qa 2.0.1 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +30 -3
  3. data/app/controllers/qa/application_controller.rb +22 -0
  4. data/app/controllers/qa/linked_data_terms_controller.rb +16 -10
  5. data/app/controllers/qa/terms_controller.rb +7 -2
  6. data/app/models/qa/mesh_tree.rb +5 -9
  7. data/app/models/qa/subject_mesh_term.rb +2 -7
  8. data/config/initializers/linked_data_authorities.rb +1 -1
  9. data/config/routes.rb +8 -0
  10. data/lib/generators/qa/install/install_generator.rb +4 -0
  11. data/lib/generators/qa/install/templates/config/initializers/qa.rb +7 -0
  12. data/lib/generators/qa/local/tables/mysql/mysql_generator.rb +1 -1
  13. data/lib/generators/qa/local/tables/tables_generator.rb +1 -1
  14. data/lib/qa.rb +16 -0
  15. data/lib/qa/authorities/assign_fast_subauthority.rb +3 -3
  16. data/lib/qa/authorities/getty/tgn.rb +1 -1
  17. data/lib/qa/authorities/getty/ulan.rb +1 -1
  18. data/lib/qa/authorities/linked_data/find_term.rb +2 -2
  19. data/lib/qa/authorities/linked_data/rdf_helper.rb +15 -0
  20. data/lib/qa/authorities/linked_data/search_query.rb +19 -3
  21. data/lib/qa/authorities/loc_subauthority.rb +2 -2
  22. data/lib/qa/authorities/local.rb +2 -4
  23. data/lib/qa/authorities/local/file_based_authority.rb +1 -1
  24. data/lib/qa/authorities/local/mysql_table_based_authority.rb +11 -2
  25. data/lib/qa/authorities/local/table_based_authority.rb +2 -1
  26. data/lib/qa/authorities/mesh_tools/mesh_data_parser.rb +1 -1
  27. data/lib/qa/authorities/mesh_tools/mesh_importer.rb +1 -1
  28. data/lib/qa/authorities/oclcts/generic_oclc_authority.rb +1 -3
  29. data/lib/qa/configuration.rb +16 -0
  30. data/lib/qa/version.rb +1 -1
  31. data/lib/tasks/mesh.rake +3 -3
  32. data/spec/controllers/linked_data_terms_controller_spec.rb +65 -14
  33. data/spec/controllers/terms_controller_spec.rb +85 -10
  34. data/spec/fixtures/{lexvo_snippet.rdf → lexvo_snippet.rdf.xml} +1 -0
  35. data/spec/lib/authorities/assign_fast_spec.rb +3 -1
  36. data/spec/lib/authorities/file_based_authority_spec.rb +19 -11
  37. data/spec/lib/authorities/geonames_spec.rb +3 -3
  38. data/spec/lib/authorities/getty/aat_spec.rb +2 -1
  39. data/spec/lib/authorities/getty/tgn_spec.rb +6 -2
  40. data/spec/lib/authorities/getty/ulan_spec.rb +4 -2
  41. data/spec/lib/authorities/getty_spec.rb +2 -1
  42. data/spec/lib/authorities/linked_data/generic_authority_spec.rb +54 -12
  43. data/spec/lib/authorities/linked_data/search_config_spec.rb +23 -19
  44. data/spec/lib/authorities/linked_data/search_query_spec.rb +67 -15
  45. data/spec/lib/authorities/linked_data/term_config_spec.rb +24 -20
  46. data/spec/lib/authorities/local_spec.rb +7 -8
  47. data/spec/lib/authorities/oclcts_spec.rb +27 -20
  48. data/spec/lib/authorities/table_based_authority_spec.rb +5 -3
  49. data/spec/lib/authorities_loc_subauthorities.rb +2 -2
  50. data/spec/lib/mesh_data_parser_spec.rb +2 -0
  51. data/spec/lib/services/rdf_authority_parser_spec.rb +1 -1
  52. data/spec/lib/tasks/mesh.rake_spec.rb +13 -12
  53. data/spec/models/subject_mesh_term_spec.rb +2 -0
  54. data/spec/requests/cors_headers_spec.rb +118 -0
  55. data/spec/spec_helper.rb +2 -2
  56. metadata +133 -142
@@ -370,32 +370,35 @@ describe Qa::Authorities::LinkedData::TermConfig do
370
370
  end
371
371
  end
372
372
 
373
+ # rubocop:disable RSpec/RepeatedExample
373
374
  describe '#term_url_with_replacements' do
374
375
  it 'returns nil if only search configuration is defined' do
375
376
  expect(search_only_config.term_url_with_replacements('C123')).to eq nil
376
377
  end
377
- it 'returns the url with query substitution applied' do
378
- expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=alpha&param2=beta'
379
- expect(full_config.term_url_with_replacements('C123')).to eq expected_url
380
- end
381
- it 'returns the url with default subauthority when NOT specified' do
382
- expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=alpha&param2=beta'
383
- expect(full_config.term_url_with_replacements('C123')).to eq expected_url
384
- end
385
- it 'returns the url with subauthority substitution when specified' do
386
- expected_url = 'http://localhost/test_default/term/term_sub3_name/C123?param1=alpha&param2=beta'
387
- expect(full_config.term_url_with_replacements('C123', 'term_sub3_key')).to eq expected_url
388
- end
389
- it 'returns the url with default values when replacements are NOT specified' do
390
- expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=alpha&param2=beta'
391
- expect(full_config.term_url_with_replacements('C123')).to eq expected_url
392
- end
393
- it 'returns the url with replacement substitution values when replacements are specified' do
394
- expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=golf&param2=hotel'
395
- expect(full_config.term_url_with_replacements('C123', nil, param1: 'golf', param2: 'hotel')).to eq expected_url
378
+ context 'when subauthorities ARE defined' do
379
+ it 'returns the url with query substitution applied' do
380
+ expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=alpha&param2=beta'
381
+ expect(full_config.term_url_with_replacements('C123')).to eq expected_url
382
+ end
383
+ it 'returns the url with default subauthority when NOT specified' do
384
+ expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=alpha&param2=beta'
385
+ expect(full_config.term_url_with_replacements('C123')).to eq expected_url
386
+ end
387
+ it 'returns the url with subauthority substitution when specified' do
388
+ expected_url = 'http://localhost/test_default/term/term_sub3_name/C123?param1=alpha&param2=beta'
389
+ expect(full_config.term_url_with_replacements('C123', 'term_sub3_key')).to eq expected_url
390
+ end
391
+ it 'returns the url with default values when replacements are NOT specified' do
392
+ expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=alpha&param2=beta'
393
+ expect(full_config.term_url_with_replacements('C123')).to eq expected_url
394
+ end
395
+ it 'returns the url with replacement substitution values when replacements are specified' do
396
+ expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=golf&param2=hotel'
397
+ expect(full_config.term_url_with_replacements('C123', nil, param1: 'golf', param2: 'hotel')).to eq expected_url
398
+ end
396
399
  end
397
400
 
398
- context 'when subauthorities are not defined' do
401
+ context 'when subauthorities are NOT defined' do
399
402
  it 'returns the url with query substitution applied' do
400
403
  expected_url = 'http://localhost/test_default/term/C123'
401
404
  expect(min_config.term_url_with_replacements('C123')).to eq expected_url
@@ -426,4 +429,5 @@ describe Qa::Authorities::LinkedData::TermConfig do
426
429
  end
427
430
  end
428
431
  end
432
+ # rubocop:enable RSpec/RepeatedExample
429
433
  end
@@ -8,11 +8,11 @@ describe Qa::Authorities::Local do
8
8
  end
9
9
 
10
10
  describe "#subauthorities_path" do
11
+ let!(:original_path) { described_class.config[:local_path] }
11
12
  before do
12
- @original_path = described_class.config[:local_path]
13
13
  described_class.config[:local_path] = path
14
14
  end
15
- after { described_class.config[:local_path] = @original_path }
15
+ after { described_class.config[:local_path] = original_path }
16
16
 
17
17
  context "configured with a full path" do
18
18
  let(:path) { "/full/path" }
@@ -25,8 +25,8 @@ describe Qa::Authorities::Local do
25
25
  context "configured with a relative path" do
26
26
  let(:path) { "relative/path" }
27
27
 
28
- it "returns a path relative to the Rails applicaition" do
29
- expect(described_class.subauthorities_path).to eq(File.join(Rails.root, path))
28
+ it "returns a path relative to the Rails application" do
29
+ expect(described_class.subauthorities_path).to eq(Rails.root.join(path).to_s)
30
30
  end
31
31
  end
32
32
  end
@@ -37,11 +37,11 @@ describe Qa::Authorities::Local do
37
37
  end
38
38
 
39
39
  context "when the path doesn't exist" do
40
+ let!(:original_path) { described_class.config[:local_path] }
40
41
  before do
41
- @original_path = described_class.config[:local_path]
42
42
  described_class.config[:local_path] = '/foo/bar'
43
43
  end
44
- after { described_class.config[:local_path] = @original_path }
44
+ after { described_class.config[:local_path] = original_path }
45
45
 
46
46
  it "raises an error" do
47
47
  expect { described_class.names }.to raise_error Qa::ConfigDirectoryNotFound
@@ -70,8 +70,7 @@ describe Qa::Authorities::Local do
70
70
  describe ".register" do
71
71
  before do
72
72
  class SolrAuthority
73
- def initialize(one)
74
- end
73
+ def initialize(one); end
75
74
  end
76
75
  described_class.register_subauthority('new_sub', 'SolrAuthority')
77
76
  end
@@ -1,46 +1,53 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::Oclcts do
4
+ let(:first_query) { described_class.subauthority_for("mesh") }
5
+ let(:terms) { first_query.search("ball") }
6
+ let(:term_record) { first_query.find(terms.first["id"]) }
7
+ let(:second_query) { described_class.subauthority_for("mesh") }
8
+
4
9
  before do
5
- stub_request(:get, "http://tspilot.oclc.org/mesh/?maximumRecords=10&operation=searchRetrieve&query=oclcts.rootHeading%20exact%20%22ball*%22&recordPacking=xml&recordSchema=http://zthes.z3950.org/xml/1.0/&recordXPath=&resultSetTTL=300&sortKeys=&startRecord=1&version=1.1")
10
+ stub_request(:get, "http://tspilot.oclc.org/mesh/?maximumRecords=10&operation=searchRetrieve&query=oclcts" \
11
+ ".rootHeading%20exact%20%22ball*%22&recordPacking=xml&recordSchema=" \
12
+ "http://zthes.z3950.org/xml/1.0/&recordXPath=&resultSetTTL=300&sortKeys=&startRecord=1&version=1.1")
6
13
  .to_return(body: webmock_fixture("oclcts-response-mesh-1.txt"), status: 200)
7
- stub_request(:get, "http://tspilot.oclc.org/mesh/?maximumRecords=10&operation=searchRetrieve&query=oclcts.rootHeading%20exact%20%22alph*%22&recordPacking=xml&recordSchema=http://zthes.z3950.org/xml/1.0/&recordXPath=&resultSetTTL=300&sortKeys=&startRecord=1&version=1.1")
14
+ stub_request(:get, "http://tspilot.oclc.org/mesh/?maximumRecords=10&operation=searchRetrieve&query=oclcts" \
15
+ ".rootHeading%20exact%20%22alph*%22&recordPacking=xml&recordSchema=" \
16
+ "http://zthes.z3950.org/xml/1.0/&recordXPath=&resultSetTTL=300&sortKeys=&startRecord=1&version=1.1")
8
17
  .to_return(body: webmock_fixture("oclcts-response-mesh-2.txt"), status: 200)
9
- stub_request(:get, "http://tspilot.oclc.org/mesh/?maximumRecords=10&operation=searchRetrieve&query=dc.identifier%20exact%20%22D031329Q000821%22&recordPacking=xml&recordSchema=http://zthes.z3950.org/xml/1.0/&recordXPath=&resultSetTTL=300&sortKeys=&startRecord=1&version=1.1")
18
+ stub_request(:get, "http://tspilot.oclc.org/mesh/?maximumRecords=10&operation=searchRetrieve&query=dc" \
19
+ ".identifier%20exact%20%22D031329Q000821%22&recordPacking=xml&recordSchema=" \
20
+ "http://zthes.z3950.org/xml/1.0/&recordXPath=&resultSetTTL=300&sortKeys=&startRecord=1&version=1.1")
10
21
  .to_return(body: webmock_fixture("oclcts-response-mesh-3.txt"), status: 200)
11
22
 
12
- @first_query = described_class.subauthority_for("mesh")
13
- @terms = @first_query.search("ball")
14
- @term_record = @first_query.find(@terms.first["id"])
15
- @second_query = described_class.subauthority_for("mesh")
16
- @second_query.search("alph")
23
+ second_query.search("alph")
17
24
  end
18
25
 
19
26
  describe "a query for terms" do
20
27
  it "has an array of hashes that match the query" do
21
- expect(@terms).to be_kind_of Array
22
- expect(@terms.first).to be_kind_of Hash
23
- expect(@terms.first["label"]).to be_kind_of String
24
- expect(@terms.first["label"]).to include "Ballota"
28
+ expect(terms).to be_kind_of Array
29
+ expect(terms.first).to be_kind_of Hash
30
+ expect(terms.first["label"]).to be_kind_of String
31
+ expect(terms.first["label"]).to include "Ballota"
25
32
  end
26
33
 
27
34
  it "has an array of hashes containing unique id and label" do
28
- expect(@terms.first).to have_key("id")
29
- expect(@terms.first).to have_key("label")
35
+ expect(terms.first).to have_key("id")
36
+ expect(terms.first).to have_key("label")
30
37
  end
31
38
  end
32
39
 
33
40
  describe "a query for a single item" do
34
41
  it "has a hash of values that represent the item requested" do
35
- expect(@term_record).to be_kind_of Hash
36
- expect(@term_record.values).to include @terms.first["id"]
37
- expect(@term_record.values).to include @terms.first["label"]
42
+ expect(term_record).to be_kind_of Hash
43
+ expect(term_record.values).to include terms.first["id"]
44
+ expect(term_record.values).to include terms.first["label"]
38
45
  end
39
46
 
40
47
  it "succeeds for valid ids, even if the id is not in the initial list of responses" do
41
- record = @second_query.find(@terms.first["id"])
42
- expect(record.values).to include @terms.first["id"]
43
- expect(record.values).to include @terms.first["label"]
48
+ record = second_query.find(terms.first["id"])
49
+ expect(record.values).to include terms.first["id"]
50
+ expect(record.values).to include terms.first["label"]
44
51
  end
45
52
  end
46
53
  end
@@ -25,9 +25,11 @@ describe Qa::Authorities::Local::TableBasedAuthority do
25
25
  end
26
26
 
27
27
  describe "#all" do
28
- let(:expected) { [{ 'id' => "A1", 'label' => "Abc Term A1" },
29
- { 'id' => "A2", 'label' => "Term A2" },
30
- { 'id' => "A3", 'label' => "Abc Term A3" }] }
28
+ let(:expected) do
29
+ [{ 'id' => "A1", 'label' => "Abc Term A1" },
30
+ { 'id' => "A2", 'label' => "Term A2" },
31
+ { 'id' => "A3", 'label' => "Abc Term A3" }]
32
+ end
31
33
  it "returns all the entries" do
32
34
  expect(language.all).to eq [
33
35
  { "id" => "http://id.loc.gov/vocabulary/languages/fre", "label" => "French" },
@@ -10,7 +10,7 @@ describe Qa::Authorities::LocSubauthority do
10
10
 
11
11
  context "with a valid subauthority" do
12
12
  it "returns a url" do
13
- subauthority_table.keys.each do |authority|
13
+ subauthority_table.each_key do |authority|
14
14
  expect(subject.get_url_for_authority(authority)).to eq(subauthority_table[authority])
15
15
  end
16
16
  end
@@ -24,7 +24,7 @@ describe Qa::Authorities::LocSubauthority do
24
24
 
25
25
  # This is the original data structure that was used to define subauthority urls
26
26
  # It is retained here to ensure our refactor succeeded
27
- def subauthority_table
27
+ def subauthority_table # rubocop:disable Metrics/MethodLength
28
28
  vocab_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2F'
29
29
  authority_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2F'
30
30
  datatype_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fdatatypes%2F'
@@ -47,6 +47,7 @@ EOS
47
47
  expect(records[1]).to eq({})
48
48
  end
49
49
 
50
+ # rubocop:disable Metrics/LineLength
50
51
  it 'parses a sample mesh file' do
51
52
  mesh = described_class.new(webmock_fixture('mesh.txt'))
52
53
  records = mesh.all_records
@@ -116,4 +117,5 @@ EOS
116
117
  "DX" => ["19840101"],
117
118
  "UI" => ["D000001"])
118
119
  end
120
+ # rubocop:enable Metrics/LineLength
119
121
  end
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Qa::Services::RDFAuthorityParser do
5
- let(:source) { [File.join(fixture_path, 'lexvo_snippet.rdf')] }
5
+ let(:source) { [File.join(fixture_path, 'lexvo_snippet.rdf.xml')] }
6
6
  let(:format) { 'rdfxml' }
7
7
  let(:predicate) { RDF::URI("http://www.w3.org/2008/05/skos#prefLabel") }
8
8
  let(:name) { 'language' }
@@ -2,33 +2,34 @@ require 'spec_helper'
2
2
  require 'rake'
3
3
  require 'stringio'
4
4
 
5
- describe "mesh rake tasks" do
5
+ describe "mesh rake tasks" do # rubocop:disable RSpec/DescribeClass
6
+ let(:rake) { Rake::Application.new }
6
7
  before do
7
- @rake = Rake::Application.new
8
- Rake.application = @rake
9
- Rake.application.rake_require "mesh", ["#{Rails.root}/lib/tasks", "#{Rails.root}/../lib/tasks"], []
8
+ Rake.application = rake
9
+ Rake.application.rake_require "mesh", [Rails.root.join('lib', 'tasks'), Rails.root.join('..', 'lib', 'tasks')], []
10
10
  Rake::Task.define_task(:environment) # rspec has loaded rails
11
11
  end
12
12
 
13
13
  describe "mesh:import" do
14
+ let(:task_name) { "mesh:import" }
15
+ let(:output) { StringIO.new }
14
16
  before do
15
- @task_name = "mesh:import"
16
- @output = StringIO.new
17
- $stdout = @output
17
+ $stdout = output # rubocop:disable RSpec/ExpectOutput # TODO: Explore how to remove this disable
18
18
  end
19
19
  after :all do
20
20
  $stdout = STDOUT
21
21
  end
22
22
  it "has 'environment' as a prereq" do
23
- expect(@rake[@task_name].prerequisites).to include("environment")
23
+ expect(rake[task_name].prerequisites).to include("environment")
24
24
  end
25
25
  it "requires $MESH_FILE to be set" do
26
26
  old_mesh_file = ENV.delete('MESH_FILE')
27
- @rake[@task_name].invoke
28
- @output.seek(0)
29
- expect(@output.read).to match(/Need to set \$MESH_FILE with path to file to ingest/)
27
+ rake[task_name].invoke
28
+ output.seek(0)
29
+ expect(output.read).to match(/Need to set \$MESH_FILE with path to file to ingest/)
30
30
  ENV['MESH_FILE'] = old_mesh_file
31
31
  end
32
+
32
33
  describe "create or update" do
33
34
  let(:input) { StringIO.new("*NEWRECORD\nUI = 5\nMH = test\n") }
34
35
  let(:term) { Qa::SubjectMeshTerm.find_by_term_id(5) }
@@ -36,7 +37,7 @@ describe "mesh rake tasks" do
36
37
  before do
37
38
  ENV['MESH_FILE'] = "dummy"
38
39
  allow(File).to receive(:open).with("dummy").and_yield(input)
39
- @rake[@task_name].invoke
40
+ rake[task_name].invoke
40
41
  end
41
42
  it "creates or update all records in the config file" do
42
43
  expect(term).not_to be_nil
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
+ # rubocop:disable RSpec/InstanceVariable # TODO: Explore if there is a way to remove this disable
3
4
  describe Qa::SubjectMeshTerm, type: :model do
4
5
  before(:all) do
5
6
  @term = Qa::SubjectMeshTerm.new
@@ -47,3 +48,4 @@ describe Qa::SubjectMeshTerm, type: :model do
47
48
  # @term.parents.map { |p| p.term_id }.should == ["1", "2", "3"]
48
49
  # end
49
50
  end
51
+ # rubocop:enable RSpec/InstanceVariable
@@ -0,0 +1,118 @@
1
+ # spec/requests/cors_headers_spec.rb
2
+ require 'spec_helper'
3
+
4
+ describe "CORS OPTIONS requests" do # rubocop:disable RSpec/DescribeClass
5
+ context 'when cors headers are enabled' do
6
+ before do
7
+ Qa.config.enable_cors_headers
8
+ end
9
+
10
+ it 'return CORS header info for index' do
11
+ reset!
12
+ integration_session.__send__ :process, 'OPTIONS', "/qa/terms/loc"
13
+ correct_cors_response?
14
+ end
15
+
16
+ it 'return CORS header info for index with subauthority' do
17
+ reset!
18
+ integration_session.__send__ :process, 'OPTIONS', "/qa/terms/local/states"
19
+ correct_cors_response?
20
+ end
21
+
22
+ it 'return CORS header info for search' do
23
+ reset!
24
+ integration_session.__send__ :process, 'OPTIONS', "/qa/search/loc"
25
+ correct_cors_response?
26
+ end
27
+
28
+ it 'return CORS header info for search with subauthority' do
29
+ reset!
30
+ integration_session.__send__ :process, 'OPTIONS', "/qa/search/local/two_args?q=a query"
31
+ correct_cors_response?
32
+ end
33
+
34
+ it 'return CORS header info for show' do
35
+ reset!
36
+ integration_session.__send__ :process, 'OPTIONS', "/qa/show/mesh/D000001"
37
+ correct_cors_response?
38
+ end
39
+
40
+ it 'return CORS header info for show with subauthority' do
41
+ reset!
42
+ integration_session.__send__ :process, 'OPTIONS', "/qa/show/local/states/OH"
43
+ correct_cors_response?
44
+ end
45
+
46
+ it 'return CORS header info for linked_data/search' do
47
+ reset!
48
+ integration_session.__send__ :process, 'OPTIONS', "/qa/search/linked_data/OCLC_FAST?q=my_query&maximumRecords=3"
49
+ correct_cors_response?
50
+ end
51
+
52
+ it 'return CORS header info for linked_data/show' do
53
+ reset!
54
+ integration_session.__send__ :process, 'OPTIONS', "/qa/show/linked_data/OCLC_FAST/n24"
55
+ correct_cors_response?
56
+ end
57
+ end
58
+
59
+ def correct_cors_response?
60
+ expect(response.code).to eq('204')
61
+ expect(response.headers['Access-Control-Allow-Origin']).to eq '*'
62
+ expect(response.headers['Access-Control-Allow-Methods']).to eq 'GET, OPTIONS'
63
+ end
64
+
65
+ context 'when cors headers are disabled' do
66
+ before do
67
+ Qa.config.disable_cors_headers
68
+ end
69
+
70
+ it 'report method not supported for index' do
71
+ reset!
72
+ integration_session.__send__ :process, 'OPTIONS', "/qa/terms/loc"
73
+ expect(response.code).to eq('501')
74
+ end
75
+
76
+ it 'report method not supported for index with subauthority' do
77
+ reset!
78
+ integration_session.__send__ :process, 'OPTIONS', "/qa/terms/local/states"
79
+ expect(response.code).to eq('501')
80
+ end
81
+
82
+ it 'report method not supported for search' do
83
+ reset!
84
+ integration_session.__send__ :process, 'OPTIONS', "/qa/search/loc"
85
+ expect(response.code).to eq('501')
86
+ end
87
+
88
+ it 'report method not supported for search with subauthority' do
89
+ reset!
90
+ integration_session.__send__ :process, 'OPTIONS', "/qa/search/local/two_args?q=a query"
91
+ expect(response.code).to eq('501')
92
+ end
93
+
94
+ it 'report method not supported for show' do
95
+ reset!
96
+ integration_session.__send__ :process, 'OPTIONS', "/qa/show/mesh/D000001"
97
+ expect(response.code).to eq('501')
98
+ end
99
+
100
+ it 'report method not supported for show with subauthority' do
101
+ reset!
102
+ integration_session.__send__ :process, 'OPTIONS', "/qa/show/local/states/OH"
103
+ expect(response.code).to eq('501')
104
+ end
105
+
106
+ it 'report method not supported for linked_data/search' do
107
+ reset!
108
+ integration_session.__send__ :process, 'OPTIONS', "/qa/search/linked_data/OCLC_FAST?q=my_query&maximumRecords=3"
109
+ expect(response.code).to eq('501')
110
+ end
111
+
112
+ it 'report method not supported for linked_data/show' do
113
+ reset!
114
+ integration_session.__send__ :process, 'OPTIONS', "/qa/show/linked_data/OCLC_FAST/n24"
115
+ expect(response.code).to eq('501')
116
+ end
117
+ end
118
+ end
@@ -19,7 +19,7 @@ require 'pry'
19
19
 
20
20
  # Requires supporting ruby files with custom matchers and macros, etc,
21
21
  # in spec/support/ and its subdirectories.
22
- Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
22
+ Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
23
23
 
24
24
  RSpec.configure do |config|
25
25
  config.fixture_path = File.expand_path("../fixtures", __FILE__)
@@ -49,7 +49,7 @@ end
49
49
 
50
50
  # returns the file contents
51
51
  def load_fixture_file(fname)
52
- File.open(Rails.root.join("spec/fixtures", fname)) do |f|
52
+ File.open(Rails.root.join('spec', 'fixtures', fname)) do |f|
53
53
  return f.read
54
54
  end
55
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qa
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Anderson
@@ -12,25 +12,40 @@ authors:
12
12
  - Eric James
13
13
  - Mike Stroming
14
14
  - Adam Wead
15
+ - E. Lynette Rayle
15
16
  autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
- date: 2018-02-22 00:00:00.000000000 Z
19
+ date: 2018-09-07 00:00:00.000000000 Z
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: rails
22
+ name: activerecord-import
22
23
  requirement: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - "~>"
25
+ - - ">="
25
26
  - !ruby/object:Gem::Version
26
- version: '5.0'
27
+ version: '0'
27
28
  type: :runtime
28
29
  prerelease: false
29
30
  version_requirements: !ruby/object:Gem::Requirement
30
31
  requirements:
31
- - - "~>"
32
+ - - ">="
32
33
  - !ruby/object:Gem::Version
33
- version: '5.0'
34
+ version: '0'
35
+ - !ruby/object:Gem::Dependency
36
+ name: deprecation
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
34
49
  - !ruby/object:Gem::Dependency
35
50
  name: faraday
36
51
  requirement: !ruby/object:Gem::Requirement
@@ -60,21 +75,21 @@ dependencies:
60
75
  - !ruby/object:Gem::Version
61
76
  version: '1.6'
62
77
  - !ruby/object:Gem::Dependency
63
- name: activerecord-import
78
+ name: rails
64
79
  requirement: !ruby/object:Gem::Requirement
65
80
  requirements:
66
- - - ">="
81
+ - - "~>"
67
82
  - !ruby/object:Gem::Version
68
- version: '0'
83
+ version: '5.0'
69
84
  type: :runtime
70
85
  prerelease: false
71
86
  version_requirements: !ruby/object:Gem::Requirement
72
87
  requirements:
73
- - - ">="
88
+ - - "~>"
74
89
  - !ruby/object:Gem::Version
75
- version: '0'
90
+ version: '5.0'
76
91
  - !ruby/object:Gem::Dependency
77
- name: deprecation
92
+ name: rdf
78
93
  requirement: !ruby/object:Gem::Requirement
79
94
  requirements:
80
95
  - - ">="
@@ -88,19 +103,19 @@ dependencies:
88
103
  - !ruby/object:Gem::Version
89
104
  version: '0'
90
105
  - !ruby/object:Gem::Dependency
91
- name: rdf
106
+ name: bixby
92
107
  requirement: !ruby/object:Gem::Requirement
93
108
  requirements:
94
- - - ">="
109
+ - - "~>"
95
110
  - !ruby/object:Gem::Version
96
- version: '0'
97
- type: :runtime
111
+ version: 1.0.0
112
+ type: :development
98
113
  prerelease: false
99
114
  version_requirements: !ruby/object:Gem::Requirement
100
115
  requirements:
101
- - - ">="
116
+ - - "~>"
102
117
  - !ruby/object:Gem::Version
103
- version: '0'
118
+ version: 1.0.0
104
119
  - !ruby/object:Gem::Dependency
105
120
  name: byebug
106
121
  requirement: !ruby/object:Gem::Requirement
@@ -116,21 +131,21 @@ dependencies:
116
131
  - !ruby/object:Gem::Version
117
132
  version: '0'
118
133
  - !ruby/object:Gem::Dependency
119
- name: pry
134
+ name: engine_cart
120
135
  requirement: !ruby/object:Gem::Requirement
121
136
  requirements:
122
- - - ">="
137
+ - - "~>"
123
138
  - !ruby/object:Gem::Version
124
- version: '0'
139
+ version: '0.8'
125
140
  type: :development
126
141
  prerelease: false
127
142
  version_requirements: !ruby/object:Gem::Requirement
128
143
  requirements:
129
- - - ">="
144
+ - - "~>"
130
145
  - !ruby/object:Gem::Version
131
- version: '0'
146
+ version: '0.8'
132
147
  - !ruby/object:Gem::Dependency
133
- name: pry-byebug
148
+ name: linkeddata
134
149
  requirement: !ruby/object:Gem::Requirement
135
150
  requirements:
136
151
  - - ">="
@@ -144,7 +159,7 @@ dependencies:
144
159
  - !ruby/object:Gem::Version
145
160
  version: '0'
146
161
  - !ruby/object:Gem::Dependency
147
- name: linkeddata
162
+ name: pry
148
163
  requirement: !ruby/object:Gem::Requirement
149
164
  requirements:
150
165
  - - ">="
@@ -158,19 +173,19 @@ dependencies:
158
173
  - !ruby/object:Gem::Version
159
174
  version: '0'
160
175
  - !ruby/object:Gem::Dependency
161
- name: engine_cart
176
+ name: pry-byebug
162
177
  requirement: !ruby/object:Gem::Requirement
163
178
  requirements:
164
- - - "~>"
179
+ - - ">="
165
180
  - !ruby/object:Gem::Version
166
- version: '0.8'
181
+ version: '0'
167
182
  type: :development
168
183
  prerelease: false
169
184
  version_requirements: !ruby/object:Gem::Requirement
170
185
  requirements:
171
- - - "~>"
186
+ - - ">="
172
187
  - !ruby/object:Gem::Version
173
- version: '0.8'
188
+ version: '0'
174
189
  - !ruby/object:Gem::Dependency
175
190
  name: rspec-rails
176
191
  requirement: !ruby/object:Gem::Requirement
@@ -227,34 +242,6 @@ dependencies:
227
242
  - - ">="
228
243
  - !ruby/object:Gem::Version
229
244
  version: '0'
230
- - !ruby/object:Gem::Dependency
231
- name: rubocop
232
- requirement: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - "~>"
235
- - !ruby/object:Gem::Version
236
- version: 0.42.0
237
- type: :development
238
- prerelease: false
239
- version_requirements: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - "~>"
242
- - !ruby/object:Gem::Version
243
- version: 0.42.0
244
- - !ruby/object:Gem::Dependency
245
- name: rubocop-rspec
246
- requirement: !ruby/object:Gem::Requirement
247
- requirements:
248
- - - "~>"
249
- - !ruby/object:Gem::Version
250
- version: 1.8.0
251
- type: :development
252
- prerelease: false
253
- version_requirements: !ruby/object:Gem::Requirement
254
- requirements:
255
- - - "~>"
256
- - !ruby/object:Gem::Version
257
- version: 1.8.0
258
245
  description: Provides a set of uniform RESTful routes to query any controlled vocabulary
259
246
  or set of authority terms.
260
247
  email:
@@ -289,6 +276,7 @@ files:
289
276
  - db/migrate/20130918141523_add_term_lower_to_qa_subject_mesh_terms.rb
290
277
  - lib/generators/qa/install/USAGE
291
278
  - lib/generators/qa/install/install_generator.rb
279
+ - lib/generators/qa/install/templates/config/initializers/qa.rb
292
280
  - lib/generators/qa/install/templates/config/oclcts-authorities.yml
293
281
  - lib/generators/qa/local/USAGE
294
282
  - lib/generators/qa/local/files/files_generator.rb
@@ -336,6 +324,7 @@ files:
336
324
  - lib/qa/authorities/oclcts/generic_oclc_authority.rb
337
325
  - lib/qa/authorities/tgnlang.rb
338
326
  - lib/qa/authorities/web_service_base.rb
327
+ - lib/qa/configuration.rb
339
328
  - lib/qa/data/TGN_LANGUAGES.xml
340
329
  - lib/qa/engine.rb
341
330
  - lib/qa/services.rb
@@ -379,7 +368,7 @@ files:
379
368
  - spec/fixtures/journals-noquery.json
380
369
  - spec/fixtures/journals-noresults.json
381
370
  - spec/fixtures/journals-result.json
382
- - spec/fixtures/lexvo_snippet.rdf
371
+ - spec/fixtures/lexvo_snippet.rdf.xml
383
372
  - spec/fixtures/loc-names-response.txt
384
373
  - spec/fixtures/loc-response.txt
385
374
  - spec/fixtures/loc-subject-find-response.txt
@@ -435,6 +424,7 @@ files:
435
424
  - spec/lib/services/rdf_authority_parser_spec.rb
436
425
  - spec/lib/tasks/mesh.rake_spec.rb
437
426
  - spec/models/subject_mesh_term_spec.rb
427
+ - spec/requests/cors_headers_spec.rb
438
428
  - spec/routing/linked_data_route_spec.rb
439
429
  - spec/routing/route_spec.rb
440
430
  - spec/spec_helper.rb
@@ -465,100 +455,101 @@ signing_key:
465
455
  specification_version: 4
466
456
  summary: You should question your authorities.
467
457
  test_files:
468
- - spec/controllers/linked_data_terms_controller_spec.rb
469
- - spec/controllers/terms_controller_spec.rb
458
+ - spec/spec_helper.rb
459
+ - spec/models/subject_mesh_term_spec.rb
460
+ - spec/requests/cors_headers_spec.rb
461
+ - spec/test_app_templates/lib/generators/test_app_generator.rb
462
+ - spec/test_app_templates/Gemfile.extra
463
+ - spec/lib/tasks/mesh.rake_spec.rb
464
+ - spec/lib/authorities_loc_subauthorities.rb
465
+ - spec/lib/mesh_data_parser_spec.rb
466
+ - spec/lib/authorities/linked_data/config_spec.rb
467
+ - spec/lib/authorities/linked_data/search_config_spec.rb
468
+ - spec/lib/authorities/linked_data/search_query_spec.rb
469
+ - spec/lib/authorities/linked_data/term_config_spec.rb
470
+ - spec/lib/authorities/linked_data/find_term_spec.rb
471
+ - spec/lib/authorities/linked_data/generic_authority_spec.rb
472
+ - spec/lib/authorities/loc_spec.rb
473
+ - spec/lib/authorities/tgnlang_spec.rb
474
+ - spec/lib/authorities/crossref_spec.rb
475
+ - spec/lib/authorities/oclcts_spec.rb
476
+ - spec/lib/authorities/file_based_authority_spec.rb
477
+ - spec/lib/authorities/space_fix_encoder.rb
478
+ - spec/lib/authorities/assign_fast_spec.rb
479
+ - spec/lib/authorities/table_based_authority_spec.rb
480
+ - spec/lib/authorities/getty/tgn_spec.rb
481
+ - spec/lib/authorities/getty/ulan_spec.rb
482
+ - spec/lib/authorities/getty/aat_spec.rb
483
+ - spec/lib/authorities/mesh_spec.rb
484
+ - spec/lib/authorities/mysql_table_based_authority_spec.rb
485
+ - spec/lib/authorities/local_spec.rb
486
+ - spec/lib/authorities/geonames_spec.rb
487
+ - spec/lib/authorities/base_spec.rb
488
+ - spec/lib/authorities/getty_spec.rb
489
+ - spec/lib/services/rdf_authority_parser_spec.rb
490
+ - spec/fixtures/oclcts-response-mesh-3.txt
491
+ - spec/fixtures/loc-names-response.txt
492
+ - spec/fixtures/oclcts-response-mesh-2.txt
470
493
  - spec/fixtures/aat-response.txt
471
- - spec/fixtures/assign-fast-noheader.json
472
- - spec/fixtures/assign-fast-noresults.json
494
+ - spec/fixtures/journals-result.json
495
+ - spec/fixtures/lod_lang_search_fr.rdf.xml
496
+ - spec/fixtures/oclcts-response-mesh-1.txt
497
+ - spec/fixtures/lod_lang_term_fr.rdf.xml
498
+ - spec/fixtures/funders-noquery.json
499
+ - spec/fixtures/lod_lang_term_enfrde.rdf.xml
473
500
  - spec/fixtures/assign-fast-oneresult.json
501
+ - spec/fixtures/getty-aat-find-response.json
502
+ - spec/fixtures/lod_lang_term_enfr_noalt.rdf.xml
503
+ - spec/fixtures/assign-fast-noresults.json
504
+ - spec/fixtures/lod_loc_term_found.rdf.xml
505
+ - spec/fixtures/lod_lang_term_enfr.rdf.xml
474
506
  - spec/fixtures/assign-fast-topical-result.json
475
- - spec/fixtures/authorities/authority_A.yml
476
- - spec/fixtures/authorities/authority_B.yml
477
- - spec/fixtures/authorities/authority_C.yml
478
- - spec/fixtures/authorities/authority_D.yml
479
- - spec/fixtures/authorities/linked_data/lod_encoding_config.json
480
- - spec/fixtures/authorities/linked_data/lod_full_config.json
481
- - spec/fixtures/authorities/linked_data/lod_lang_defaults.json
482
- - spec/fixtures/authorities/linked_data/lod_lang_multi_defaults.json
483
- - spec/fixtures/authorities/linked_data/lod_lang_no_defaults.json
484
- - spec/fixtures/authorities/linked_data/lod_lang_param.json
485
- - spec/fixtures/authorities/linked_data/lod_min_config.json
486
- - spec/fixtures/authorities/linked_data/lod_search_only_config.json
487
- - spec/fixtures/authorities/linked_data/lod_sort.json
488
- - spec/fixtures/authorities/linked_data/lod_term_id_param_config.json
489
- - spec/fixtures/authorities/linked_data/lod_term_only_config.json
490
- - spec/fixtures/funders-find-response.json
491
- - spec/fixtures/funders-noquery.json
507
+ - spec/fixtures/getty-ulan-find-response.json
508
+ - spec/fixtures/loc-subjects-response.txt
509
+ - spec/fixtures/loc-subject-find-response.txt
510
+ - spec/fixtures/lod_oclc_all_query_3_results.rdf.xml
492
511
  - spec/fixtures/funders-noresults.json
493
- - spec/fixtures/funders-result.json
494
- - spec/fixtures/geonames-find-response.json
495
- - spec/fixtures/geonames-response.json
496
- - spec/fixtures/getty-aat-find-response.json
497
512
  - spec/fixtures/getty-tgn-find-response.json
498
- - spec/fixtures/getty-ulan-find-response.json
513
+ - spec/fixtures/lod_lang_search_enfr.rdf.xml
499
514
  - spec/fixtures/journals-find-response-two-issn.json
500
- - spec/fixtures/journals-find-response.json
501
- - spec/fixtures/journals-noquery.json
502
- - spec/fixtures/journals-noresults.json
503
- - spec/fixtures/journals-result.json
504
- - spec/fixtures/lexvo_snippet.rdf
505
- - spec/fixtures/loc-names-response.txt
515
+ - spec/fixtures/mesh.txt
516
+ - spec/fixtures/geonames-find-response.json
517
+ - spec/fixtures/lod_oclc_personalName_query_3_results.rdf.xml
506
518
  - spec/fixtures/loc-response.txt
507
- - spec/fixtures/loc-subject-find-response.txt
508
- - spec/fixtures/loc-subjects-response.txt
509
- - spec/fixtures/lod_agrovoc_query_many_results.json
510
- - spec/fixtures/lod_agrovoc_query_no_results.json
519
+ - spec/fixtures/funders-find-response.json
520
+ - spec/fixtures/lexvo_snippet.rdf.xml
521
+ - spec/fixtures/journals-find-response.json
511
522
  - spec/fixtures/lod_agrovoc_term_found.rdf.xml
523
+ - spec/fixtures/lod_agrovoc_query_many_results.json
512
524
  - spec/fixtures/lod_lang_search_en.rdf.xml
513
- - spec/fixtures/lod_lang_search_enfr.rdf.xml
514
- - spec/fixtures/lod_lang_search_enfrde.rdf.xml
515
- - spec/fixtures/lod_lang_search_fr.rdf.xml
516
525
  - spec/fixtures/lod_lang_term_en.rdf.xml
517
- - spec/fixtures/lod_lang_term_enfr.rdf.xml
518
- - spec/fixtures/lod_lang_term_enfr_noalt.rdf.xml
519
- - spec/fixtures/lod_lang_term_enfrde.rdf.xml
520
- - spec/fixtures/lod_lang_term_fr.rdf.xml
521
- - spec/fixtures/lod_loc_term_found.rdf.xml
522
- - spec/fixtures/lod_oclc_all_query_3_results.rdf.xml
523
- - spec/fixtures/lod_oclc_personalName_query_3_results.rdf.xml
526
+ - spec/fixtures/journals-noresults.json
527
+ - spec/fixtures/journals-noquery.json
524
528
  - spec/fixtures/lod_oclc_query_no_results.rdf.xml
525
- - spec/fixtures/lod_oclc_term_found.rdf.xml
526
- - spec/fixtures/mesh.txt
527
- - spec/fixtures/oclcts-response-mesh-1.txt
528
- - spec/fixtures/oclcts-response-mesh-2.txt
529
- - spec/fixtures/oclcts-response-mesh-3.txt
529
+ - spec/fixtures/authorities/linked_data/lod_search_only_config.json
530
+ - spec/fixtures/authorities/linked_data/lod_sort.json
531
+ - spec/fixtures/authorities/linked_data/lod_min_config.json
532
+ - spec/fixtures/authorities/linked_data/lod_encoding_config.json
533
+ - spec/fixtures/authorities/linked_data/lod_term_id_param_config.json
534
+ - spec/fixtures/authorities/linked_data/lod_lang_multi_defaults.json
535
+ - spec/fixtures/authorities/linked_data/lod_lang_defaults.json
536
+ - spec/fixtures/authorities/linked_data/lod_term_only_config.json
537
+ - spec/fixtures/authorities/linked_data/lod_lang_no_defaults.json
538
+ - spec/fixtures/authorities/linked_data/lod_full_config.json
539
+ - spec/fixtures/authorities/linked_data/lod_lang_param.json
540
+ - spec/fixtures/authorities/authority_D.yml
541
+ - spec/fixtures/authorities/authority_A.yml
542
+ - spec/fixtures/authorities/authority_C.yml
543
+ - spec/fixtures/authorities/authority_B.yml
544
+ - spec/fixtures/geonames-response.json
530
545
  - spec/fixtures/tgn-response.txt
546
+ - spec/fixtures/lod_oclc_term_found.rdf.xml
547
+ - spec/fixtures/assign-fast-noheader.json
548
+ - spec/fixtures/lod_agrovoc_query_no_results.json
549
+ - spec/fixtures/lod_lang_search_enfrde.rdf.xml
550
+ - spec/fixtures/funders-result.json
531
551
  - spec/fixtures/ulan-response.txt
532
- - spec/lib/authorities/assign_fast_spec.rb
533
- - spec/lib/authorities/base_spec.rb
534
- - spec/lib/authorities/crossref_spec.rb
535
- - spec/lib/authorities/file_based_authority_spec.rb
536
- - spec/lib/authorities/geonames_spec.rb
537
- - spec/lib/authorities/getty/aat_spec.rb
538
- - spec/lib/authorities/getty/tgn_spec.rb
539
- - spec/lib/authorities/getty/ulan_spec.rb
540
- - spec/lib/authorities/getty_spec.rb
541
- - spec/lib/authorities/linked_data/config_spec.rb
542
- - spec/lib/authorities/linked_data/find_term_spec.rb
543
- - spec/lib/authorities/linked_data/generic_authority_spec.rb
544
- - spec/lib/authorities/linked_data/search_config_spec.rb
545
- - spec/lib/authorities/linked_data/search_query_spec.rb
546
- - spec/lib/authorities/linked_data/term_config_spec.rb
547
- - spec/lib/authorities/loc_spec.rb
548
- - spec/lib/authorities/local_spec.rb
549
- - spec/lib/authorities/mesh_spec.rb
550
- - spec/lib/authorities/mysql_table_based_authority_spec.rb
551
- - spec/lib/authorities/oclcts_spec.rb
552
- - spec/lib/authorities/space_fix_encoder.rb
553
- - spec/lib/authorities/table_based_authority_spec.rb
554
- - spec/lib/authorities/tgnlang_spec.rb
555
- - spec/lib/authorities_loc_subauthorities.rb
556
- - spec/lib/mesh_data_parser_spec.rb
557
- - spec/lib/services/rdf_authority_parser_spec.rb
558
- - spec/lib/tasks/mesh.rake_spec.rb
559
- - spec/models/subject_mesh_term_spec.rb
560
552
  - spec/routing/linked_data_route_spec.rb
561
553
  - spec/routing/route_spec.rb
562
- - spec/spec_helper.rb
563
- - spec/test_app_templates/Gemfile.extra
564
- - spec/test_app_templates/lib/generators/test_app_generator.rb
554
+ - spec/controllers/terms_controller_spec.rb
555
+ - spec/controllers/linked_data_terms_controller_spec.rb