qa 5.6.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/config/routes.rb +4 -0
- data/lib/qa/authorities/local/file_based_authority.rb +3 -2
- data/lib/qa/version.rb +1 -1
- data/spec/controllers/terms_controller_spec.rb +29 -0
- data/spec/fixtures/authorities/authority_U.yml +13 -0
- 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
- metadata +10 -8
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"
|
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
|
@@ -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
@@ -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
|
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
|
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: 2021-
|
19
|
+
date: 2021-11-04 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activerecord-import
|
@@ -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
|