gds-api-adapters 7.20.0 → 7.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/gds_api/content_api.rb +4 -0
- data/lib/gds_api/test_helpers/content_api.rb +9 -0
- data/lib/gds_api/version.rb +1 -1
- data/test/content_api_test.rb +16 -0
- metadata +4 -4
data/lib/gds_api/content_api.rb
CHANGED
@@ -43,6 +43,10 @@ class GdsApi::ContentApi < GdsApi::Base
|
|
43
43
|
get_list!("#{base_url}/with_tag.json?tag=#{CGI.escape(tag)}&sort=#{sort_by}")
|
44
44
|
end
|
45
45
|
|
46
|
+
def for_need(need_id)
|
47
|
+
get_list("#{base_url}/for_need/#{CGI.escape(need_id.to_s)}.json")
|
48
|
+
end
|
49
|
+
|
46
50
|
def artefact(slug, params={})
|
47
51
|
url = "#{base_url}/#{CGI.escape(slug)}.json"
|
48
52
|
query = params.map { |k,v| "#{k}=#{v}" }
|
@@ -296,6 +296,15 @@ module GdsApi
|
|
296
296
|
raise "Need a licence identifier" if details[:licence_identifier].nil?
|
297
297
|
@stubbed_content_api_licences << details
|
298
298
|
end
|
299
|
+
|
300
|
+
def content_api_has_artefacts_for_need_id(need_id, artefacts)
|
301
|
+
url = "#{CONTENT_API_ENDPOINT}/for_need/#{CGI.escape(need_id.to_s)}.json"
|
302
|
+
body = plural_response_base.merge(
|
303
|
+
'results' => artefacts
|
304
|
+
)
|
305
|
+
|
306
|
+
stub_request(:get, url).to_return(status: 200, body: body.to_json, headers: [])
|
307
|
+
end
|
299
308
|
end
|
300
309
|
end
|
301
310
|
end
|
data/lib/gds_api/version.rb
CHANGED
data/test/content_api_test.rb
CHANGED
@@ -254,6 +254,22 @@ describe GdsApi::ContentApi do
|
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
|
+
describe "artefacts for need" do
|
258
|
+
it "should fetch artefacts with a given need id" do
|
259
|
+
content_api_has_artefacts_for_need_id(100123, [
|
260
|
+
{ "format" => "answer", "web_url" => "http://www.gov.uk/burrito" },
|
261
|
+
{ "format" => "guide", "web_url" => "http://www.gov.uk/burrito-standard" },
|
262
|
+
{ "format" => "transaction", "web_url" => "http://www.gov.uk/local-burrito-place" }
|
263
|
+
])
|
264
|
+
|
265
|
+
response = @api.for_need(100123)
|
266
|
+
|
267
|
+
assert_equal 3, response.count
|
268
|
+
assert_equal ["http://www.gov.uk/burrito", "http://www.gov.uk/burrito-standard", "http://www.gov.uk/local-burrito-place" ], response.map(&:web_url)
|
269
|
+
assert_equal ["answer", "guide", "transaction" ], response.map(&:format)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
257
273
|
describe "tags" do
|
258
274
|
it "should produce an artefact with the provided tag" do
|
259
275
|
tag = "crime-and-justice"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.21.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plek
|
@@ -340,7 +340,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
340
340
|
version: '0'
|
341
341
|
segments:
|
342
342
|
- 0
|
343
|
-
hash: -
|
343
|
+
hash: -669457376295499095
|
344
344
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
345
345
|
none: false
|
346
346
|
requirements:
|
@@ -349,7 +349,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
349
349
|
version: '0'
|
350
350
|
segments:
|
351
351
|
- 0
|
352
|
-
hash: -
|
352
|
+
hash: -669457376295499095
|
353
353
|
requirements: []
|
354
354
|
rubyforge_project:
|
355
355
|
rubygems_version: 1.8.23
|