qa 5.5.0 → 5.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/app/controllers/qa/terms_controller.rb +9 -0
- data/app/services/qa/linked_data/authority_url_service.rb +1 -1
- data/config/authorities/linked_data/oclc_fast.json +5 -5
- data/config/routes.rb +4 -0
- data/lib/qa/authorities/loc_subauthority.rb +4 -4
- data/lib/qa/authorities/local/file_based_authority.rb +3 -2
- data/lib/qa/version.rb +1 -1
- data/spec/controllers/linked_data_terms_controller_spec.rb +9 -9
- data/spec/controllers/terms_controller_spec.rb +30 -1
- data/spec/fixtures/authorities/authority_U.yml +13 -0
- data/spec/lib/authorities/linked_data/find_term_spec.rb +6 -6
- data/spec/lib/authorities/loc_spec.rb +7 -7
- data/spec/lib/authorities/{file_based_authority_spec.rb → local/file_based_authority_spec.rb} +11 -0
- data/spec/lib/authorities/{mysql_table_based_authority_spec.rb → local/mysql_table_based_authority_spec.rb} +0 -0
- data/spec/lib/authorities/{table_based_authority_spec.rb → local/table_based_authority_spec.rb} +0 -0
- data/spec/lib/authorities/local_spec.rb +3 -1
- data/spec/services/linked_data/authority_url_service_spec.rb +9 -3
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fb01e5ca2c9435b8c22af76ace78a1486d2ad22ee54f0a8e1a40ba24b64e218
|
4
|
+
data.tar.gz: '0825479f37ac4eb299c944981fff9b670e8efd86eb8b05c3341f7d2a9300361c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80792bf55b1f8cf6f7401657d7b7844fbeff0dbc4e4597e16869a63a65a6cf1e271d88d631bd0dd9f4f8dbcdda2caadac47974d8d282f21ee1696308022bb201
|
7
|
+
data.tar.gz: 7d700e24566d6047cb061731e941affa72d3c260eb7822c421421986127ddfd819f2d6d4cd1c968cd9e527b3276c392a7403564ebce8e5ee4210fb86863072d0
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Questioning Authority
|
2
2
|
|
3
|
-
Code: [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa) [![Build Status](https://circleci.com/gh/samvera/questioning_authority.svg?style=svg)](https://circleci.com/gh/samvera/questioning_authority) [![Coverage Status](https://coveralls.io/repos/github/samvera/questioning_authority/badge.svg?branch=
|
3
|
+
Code: [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa) [![Build Status](https://circleci.com/gh/samvera/questioning_authority.svg?style=svg)](https://circleci.com/gh/samvera/questioning_authority) [![Coverage Status](https://coveralls.io/repos/github/samvera/questioning_authority/badge.svg?branch=main)](https://coveralls.io/github/samvera/questioning_authority?branch=main)
|
4
4
|
|
5
5
|
Docs: [![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./CONTRIBUTING.md) [![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE)
|
6
6
|
|
@@ -145,6 +145,12 @@ rake ci
|
|
145
145
|
|
146
146
|
Commit your features into a new branch and submit a pull request.
|
147
147
|
|
148
|
+
## Contributing
|
149
|
+
|
150
|
+
If you're working on PR for this project, create a feature branch off of `main`.
|
151
|
+
|
152
|
+
This repository follows the [Samvera Community Code of Conduct](https://samvera.atlassian.net/wiki/spaces/samvera/pages/405212316/Code+of+Conduct) and [language recommendations](https://github.com/samvera/maintenance/blob/main/templates/CONTRIBUTING.md#language). Please ***do not*** create a branch called `master` for this repository or as part of your pull request; the branch will either need to be removed or renamed before it can be considered for inclusion in the code base and history of this repository.
|
153
|
+
|
148
154
|
## Compatibility
|
149
155
|
|
150
156
|
- Ruby 2.5 or the latest 2.4 version is recommended. Later versions may also work.
|
@@ -169,7 +175,7 @@ Questioning Authority is a Core Component of the Samvera community. The document
|
|
169
175
|
github_changelog_generator --user samvera --project questioning_authority --token YOUR_GITHUB_TOKEN_HERE
|
170
176
|
```
|
171
177
|
|
172
|
-
5. Commit these changes to the
|
178
|
+
5. Commit these changes to the main branch
|
173
179
|
|
174
180
|
6. Run `rake release`
|
175
181
|
|
@@ -27,12 +27,21 @@ class Qa::TermsController < ::ApplicationController
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# If the subauthority supports it, return all the information for a given term
|
30
|
+
# Expects id to be part of the request path (e.g. http://my.app/qa/show/auth/subauth/{:id})
|
30
31
|
def show
|
31
32
|
term = @authority.method(:find).arity == 2 ? @authority.find(params[:id], self) : @authority.find(params[:id])
|
32
33
|
cors_allow_origin_header(response)
|
33
34
|
render json: term, content_type: content_type_for_format
|
34
35
|
end
|
35
36
|
|
37
|
+
# If the subauthority supports it, return all the information for a given term
|
38
|
+
# Expects uri to be a request parameter (e.g. http://my.app/qa/show/auth/subauth?uri={:uri})
|
39
|
+
def fetch
|
40
|
+
term = @authority.method(:find).arity == 2 ? @authority.find(params[:uri], self) : @authority.find(params[:uri])
|
41
|
+
cors_allow_origin_header(response)
|
42
|
+
render json: term, content_type: content_type_for_format
|
43
|
+
end
|
44
|
+
|
36
45
|
def check_vocab_param
|
37
46
|
return if params[:vocab].present?
|
38
47
|
msg = "Required param 'vocab' is missing or empty"
|
@@ -29,7 +29,7 @@ module Qa
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def combined_substitutions(action_config, action, action_request, request_header)
|
32
|
-
substitutions = request_header.fetch(:replacements, {})
|
32
|
+
substitutions = request_header.fetch(:replacements, {}).clone
|
33
33
|
substitutions[action_request_variable(action_config, action)] = action_request
|
34
34
|
substitutions[action_subauth_variable(action_config)] = action_subauth_variable_value(action_config, request_header)
|
35
35
|
substitutions[action_language_variable(action_config)] = language_value(action_config, request_header)
|
@@ -2,14 +2,13 @@
|
|
2
2
|
"QA_CONFIG_VERSION": "2.1",
|
3
3
|
"prefixes": {
|
4
4
|
"dcterms": "http://purl.org/dc/terms/",
|
5
|
-
"
|
6
|
-
"schema": "http://schema.org/"
|
5
|
+
"schema": "http://schema.org/"
|
7
6
|
},
|
8
7
|
"term": {
|
9
8
|
"url": {
|
10
9
|
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
|
11
10
|
"@type": "IriTemplate",
|
12
|
-
"template": "http://id.worldcat.org/fast/{term_id}",
|
11
|
+
"template": "http://id.worldcat.org/fast/{term_id}.rdf.xml",
|
13
12
|
"variableRepresentation": "BasicRepresentation",
|
14
13
|
"mapping": [
|
15
14
|
{
|
@@ -35,14 +34,15 @@
|
|
35
34
|
"url": {
|
36
35
|
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
|
37
36
|
"@type": "IriTemplate",
|
38
|
-
"template": "http://experimental.worldcat.org/fast/search?query={subauth}+all+%22{query}%22&sortKeys=usage&{
|
37
|
+
"template": "http://experimental.worldcat.org/fast/search?query={subauth}+all+%22{query}%22&sortKeys=usage&maximumRecords={maximumRecords}",
|
39
38
|
"variableRepresentation": "BasicRepresentation",
|
40
39
|
"mapping": [
|
41
40
|
{
|
42
41
|
"@type": "IriTemplateMapping",
|
43
42
|
"variable": "query",
|
44
43
|
"property": "hydra:freetextQuery",
|
45
|
-
"required": true
|
44
|
+
"required": true,
|
45
|
+
"encode": true
|
46
46
|
},
|
47
47
|
{
|
48
48
|
"@type": "IriTemplateMapping",
|
data/config/routes.rb
CHANGED
@@ -9,6 +9,8 @@ Qa::Engine.routes.draw do
|
|
9
9
|
get "/search/:vocab(/:subauthority)", controller: :terms, action: :search
|
10
10
|
get "/show/:vocab/:id", controller: :terms, action: :show
|
11
11
|
get "/show/:vocab/:subauthority/:id", controller: :terms, action: :show
|
12
|
+
get "/fetch/:vocab", controller: :terms, action: :fetch
|
13
|
+
get "/fetch/:vocab/:subauthority", controller: :terms, action: :fetch
|
12
14
|
|
13
15
|
match "/search/linked_data/:vocab(/:subauthority)", to: 'application#options', via: [:options]
|
14
16
|
match "/show/linked_data/:vocab/:id", to: 'application#options', via: [:options]
|
@@ -17,4 +19,6 @@ Qa::Engine.routes.draw do
|
|
17
19
|
match "/search/:vocab(/:subauthority)", to: 'application#options', via: [:options]
|
18
20
|
match "/show/:vocab/:id", to: 'application#options', via: [:options]
|
19
21
|
match "/show/:vocab/:subauthority/:id", to: 'application#options', via: [:options]
|
22
|
+
match "/fetch/:vocab", to: 'application#options', via: [:options]
|
23
|
+
match "/fetch/:vocab/:subauthority", to: 'application#options', via: [:options]
|
20
24
|
end
|
@@ -70,18 +70,18 @@ module Qa::Authorities::LocSubauthority
|
|
70
70
|
private
|
71
71
|
|
72
72
|
def vocab_base_url
|
73
|
-
"cs%
|
73
|
+
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2F"
|
74
74
|
end
|
75
75
|
|
76
76
|
def authority_base_url
|
77
|
-
"cs%
|
77
|
+
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2F"
|
78
78
|
end
|
79
79
|
|
80
80
|
def datatype_base_url
|
81
|
-
"cs%
|
81
|
+
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fdatatypes%2F"
|
82
82
|
end
|
83
83
|
|
84
84
|
def vocab_preservation_base_url
|
85
|
-
"cs%
|
85
|
+
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2Fpreservation%2F"
|
86
86
|
end
|
87
87
|
end
|
@@ -8,13 +8,14 @@ module Qa::Authorities
|
|
8
8
|
def search(q)
|
9
9
|
r = q.blank? ? [] : terms.select { |term| /\b#{q.downcase}/.match(term[:term].downcase) }
|
10
10
|
r.map do |res|
|
11
|
-
{ id: res[:id], label: res[:term] }.with_indifferent_access
|
11
|
+
{ id: res[:id], label: res[:term], uri: res.fetch(:uri, nil) }.compact.with_indifferent_access
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
def all
|
16
16
|
terms.map do |res|
|
17
|
-
{ id: res[:id], label: res[:term], active: res.fetch(:active, true) }
|
17
|
+
{ id: res[:id], label: res[:term], active: res.fetch(:active, true), uri: res.fetch(:uri, nil) }
|
18
|
+
.compact.with_indifferent_access
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
data/lib/qa/version.rb
CHANGED
@@ -357,7 +357,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
357
357
|
context 'producing internal server error' do
|
358
358
|
context 'when server returns 500' do
|
359
359
|
before do
|
360
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 500)
|
360
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369.rdf.xml').to_return(status: 500)
|
361
361
|
end
|
362
362
|
it 'returns 500' do
|
363
363
|
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
|
@@ -369,7 +369,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
369
369
|
|
370
370
|
context 'when data normalization error' do
|
371
371
|
before do
|
372
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369')
|
372
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369.rdf.xml')
|
373
373
|
.to_return(status: 200, body: webmock_fixture('lod_oclc_term_bad_id.nt'), headers: { 'Content-Type' => 'application/ntriples' })
|
374
374
|
end
|
375
375
|
it 'returns 500' do
|
@@ -381,7 +381,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
381
381
|
|
382
382
|
context 'when rdf format error' do
|
383
383
|
before do
|
384
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 200)
|
384
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369.rdf.xml').to_return(status: 200)
|
385
385
|
allow(RDF::Graph).to receive(:load).and_raise(RDF::FormatError)
|
386
386
|
end
|
387
387
|
it 'returns 500' do
|
@@ -395,7 +395,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
395
395
|
|
396
396
|
context "when error isn't specifically handled" do
|
397
397
|
before do
|
398
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 501)
|
398
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369.rdf.xml').to_return(status: 501)
|
399
399
|
end
|
400
400
|
it 'returns 500' do
|
401
401
|
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
|
@@ -408,7 +408,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
408
408
|
|
409
409
|
context 'when service unavailable' do
|
410
410
|
before do
|
411
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 503)
|
411
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369.rdf.xml').to_return(status: 503)
|
412
412
|
end
|
413
413
|
it 'returns 503' do
|
414
414
|
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
|
@@ -420,7 +420,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
420
420
|
|
421
421
|
context 'when requested term is not found at the server' do
|
422
422
|
before do
|
423
|
-
stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID').to_return(status: 404, body: '', headers: {})
|
423
|
+
stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID.rdf.xml').to_return(status: 404, body: '', headers: {})
|
424
424
|
end
|
425
425
|
it 'returns 404' do
|
426
426
|
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
|
@@ -433,7 +433,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
433
433
|
context 'in OCLC_FAST authority' do
|
434
434
|
context 'term found' do
|
435
435
|
before do
|
436
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369')
|
436
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369.rdf.xml')
|
437
437
|
.to_return(status: 200, body: webmock_fixture('lod_oclc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
438
438
|
end
|
439
439
|
it 'succeeds and defaults to json content type' do
|
@@ -481,7 +481,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
481
481
|
context 'when cors headers are enabled' do
|
482
482
|
before do
|
483
483
|
Qa.config.enable_cors_headers
|
484
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369')
|
484
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369.rdf.xml')
|
485
485
|
.to_return(status: 200, body: webmock_fixture('lod_oclc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
486
486
|
end
|
487
487
|
it 'Access-Control-Allow-Origin is *' do
|
@@ -493,7 +493,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
493
493
|
context 'when cors headers are disabled' do
|
494
494
|
before do
|
495
495
|
Qa.config.disable_cors_headers
|
496
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369')
|
496
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369.rdf.xml')
|
497
497
|
.to_return(status: 200, body: webmock_fixture('lod_oclc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
498
498
|
end
|
499
499
|
it 'Access-Control-Allow-Origin is not present' do
|
@@ -82,7 +82,7 @@ describe Qa::TermsController, type: :controller do
|
|
82
82
|
|
83
83
|
context "loc" do
|
84
84
|
before do
|
85
|
-
stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:
|
85
|
+
stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names")
|
86
86
|
.with(headers: { 'Accept' => 'application/json' })
|
87
87
|
.to_return(body: webmock_fixture("loc-names-response.txt"), status: 200)
|
88
88
|
end
|
@@ -253,4 +253,33 @@ describe Qa::TermsController, type: :controller do
|
|
253
253
|
end
|
254
254
|
end
|
255
255
|
end
|
256
|
+
|
257
|
+
describe "#fetch" do
|
258
|
+
context "with supported authorities" do
|
259
|
+
it "returns an individual state term" do
|
260
|
+
get :fetch, params: { vocab: "local", subauthority: "authority_U", uri: "http://my.domain/terms/a2" }
|
261
|
+
expect(response).to be_successful
|
262
|
+
end
|
263
|
+
|
264
|
+
context 'when cors headers are enabled' do
|
265
|
+
before do
|
266
|
+
Qa.config.enable_cors_headers
|
267
|
+
end
|
268
|
+
it 'Access-Control-Allow-Origin is *' do
|
269
|
+
get :fetch, params: { vocab: "local", subauthority: "authority_U", uri: "http://my.domain/terms/a2" }
|
270
|
+
expect(response.headers['Access-Control-Allow-Origin']).to eq '*'
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
context 'when cors headers are disabled' do
|
275
|
+
before do
|
276
|
+
Qa.config.disable_cors_headers
|
277
|
+
end
|
278
|
+
it 'Access-Control-Allow-Origin is not present' do
|
279
|
+
get :fetch, params: { vocab: "local", subauthority: "authority_U", uri: "http://my.domain/terms/a2" }
|
280
|
+
expect(response.headers.key?('Access-Control-Allow-Origin')).to be false
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
256
285
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
:terms:
|
2
|
+
- :id: A1
|
3
|
+
:term: Abc Term A1
|
4
|
+
:uri: http://my.domain/terms/a1
|
5
|
+
:active: true
|
6
|
+
- :id: A2
|
7
|
+
:term: Term A2
|
8
|
+
:uri: http://my.domain/terms/a2
|
9
|
+
:active: false
|
10
|
+
- :id: A3
|
11
|
+
:term: Abc Term A3
|
12
|
+
:uri: http://my.domain/terms/a3
|
13
|
+
:active: true
|
@@ -8,18 +8,18 @@ RSpec.describe Qa::Authorities::LinkedData::FindTerm do
|
|
8
8
|
context 'basic parameter testing' do
|
9
9
|
context 'with bad id' do
|
10
10
|
before do
|
11
|
-
stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID')
|
11
|
+
stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID.rdf.xml')
|
12
12
|
.to_return(status: 404, body: '', headers: {})
|
13
13
|
end
|
14
14
|
it 'raises a TermNotFound exception' do
|
15
|
-
expect { lod_oclc.find('FAKE_ID') }.to raise_error Qa::TermNotFound, /.*\/FAKE_ID\ Not Found - Term may not exist at LOD Authority./
|
15
|
+
expect { lod_oclc.find('FAKE_ID') }.to raise_error Qa::TermNotFound, /.*\/FAKE_ID.rdf.xml\ Not Found - Term may not exist at LOD Authority./
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'performance stats' do
|
21
21
|
before do
|
22
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369')
|
22
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369.rdf.xml')
|
23
23
|
.to_return(status: 200, body: webmock_fixture('lod_oclc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
24
24
|
end
|
25
25
|
context 'when set to true' do
|
@@ -55,7 +55,7 @@ RSpec.describe Qa::Authorities::LinkedData::FindTerm do
|
|
55
55
|
|
56
56
|
context 'response header' do
|
57
57
|
before do
|
58
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369')
|
58
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369.rdf.xml')
|
59
59
|
.to_return(status: 200, body: webmock_fixture('lod_oclc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
60
60
|
end
|
61
61
|
context 'when set to true' do
|
@@ -91,7 +91,7 @@ RSpec.describe Qa::Authorities::LinkedData::FindTerm do
|
|
91
91
|
context 'in OCLC_FAST authority' do
|
92
92
|
context 'term found' do
|
93
93
|
let :results do
|
94
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369')
|
94
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369.rdf.xml')
|
95
95
|
.to_return(status: 200, body: webmock_fixture('lod_oclc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
96
96
|
lod_oclc.find('530369')
|
97
97
|
end
|
@@ -128,7 +128,7 @@ RSpec.describe Qa::Authorities::LinkedData::FindTerm do
|
|
128
128
|
|
129
129
|
context "ID in graph doesn't match ID in request URI" do
|
130
130
|
before do
|
131
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369')
|
131
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369.rdf.xml')
|
132
132
|
.to_return(status: 200, body: webmock_fixture('lod_oclc_term_bad_id.nt'), headers: { 'Content-Type' => 'application/ntriples' })
|
133
133
|
end
|
134
134
|
|
@@ -28,7 +28,7 @@ describe Qa::Authorities::Loc do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
context "for searching" do
|
31
|
-
let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%
|
31
|
+
let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
|
32
32
|
it "returns a url" do
|
33
33
|
expect(authority.build_query_url("foo")).to eq(url)
|
34
34
|
end
|
@@ -49,15 +49,15 @@ describe Qa::Authorities::Loc do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
before do
|
52
|
-
stub_request(:get, "https://id.loc.gov/search/?format=json&q=cs:
|
52
|
+
stub_request(:get, "https://id.loc.gov/search/?format=json&q=cs:http://id.loc.gov/authorities/subjects")
|
53
53
|
.with(headers: { 'Accept' => 'application/json' })
|
54
54
|
.to_return(status: 200, body: "")
|
55
55
|
end
|
56
56
|
|
57
57
|
context "with flat params encoded" do
|
58
|
-
let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%
|
58
|
+
let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
|
59
59
|
it "returns a response" do
|
60
|
-
flat_params_url = "https://id.loc.gov/search/?format=json&q=foo&q=cs%
|
60
|
+
flat_params_url = "https://id.loc.gov/search/?format=json&q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects"
|
61
61
|
expect(subject.env.url.to_s).to eq(flat_params_url)
|
62
62
|
end
|
63
63
|
end
|
@@ -66,7 +66,7 @@ describe Qa::Authorities::Loc do
|
|
66
66
|
describe "#search" do
|
67
67
|
context "any LOC authorities" do
|
68
68
|
let :authority do
|
69
|
-
stub_request(:get, "https://id.loc.gov/search/?format=json&q=s&q=cs:
|
69
|
+
stub_request(:get, "https://id.loc.gov/search/?format=json&q=s&q=cs:http://id.loc.gov/vocabulary/geographicAreas")
|
70
70
|
.with(headers: { 'Accept' => 'application/json' })
|
71
71
|
.to_return(body: webmock_fixture("loc-response.txt"), status: 200)
|
72
72
|
described_class.subauthority_for("geographicAreas")
|
@@ -95,7 +95,7 @@ describe Qa::Authorities::Loc do
|
|
95
95
|
|
96
96
|
context "subject terms" do
|
97
97
|
let :results do
|
98
|
-
stub_request(:get, "https://id.loc.gov/search/?format=json&q=History--&q=cs:
|
98
|
+
stub_request(:get, "https://id.loc.gov/search/?format=json&q=History--&q=cs:http://id.loc.gov/authorities/subjects")
|
99
99
|
.with(headers: { 'Accept' => 'application/json' })
|
100
100
|
.to_return(body: webmock_fixture("loc-subjects-response.txt"), status: 200)
|
101
101
|
described_class.subauthority_for("subjects").search("History--")
|
@@ -111,7 +111,7 @@ describe Qa::Authorities::Loc do
|
|
111
111
|
|
112
112
|
context "name terms" do
|
113
113
|
let :results do
|
114
|
-
stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:
|
114
|
+
stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names")
|
115
115
|
.with(headers: { 'Accept' => 'application/json' })
|
116
116
|
.to_return(body: webmock_fixture("loc-names-response.txt"), status: 200)
|
117
117
|
described_class.subauthority_for("names").search("Berry")
|
data/spec/lib/authorities/{file_based_authority_spec.rb → local/file_based_authority_spec.rb}
RENAMED
@@ -5,6 +5,7 @@ describe Qa::Authorities::Local::FileBasedAuthority do
|
|
5
5
|
let(:authority_b) { Qa::Authorities::Local.subauthority_for("authority_B") }
|
6
6
|
let(:authority_c) { Qa::Authorities::Local.subauthority_for("authority_C") }
|
7
7
|
let(:authority_d) { Qa::Authorities::Local.subauthority_for("authority_D") }
|
8
|
+
let(:authority_u) { Qa::Authorities::Local.subauthority_for("authority_U") }
|
8
9
|
|
9
10
|
describe "#all" do
|
10
11
|
let(:expected) do
|
@@ -35,6 +36,16 @@ describe Qa::Authorities::Local::FileBasedAuthority do
|
|
35
36
|
expect(authority_c.all).to eq(expected)
|
36
37
|
end
|
37
38
|
end
|
39
|
+
context "when terms have uris" do
|
40
|
+
let(:expected) do
|
41
|
+
[{ 'id' => "A1", 'label' => "Abc Term A1", 'active' => true, 'uri' => 'http://my.domain/terms/a1' },
|
42
|
+
{ 'id' => "A2", 'label' => "Term A2", 'active' => false, 'uri' => 'http://my.domain/terms/a2' },
|
43
|
+
{ 'id' => "A3", 'label' => "Abc Term A3", 'active' => true, 'uri' => 'http://my.domain/terms/a3' }]
|
44
|
+
end
|
45
|
+
it "sets the id to be same as the label" do
|
46
|
+
expect(authority_u.all).to eq(expected)
|
47
|
+
end
|
48
|
+
end
|
38
49
|
context "YAML file is malformed" do
|
39
50
|
it "raises an error" do
|
40
51
|
expect { authority_d.all }.to raise_error Psych::SyntaxError
|
File without changes
|
data/spec/lib/authorities/{table_based_authority_spec.rb → local/table_based_authority_spec.rb}
RENAMED
File without changes
|
@@ -33,7 +33,9 @@ describe Qa::Authorities::Local do
|
|
33
33
|
|
34
34
|
describe "#names" do
|
35
35
|
it "returns a list of yaml files" do
|
36
|
-
expect(described_class.names)
|
36
|
+
expect(described_class.names)
|
37
|
+
.to include("authority_A", "authority_B", "authority_C",
|
38
|
+
"authority_D", "authority_U", "states")
|
37
39
|
end
|
38
40
|
|
39
41
|
context "when the path doesn't exist" do
|
@@ -83,16 +83,22 @@ RSpec.describe Qa::LinkedData::AuthorityUrlService do
|
|
83
83
|
let(:action_request) { 'mark twain' }
|
84
84
|
|
85
85
|
it 'returns template with substitutions' do
|
86
|
-
expected_url = 'http://experimental.worldcat.org/fast/search?query=oclc.personalName+all+%22mark
|
86
|
+
expected_url = 'http://experimental.worldcat.org/fast/search?query=oclc.personalName+all+%22mark%20twain%22&sortKeys=usage&maximumRecords=10'
|
87
87
|
expect(subject).to eq expected_url
|
88
88
|
end
|
89
|
+
|
90
|
+
it 'does not mutate substitutions hash' do
|
91
|
+
before_substitutions = substitutions.clone
|
92
|
+
subject
|
93
|
+
expect(substitutions).to eq before_substitutions
|
94
|
+
end
|
89
95
|
end
|
90
96
|
|
91
97
|
context 'when no substitutions specified' do
|
92
98
|
let(:action_request) { 'mark twain' }
|
93
99
|
|
94
100
|
it 'returns template with substitutions' do
|
95
|
-
expected_url = 'http://experimental.worldcat.org/fast/search?query=cql.any+all+%22mark
|
101
|
+
expected_url = 'http://experimental.worldcat.org/fast/search?query=cql.any+all+%22mark%20twain%22&sortKeys=usage&maximumRecords=20'
|
96
102
|
expect(subject).to eq expected_url
|
97
103
|
end
|
98
104
|
end
|
@@ -104,7 +110,7 @@ RSpec.describe Qa::LinkedData::AuthorityUrlService do
|
|
104
110
|
let(:action_request) { 'n79021164' }
|
105
111
|
|
106
112
|
it 'returns template with substitutions' do
|
107
|
-
expected_url = 'http://id.worldcat.org/fast/n79021164'
|
113
|
+
expected_url = 'http://id.worldcat.org/fast/n79021164.rdf.xml'
|
108
114
|
expect(subject).to eq expected_url
|
109
115
|
end
|
110
116
|
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: 5.
|
4
|
+
version: 5.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Anderson
|
@@ -16,7 +16,7 @@ authors:
|
|
16
16
|
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
|
-
date:
|
19
|
+
date: 2021-11-04 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activerecord-import
|
@@ -111,7 +111,7 @@ dependencies:
|
|
111
111
|
version: '5.0'
|
112
112
|
- - "<"
|
113
113
|
- !ruby/object:Gem::Version
|
114
|
-
version: '6.
|
114
|
+
version: '6.2'
|
115
115
|
type: :runtime
|
116
116
|
prerelease: false
|
117
117
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -121,7 +121,7 @@ dependencies:
|
|
121
121
|
version: '5.0'
|
122
122
|
- - "<"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '6.
|
124
|
+
version: '6.2'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rdf
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -479,6 +479,7 @@ files:
|
|
479
479
|
- spec/fixtures/authorities/authority_B.yml
|
480
480
|
- spec/fixtures/authorities/authority_C.yml
|
481
481
|
- spec/fixtures/authorities/authority_D.yml
|
482
|
+
- spec/fixtures/authorities/authority_U.yml
|
482
483
|
- spec/fixtures/authorities/linked_data/lod_encoding_config.json
|
483
484
|
- spec/fixtures/authorities/linked_data/lod_full_config.json
|
484
485
|
- spec/fixtures/authorities/linked_data/lod_full_config_1_0.json
|
@@ -559,7 +560,6 @@ files:
|
|
559
560
|
- spec/lib/authorities/crossref_spec.rb
|
560
561
|
- spec/lib/authorities/discogs/generic_authority_spec.rb
|
561
562
|
- spec/lib/authorities/discogs_spec.rb
|
562
|
-
- spec/lib/authorities/file_based_authority_spec.rb
|
563
563
|
- spec/lib/authorities/geonames_spec.rb
|
564
564
|
- spec/lib/authorities/getty/aat_spec.rb
|
565
565
|
- spec/lib/authorities/getty/tgn_spec.rb
|
@@ -572,12 +572,13 @@ files:
|
|
572
572
|
- spec/lib/authorities/linked_data/search_query_spec.rb
|
573
573
|
- spec/lib/authorities/linked_data/term_config_spec.rb
|
574
574
|
- spec/lib/authorities/loc_spec.rb
|
575
|
+
- spec/lib/authorities/local/file_based_authority_spec.rb
|
576
|
+
- spec/lib/authorities/local/mysql_table_based_authority_spec.rb
|
577
|
+
- spec/lib/authorities/local/table_based_authority_spec.rb
|
575
578
|
- spec/lib/authorities/local_spec.rb
|
576
579
|
- spec/lib/authorities/mesh_spec.rb
|
577
|
-
- spec/lib/authorities/mysql_table_based_authority_spec.rb
|
578
580
|
- spec/lib/authorities/oclcts_spec.rb
|
579
581
|
- spec/lib/authorities/space_fix_encoder.rb
|
580
|
-
- spec/lib/authorities/table_based_authority_spec.rb
|
581
582
|
- spec/lib/authorities/tgnlang_spec.rb
|
582
583
|
- spec/lib/authorities_loc_subauthorities.rb
|
583
584
|
- spec/lib/configuration_spec.rb
|
@@ -662,16 +663,16 @@ test_files:
|
|
662
663
|
- spec/lib/authorities/tgnlang_spec.rb
|
663
664
|
- spec/lib/authorities/crossref_spec.rb
|
664
665
|
- spec/lib/authorities/oclcts_spec.rb
|
665
|
-
- spec/lib/authorities/file_based_authority_spec.rb
|
666
|
+
- spec/lib/authorities/local/file_based_authority_spec.rb
|
667
|
+
- spec/lib/authorities/local/table_based_authority_spec.rb
|
668
|
+
- spec/lib/authorities/local/mysql_table_based_authority_spec.rb
|
666
669
|
- spec/lib/authorities/space_fix_encoder.rb
|
667
670
|
- spec/lib/authorities/assign_fast_spec.rb
|
668
|
-
- spec/lib/authorities/table_based_authority_spec.rb
|
669
671
|
- spec/lib/authorities/getty/tgn_spec.rb
|
670
672
|
- spec/lib/authorities/getty/ulan_spec.rb
|
671
673
|
- spec/lib/authorities/getty/aat_spec.rb
|
672
674
|
- spec/lib/authorities/discogs_spec.rb
|
673
675
|
- spec/lib/authorities/mesh_spec.rb
|
674
|
-
- spec/lib/authorities/mysql_table_based_authority_spec.rb
|
675
676
|
- spec/lib/authorities/local_spec.rb
|
676
677
|
- spec/lib/authorities/discogs/generic_authority_spec.rb
|
677
678
|
- spec/lib/authorities/geonames_spec.rb
|
@@ -750,6 +751,7 @@ test_files:
|
|
750
751
|
- spec/fixtures/authorities/authority_D.yml
|
751
752
|
- spec/fixtures/authorities/authority_A.yml
|
752
753
|
- spec/fixtures/authorities/authority_C.yml
|
754
|
+
- spec/fixtures/authorities/authority_U.yml
|
753
755
|
- spec/fixtures/authorities/authority_B.yml
|
754
756
|
- spec/fixtures/geonames-response.json
|
755
757
|
- spec/fixtures/tgn-response.txt
|