qa 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 571cac6a8c4ec9ddf8a61a7d54ea857481af0a1c
4
- data.tar.gz: e33cead405236f73a1dc443ee11c48a132f64b30
3
+ metadata.gz: cd95864495b3db88e02bf7a8261cfc53387c8db2
4
+ data.tar.gz: a5c462c41d39c58650be960dee85708952ad1cf5
5
5
  SHA512:
6
- metadata.gz: ccd4534d37546bbfc12514de7ba0058668fc1f380d6eab4a9889c45d34ea035df73dc6e2977a14ae273d215c24ff02b6228e82593aa8c51f3a5bb333e6112f28
7
- data.tar.gz: af6074497e2bfeafdf3f9c9fd71d13e45c7917889084d241174059d5e3062697589286edb4f6260603414ec0d22d771683695d91e26a8b390d03bfbbd21dbce5
6
+ metadata.gz: 7769289d6084b3211ae2dbf68a2b0978baed528e61c7e9fd288016bdee6d5915e315d8637ac7f38ed9eab90308f926afa5d569c1615d014f8d3bb898fe390730
7
+ data.tar.gz: 8694569bddcaccf386e6c2ae1b14cd6ca63703f945034533bbc1a4d7a48c60729790d428998cb257f174254ac8f0956f8b13af52136c7d0dd5ead5c52cb27d65
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Questioning Authority
2
2
 
3
- [![Build Status](https://travis-ci.org/projecthydra/questioning_authority.png?branch=master)](https://travis-ci.org/projecthydra/questioning_authority) [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa)
4
- [![Coverage Status](https://coveralls.io/repos/github/projecthydra/questioning_authority/badge.svg?branch=master)](https://coveralls.io/github/projecthydra/questioning_authority?branch=master)
3
+ [![Build Status](https://travis-ci.org/samvera/questioning_authority.png?branch=master)](https://travis-ci.org/samvera/questioning_authority) [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa)
4
+ [![Coverage Status](https://coveralls.io/repos/github/samvera/questioning_authority/badge.svg?branch=master)](https://coveralls.io/github/samvera/questioning_authority?branch=master)
5
5
 
6
6
  You should question your authorities.
7
7
 
@@ -387,7 +387,7 @@ gem 'rdf-rdfxml'
387
387
 
388
388
  Access to LOD authorities can be configured. Currently, a configuration exists in QA for OCLC Fast Linked Data, Library of
389
389
  Congress (terms only), and Agrovoc. Look for configuration files in
390
- [/config/authorities/linked_data](https://github.com/projecthydra/questioning_authority/tree/master/config/authorities/linked_data).
390
+ [/config/authorities/linked_data](https://github.com/samvera/questioning_authority/tree/master/config/authorities/linked_data).
391
391
 
392
392
  Example configuration...
393
393
 
@@ -611,7 +611,7 @@ NOTE: All predicates with the URI as the subject will be included under "predica
611
611
 
612
612
  #### Add javascript to support autocomplete
613
613
 
614
- See [Using with autocomplete in Sufia](https://github.com/projecthydra/questioning_authority/wiki/Using-with-autocomplete-in-Sufia) in the wiki documentation for QA.
614
+ See [Using with autocomplete in Sufia](https://github.com/samvera/questioning_authority/wiki/Using-with-autocomplete-in-Sufia) in the wiki documentation for QA.
615
615
 
616
616
 
617
617
 
@@ -19,11 +19,15 @@ class Qa::LinkedDataTermsController < ApplicationController
19
19
  terms = @authority.search(query, subauth: subauthority, language: language, replacements: replacement_params)
20
20
  rescue Qa::ServiceUnavailable
21
21
  logger.warn "Service Unavailable - Search query #{query} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
22
- head :not_found
22
+ head :service_unavailable
23
+ return
24
+ rescue Qa::ServiceError
25
+ logger.warn "Internal Server Error - Search query #{query} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
26
+ head :internal_server_error
23
27
  return
24
28
  rescue RDF::FormatError
25
29
  logger.warn "RDF Format Error - Results from search query #{query} for#{subauth_warn_msg} authority #{vocab_param} was not identified as a valid RDF format. You may need to include the linkeddata gem."
26
- head :not_found
30
+ head :internal_server_error
27
31
  return
28
32
  end
29
33
  render json: terms
@@ -40,11 +44,15 @@ class Qa::LinkedDataTermsController < ApplicationController
40
44
  return
41
45
  rescue Qa::ServiceUnavailable
42
46
  logger.warn "Service Unavailable - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
43
- head :not_found
47
+ head :service_unavailable
48
+ return
49
+ rescue Qa::ServiceError
50
+ logger.warn "Internal Server Error - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
51
+ head :internal_server_error
44
52
  return
45
53
  rescue RDF::FormatError
46
54
  logger.warn "RDF Format Error - Results from fetch term #{id} for#{subauth_warn_msg} authority #{vocab_param} was not identified as a valid RDF format. You may need to include the linkeddata gem."
47
- head :not_found
55
+ head :internal_server_error
48
56
  return
49
57
  end
50
58
  render json: term
@@ -55,7 +63,7 @@ class Qa::LinkedDataTermsController < ApplicationController
55
63
  def check_authority
56
64
  if params[:vocab].nil? || !params[:vocab].size.positive?
57
65
  logger.warn "Required param 'vocab' is missing or empty"
58
- head :not_found
66
+ head :bad_request
59
67
  end
60
68
  end
61
69
 
@@ -63,7 +71,7 @@ class Qa::LinkedDataTermsController < ApplicationController
63
71
  return if subauthority.nil?
64
72
  unless @authority.search_subauthority?(subauthority)
65
73
  logger.warn "Unable to initialize linked data search sub-authority '#{subauthority}' for authority '#{vocab_param}'"
66
- head :not_found
74
+ head :bad_request
67
75
  end
68
76
  end
69
77
 
@@ -71,7 +79,7 @@ class Qa::LinkedDataTermsController < ApplicationController
71
79
  return if subauthority.nil?
72
80
  unless @authority.term_subauthority?(subauthority)
73
81
  logger.warn "Unable to initialize linked data term sub-authority '#{subauthority}' for authority '#{vocab_param}'"
74
- head :not_found
82
+ head :bad_request
75
83
  end
76
84
  end
77
85
 
@@ -79,7 +87,7 @@ class Qa::LinkedDataTermsController < ApplicationController
79
87
  @authority = Qa::Authorities::LinkedData::GenericAuthority.new(vocab_param)
80
88
  rescue Qa::InvalidLinkedDataAuthority => e
81
89
  logger.warn e.message
82
- head :not_found
90
+ head :bad_request
83
91
  end
84
92
 
85
93
  def vocab_param
@@ -89,7 +97,7 @@ class Qa::LinkedDataTermsController < ApplicationController
89
97
  def check_query_param
90
98
  if params[:q].nil? || !params[:q].size.positive?
91
99
  logger.warn "Required search param 'q' is missing or empty"
92
- head :not_found
100
+ head :bad_request
93
101
  end
94
102
  end
95
103
 
@@ -101,7 +109,7 @@ class Qa::LinkedDataTermsController < ApplicationController
101
109
  def check_id_param
102
110
  if params[:id].nil? || !params[:id].size.positive?
103
111
  logger.warn "Required show param 'id' is missing or empty"
104
- head :not_found
112
+ head :bad_request
105
113
  end
106
114
  end
107
115
 
@@ -3,7 +3,7 @@
3
3
  "url": {
4
4
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
5
5
  "@type": "IriTemplate",
6
- "template": "http://aims.fao.org/skosmos/rest/v1/data?uri=http://aims.fao.org/aos/agrovoc/{?term_id}",
6
+ "template": "http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/data?uri=http://aims.fao.org/aos/agrovoc/{?term_id}",
7
7
  "variableRepresentation": "BasicRepresentation",
8
8
  "mapping": [
9
9
  {
@@ -31,7 +31,7 @@
31
31
  "url": {
32
32
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
33
33
  "@type": "IriTemplate",
34
- "template": "http://aims.fao.org/skosmos/rest/v1/search/?query=*{?query}*&lang={?lang}",
34
+ "template": "http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?query=*{?query}*&lang={?lang}",
35
35
  "variableRepresentation": "BasicRepresentation",
36
36
  "mapping": [
37
37
  {
data/lib/qa.rb CHANGED
@@ -26,9 +26,12 @@ module Qa
26
26
  # Raised when a configuration parameter is incorrect or is required and missing
27
27
  class InvalidConfiguration < ArgumentError; end
28
28
 
29
- # Raised when a linked data request to a server returns a 500 error
29
+ # Raised when a linked data request to a server returns a 503 error
30
30
  class ServiceUnavailable < ArgumentError; end
31
31
 
32
+ # Raised when a linked data request to a server returns a 500 error
33
+ class ServiceError < ArgumentError; end
34
+
32
35
  # Raised when the server returns 404 for a find term request
33
36
  class TermNotFound < ArgumentError; end
34
37
  end
@@ -35,18 +35,17 @@ module Qa::Authorities
35
35
 
36
36
  def process_error(e, url)
37
37
  uri = URI(url)
38
+ raise RDF::FormatError, "Unknown RDF format of results returned by #{uri}. (RDF::FormatError) You may need to include gem 'linkeddata'." if e.is_a? RDF::FormatError
38
39
  response_code = ioerror_code(e)
39
40
  case response_code
40
- when 'format'
41
- raise RDF::FormatError, "Unknown RDF format of results returned by #{uri}. (RDF::FormatError) You may need to include gem 'linkeddata'."
42
41
  when '404'
43
42
  raise Qa::TermNotFound, "#{uri} Not Found - Term may not exist at LOD Authority. (HTTPNotFound - 404)"
44
43
  when '500'
45
- raise Qa::ServiceUnavailable, "#{uri.hostname} on port #{uri.port} is not responding. Try again later. (HTTPServerError - 500)"
44
+ raise Qa::ServiceError, "#{uri.hostname} on port #{uri.port} is not responding. Try again later. (HTTPServerError - 500)"
46
45
  when '503'
47
46
  raise Qa::ServiceUnavailable, "#{uri.hostname} on port #{uri.port} is not responding. Try again later. (HTTPServiceUnavailable - 503)"
48
47
  else
49
- raise Qa::ServiceUnavailable, "Unknown error for #{uri.hostname} on port #{uri.port}. Try again later. (Cause - #{e.message})"
48
+ raise Qa::ServiceError, "Unknown error for #{uri.hostname} on port #{uri.port}. Try again later. (Cause - #{e.message})"
50
49
  end
51
50
  end
52
51
 
@@ -14,7 +14,7 @@ module Qa::Authorities
14
14
 
15
15
  def all
16
16
  terms.map do |res|
17
- { id: res[:id], label: res[:term] }.with_indifferent_access
17
+ { id: res[:id], label: res[:term], active: res.fetch(:active, true) }.with_indifferent_access
18
18
  end
19
19
  end
20
20
 
@@ -1,3 +1,3 @@
1
1
  module Qa
2
- VERSION = "1.1.0".freeze
2
+ VERSION = "1.2.0".freeze
3
3
  end
@@ -6,72 +6,122 @@ describe Qa::LinkedDataTermsController, type: :controller do
6
6
  end
7
7
 
8
8
  describe '#check_authority' do
9
- it 'returns 404 if the vocabulary is not specified' do
9
+ it 'returns 400 if the vocabulary is not specified' do
10
10
  expect(Rails.logger).to receive(:warn).with("Required param 'vocab' is missing or empty")
11
11
  get :search, params: { q: 'a query', vocab: '' }
12
- expect(response.code).to eq('404')
12
+ expect(response.code).to eq('400')
13
13
  end
14
14
 
15
- it 'returns 404 if the vocabulary is not specified' do
15
+ it 'returns 400 if the vocabulary is not specified' do
16
16
  expect(Rails.logger).to receive(:warn).with("Required param 'vocab' is missing or empty")
17
17
  get :show, params: { id: 'C_1234', vocab: '' }
18
- expect(response.code).to eq('404')
18
+ expect(response.code).to eq('400')
19
19
  end
20
20
  end
21
21
 
22
22
  describe '#check_search_subauthority' do
23
- it 'returns 404 if the query subauthority is missing' do
23
+ it 'returns 400 if the query subauthority is missing' do
24
24
  expect(Rails.logger).to receive(:warn).with("Unable to initialize linked data search sub-authority '' for authority 'OCLC_FAST'")
25
25
  get :search, params: { q: 'test', vocab: 'OCLC_FAST', subauthority: '' }
26
- expect(response.code).to eq('404')
26
+ expect(response.code).to eq('400')
27
27
  end
28
- it 'returns 404 if the query subauthority is invalid' do
28
+ it 'returns 400 if the query subauthority is invalid' do
29
29
  expect(Rails.logger).to receive(:warn).with("Unable to initialize linked data search sub-authority 'FAKE_SUBAUTHORITY' for authority 'OCLC_FAST'")
30
30
  get :search, params: { vocab: 'OCLC_FAST', subauthority: 'FAKE_SUBAUTHORITY' }
31
- expect(response.code).to eq('404')
31
+ expect(response.code).to eq('400')
32
32
  end
33
33
  end
34
34
 
35
35
  describe '#check_show_subauthority' do
36
- it 'returns 404 if the show subauthority is missing' do
36
+ it 'returns 400 if the show subauthority is missing' do
37
37
  expect(Rails.logger).to receive(:warn).with("Unable to initialize linked data term sub-authority '' for authority 'OCLC_FAST'")
38
38
  get :show, params: { id: 'C_123', vocab: 'OCLC_FAST', subauthority: '' }
39
- expect(response.code).to eq('404')
39
+ expect(response.code).to eq('400')
40
40
  end
41
- it 'returns 404 if the show subauthority is invalid' do
41
+ it 'returns 400 if the show subauthority is invalid' do
42
42
  expect(Rails.logger).to receive(:warn).with("Unable to initialize linked data term sub-authority 'FAKE_SUBAUTHORITY' for authority 'OCLC_FAST'")
43
43
  get :show, params: { id: 'C_123', vocab: 'OCLC_FAST', subauthority: 'FAKE_SUBAUTHORITY' }
44
- expect(response.code).to eq('404')
44
+ expect(response.code).to eq('400')
45
45
  end
46
46
  end
47
47
 
48
48
  describe '#check_query_param' do
49
- it 'returns 404 if the query is missing' do
49
+ it 'returns 400 if the query is missing' do
50
50
  expect(Rails.logger).to receive(:warn).with("Required search param 'q' is missing or empty")
51
51
  get :search, params: { vocab: 'OCLC_FAST' }
52
- expect(response.code).to eq('404')
52
+ expect(response.code).to eq('400')
53
53
  end
54
54
  end
55
55
 
56
56
  describe '#check_id_param' do
57
- it 'returns 404 if the id is missing' do
57
+ it 'returns 400 if the id is missing' do
58
58
  expect(Rails.logger).to receive(:warn).with("Required show param 'id' is missing or empty")
59
59
  get :show, params: { id: '', vocab: 'OCLC_FAST' }
60
- expect(response.code).to eq('404')
60
+ expect(response.code).to eq('400')
61
61
  end
62
62
  end
63
63
 
64
64
  describe '#init_authority' do
65
65
  context 'when the authority does not exist' do
66
- it 'returns 404' do
66
+ it 'returns 400' do
67
67
  expect(Rails.logger).to receive(:warn).with("Unable to initialize linked data authority 'FAKE_AUTHORITY'")
68
68
  get :search, params: { q: 'a query', vocab: 'fake_authority' }
69
- expect(response.code).to eq('404')
69
+ expect(response.code).to eq('400')
70
70
  end
71
71
  end
72
72
  end
73
73
 
74
74
  describe '#search' do
75
+ context 'producing internal server error' do
76
+ context 'when server returns 500' do
77
+ before do
78
+ stub_request(:get, 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=cql.any%20all%20%22my_query%22&sortKeys=usage')
79
+ .to_return(status: 500)
80
+ end
81
+ it 'returns 500' do
82
+ expect(Rails.logger).to receive(:warn).with("Internal Server Error - Search query my_query unsuccessful for authority OCLC_FAST")
83
+ get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
84
+ expect(response.code).to eq('500')
85
+ end
86
+ end
87
+
88
+ context 'when rdf format error' do
89
+ before do
90
+ stub_request(:get, 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=cql.any%20all%20%22my_query%22&sortKeys=usage')
91
+ .to_return(status: 200)
92
+ allow(RDF::Graph).to receive(:load).and_raise(RDF::FormatError)
93
+ end
94
+ it 'returns 500' do
95
+ expect(Rails.logger).to receive(:warn).with("RDF Format Error - Results from search query my_query for authority OCLC_FAST was not identified as a valid RDF format. You may need to include the linkeddata gem.")
96
+ get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
97
+ expect(response.code).to eq('500')
98
+ end
99
+ end
100
+
101
+ context "when error isn't specifically handled" do
102
+ before do
103
+ stub_request(:get, 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=cql.any%20all%20%22my_query%22&sortKeys=usage')
104
+ .to_return(status: 501)
105
+ end
106
+ it 'returns 500' do
107
+ expect(Rails.logger).to receive(:warn).with("Internal Server Error - Search query my_query unsuccessful for authority OCLC_FAST")
108
+ get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
109
+ expect(response.code).to eq('500')
110
+ end
111
+ end
112
+ end
113
+
114
+ context 'when service unavailable' do
115
+ before do
116
+ stub_request(:get, 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=cql.any%20all%20%22my_query%22&sortKeys=usage')
117
+ .to_return(status: 503)
118
+ end
119
+ it 'returns 503' do
120
+ expect(Rails.logger).to receive(:warn).with("Service Unavailable - Search query my_query unsuccessful for authority OCLC_FAST")
121
+ get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
122
+ expect(response.code).to eq('503')
123
+ end
124
+ end
75
125
  context 'in OCLC_FAST authority' do
76
126
  context '0 search results' do
77
127
  before do
@@ -123,7 +173,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
123
173
  context 'in AGROVOC authority' do
124
174
  context '0 search results' do
125
175
  before do
126
- stub_request(:get, 'http://aims.fao.org/skosmos/rest/v1/search/?lang=en&query=*supercalifragilisticexpialidocious*')
176
+ stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?lang=en&query=*supercalifragilisticexpialidocious*')
127
177
  .to_return(status: 200, body: webmock_fixture('lod_agrovoc_query_no_results.json'), headers: { 'Content-Type' => 'application/json' })
128
178
  end
129
179
  it 'succeeds' do
@@ -134,7 +184,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
134
184
 
135
185
  context '3 search results' do
136
186
  before do
137
- stub_request(:get, 'http://aims.fao.org/skosmos/rest/v1/search/?lang=en&query=*milk*')
187
+ stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?lang=en&query=*milk*')
138
188
  .to_return(status: 200, body: webmock_fixture('lod_agrovoc_query_many_results.json'), headers: { 'Content-Type' => 'application/json' })
139
189
  end
140
190
  it 'succeeds' do
@@ -146,20 +196,64 @@ describe Qa::LinkedDataTermsController, type: :controller do
146
196
  end
147
197
 
148
198
  describe '#show' do
149
- context 'basic parameter testing' do
150
- context 'with bad id' do
199
+ context 'producing internal server error' do
200
+ context 'when server returns 500' do
201
+ before do
202
+ stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 500)
203
+ end
204
+ it 'returns 500' do
205
+ expect(Rails.logger).to receive(:warn).with("Internal Server Error - Fetch term 530369 unsuccessful for authority OCLC_FAST")
206
+ get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
207
+ expect(response.code).to eq('500')
208
+ end
209
+ end
210
+
211
+ context 'when rdf format error' do
212
+ before do
213
+ stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 200)
214
+ allow(RDF::Graph).to receive(:load).and_raise(RDF::FormatError)
215
+ end
216
+ it 'returns 500' do
217
+ expect(Rails.logger).to receive(:warn).with("RDF Format Error - Results from fetch term 530369 for authority OCLC_FAST was not identified as a valid RDF format. You may need to include the linkeddata gem.")
218
+ get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
219
+ expect(response.code).to eq('500')
220
+ end
221
+ end
222
+
223
+ context "when error isn't specifically handled" do
151
224
  before do
152
- stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID')
153
- .to_return(status: 404, body: '', headers: {})
225
+ stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 501)
154
226
  end
155
- it 'returns 404' do
156
- expect(Rails.logger).to receive(:warn).with('Term Not Found - Fetch term FAKE_ID unsuccessful for authority OCLC_FAST')
157
- get :show, params: { id: 'FAKE_ID', vocab: 'OCLC_FAST' }
158
- expect(response.code).to eq('404')
227
+ it 'returns 500' do
228
+ expect(Rails.logger).to receive(:warn).with("Internal Server Error - Fetch term 530369 unsuccessful for authority OCLC_FAST")
229
+ get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
230
+ expect(response.code).to eq('500')
159
231
  end
160
232
  end
161
233
  end
162
234
 
235
+ context 'when service unavailable' do
236
+ before do
237
+ stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 503)
238
+ end
239
+ it 'returns 503' do
240
+ expect(Rails.logger).to receive(:warn).with("Service Unavailable - Fetch term 530369 unsuccessful for authority OCLC_FAST")
241
+ get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
242
+ expect(response.code).to eq('503')
243
+ end
244
+ end
245
+
246
+ context 'when requested term is not found at the server' do
247
+ before do
248
+ stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID').to_return(status: 404, body: '', headers: {})
249
+ end
250
+ it 'returns 404' do
251
+ expect(Rails.logger).to receive(:warn).with('Term Not Found - Fetch term FAKE_ID unsuccessful for authority OCLC_FAST')
252
+ get :show, params: { id: 'FAKE_ID', vocab: 'OCLC_FAST' }
253
+ expect(response.code).to eq('404')
254
+ end
255
+ end
256
+
163
257
  context 'in OCLC_FAST authority' do
164
258
  context 'term found' do
165
259
  before do
@@ -176,7 +270,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
176
270
  context 'in AGROVOC authority' do
177
271
  context 'term found' do
178
272
  before do
179
- stub_request(:get, 'http://aims.fao.org/skosmos/rest/v1/data?uri=http://aims.fao.org/aos/agrovoc/c_9513')
273
+ stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/data?uri=http://aims.fao.org/aos/agrovoc/c_9513')
180
274
  .to_return(status: 200, body: webmock_fixture('lod_agrovoc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
181
275
  end
182
276
  it 'succeeds' do
@@ -7,24 +7,24 @@ describe Qa::Authorities::Local::FileBasedAuthority do
7
7
  let(:authority_d) { Qa::Authorities::Local.subauthority_for("authority_D") }
8
8
 
9
9
  describe "#all" do
10
- let(:expected) { [{ 'id' => "A1", 'label' => "Abc Term A1" },
11
- { 'id' => "A2", 'label' => "Term A2" },
12
- { 'id' => "A3", 'label' => "Abc Term A3" }] }
10
+ let(:expected) { [{ 'id' => "A1", 'label' => "Abc Term A1", 'active' => true },
11
+ { 'id' => "A2", 'label' => "Term A2", 'active' => false },
12
+ { 'id' => "A3", 'label' => "Abc Term A3", 'active' => true }] }
13
13
  it "returns all the entries" do
14
14
  expect(authority_a.all).to eq(expected)
15
15
  end
16
16
  context "when terms do not have ids" do
17
- let(:expected) { [{ 'id' => "Term B1", 'label' => "Term B1" },
18
- { 'id' => "Term B2", 'label' => "Term B2" },
19
- { 'id' => "Term B3", 'label' => "Term B3" }] }
17
+ let(:expected) { [{ 'id' => "Term B1", 'label' => "Term B1", 'active' => true },
18
+ { 'id' => "Term B2", 'label' => "Term B2", 'active' => true },
19
+ { 'id' => "Term B3", 'label' => "Term B3", 'active' => true }] }
20
20
  it "sets the id to be same as the label" do
21
21
  expect(authority_b.all).to eq(expected)
22
22
  end
23
23
  end
24
24
  context "authority YAML file is a list of terms" do
25
- let(:expected) { [{ 'id' => "Term C1", 'label' => "Term C1" },
26
- { 'id' => "Term C2", 'label' => "Term C2" },
27
- { 'id' => "Term C3", 'label' => "Term C3" }] }
25
+ let(:expected) { [{ 'id' => "Term C1", 'label' => "Term C1", 'active' => true },
26
+ { 'id' => "Term C2", 'label' => "Term C2", 'active' => true },
27
+ { 'id' => "Term C3", 'label' => "Term C3", 'active' => true }] }
28
28
  it "uses the terms as labels" do
29
29
  expect(authority_c.all).to eq(expected)
30
30
  end
@@ -62,7 +62,7 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
62
62
  context 'in AGROVOC authority' do
63
63
  context '0 search results' do
64
64
  let :results do
65
- stub_request(:get, 'http://aims.fao.org/skosmos/rest/v1/search/?lang=en&query=*supercalifragilisticexpialidocious*')
65
+ stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?lang=en&query=*supercalifragilisticexpialidocious*')
66
66
  .to_return(status: 200, body: webmock_fixture('lod_agrovoc_query_no_results.json'), headers: { 'Content-Type' => 'application/json' })
67
67
  lod_agrovoc.search('supercalifragilisticexpialidocious')
68
68
  end
@@ -73,7 +73,7 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
73
73
 
74
74
  context '3 search results' do
75
75
  let :results do
76
- stub_request(:get, 'http://aims.fao.org/skosmos/rest/v1/search/?lang=en&query=*milk*')
76
+ stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?lang=en&query=*milk*')
77
77
  .to_return(status: 200, body: webmock_fixture('lod_agrovoc_query_many_results.json'), headers: { 'Content-Type' => 'application/json' })
78
78
  lod_agrovoc.search('milk')
79
79
  end
@@ -271,7 +271,7 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
271
271
  context 'in AGROVOC authority' do
272
272
  context 'term found' do
273
273
  let :results do
274
- stub_request(:get, 'http://aims.fao.org/skosmos/rest/v1/data?uri=http://aims.fao.org/aos/agrovoc/c_9513')
274
+ stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/data?uri=http://aims.fao.org/aos/agrovoc/c_9513')
275
275
  .to_return(status: 200, body: webmock_fixture('lod_agrovoc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
276
276
  lod_agrovoc.find('c_9513')
277
277
  end
@@ -0,0 +1,5 @@
1
+ # Use this file to reference specific commits of gems.
2
+
3
+ group :development do
4
+ gem 'linkeddata'
5
+ 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: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Anderson
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2017-05-02 00:00:00.000000000 Z
18
+ date: 2017-06-23 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails
@@ -442,6 +442,7 @@ files:
442
442
  - spec/routing/linked_data_route_spec.rb
443
443
  - spec/routing/route_spec.rb
444
444
  - spec/spec_helper.rb
445
+ - spec/test_app_templates/Gemfile.extra
445
446
  - spec/test_app_templates/lib/generators/test_app_generator.rb
446
447
  homepage: https://github.com/projecthydra/questioning_authority
447
448
  licenses:
@@ -463,7 +464,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
463
464
  version: '0'
464
465
  requirements: []
465
466
  rubyforge_project:
466
- rubygems_version: 2.6.11
467
+ rubygems_version: 2.5.2
467
468
  signing_key:
468
469
  specification_version: 4
469
470
  summary: You should question your authorities.
@@ -561,4 +562,5 @@ test_files:
561
562
  - spec/routing/linked_data_route_spec.rb
562
563
  - spec/routing/route_spec.rb
563
564
  - spec/spec_helper.rb
565
+ - spec/test_app_templates/Gemfile.extra
564
566
  - spec/test_app_templates/lib/generators/test_app_generator.rb