gds-api-adapters 6.0.0 → 6.1.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.
@@ -56,6 +56,10 @@ class GdsApi::ContentApi < GdsApi::Base
56
56
  get_json(url)
57
57
  end
58
58
 
59
+ def artefacts
60
+ get_list!("#{base_url}/artefacts.json")
61
+ end
62
+
59
63
  def local_authority(snac_code)
60
64
  get_json("#{base_url}/local_authorities/#{CGI.escape(snac_code)}.json")
61
65
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '6.0.0'
2
+ VERSION = '6.1.0'
3
3
  end
@@ -198,6 +198,62 @@ describe GdsApi::ContentApi do
198
198
  end
199
199
  end
200
200
 
201
+ describe "artefacts" do
202
+ before :each do
203
+ @artefacts_endpoint = "#{GdsApi::TestHelpers::ContentApi::CONTENT_API_ENDPOINT}/artefacts.json"
204
+ end
205
+
206
+ it "should return a listresponse for the artefacts" do
207
+ WebMock.stub_request(:get, @artefacts_endpoint).
208
+ to_return(:body => {
209
+ "_response_info" => {"status" => "ok"},
210
+ "total" => 4,
211
+ "results" => [
212
+ {"format" => "answer", "web_url" => "http://www.test.gov.uk/foo"},
213
+ {"format" => "local_transaction", "web_url" => "http://www.test.gov.uk/bar/baz"},
214
+ {"format" => "place", "web_url" => "http://www.test.gov.uk/somewhere"},
215
+ {"format" => "guide", "web_url" => "http://www.test.gov.uk/vat"},
216
+ ]
217
+ }.to_json)
218
+
219
+ response = @api.artefacts
220
+ assert_equal 4, response.count
221
+ assert_equal %w(answer local_transaction place guide), response.map(&:format)
222
+ end
223
+
224
+ it "should work with a paginated response" do
225
+ WebMock.stub_request(:get, @artefacts_endpoint).
226
+ to_return(
227
+ :body => {
228
+ "_response_info" => {"status" => "ok"},
229
+ "total" => 4,
230
+ "results" => [
231
+ {"format" => "answer", "web_url" => "http://www.test.gov.uk/foo"},
232
+ {"format" => "local_transaction", "web_url" => "http://www.test.gov.uk/bar/baz"},
233
+ {"format" => "place", "web_url" => "http://www.test.gov.uk/somewhere"},
234
+ {"format" => "guide", "web_url" => "http://www.test.gov.uk/vat"},
235
+ ]
236
+ }.to_json,
237
+ :headers => {"Link" => "<#{@artefacts_endpoint}?page=2>; rel=\"next\""}
238
+ )
239
+ WebMock.stub_request(:get, "#{@artefacts_endpoint}?page=2").
240
+ to_return(
241
+ :body => {
242
+ "_response_info" => {"status" => "ok"},
243
+ "total" => 3,
244
+ "results" => [
245
+ {"format" => "answer", "web_url" => "http://www.test.gov.uk/foo2"},
246
+ {"format" => "local_transaction", "web_url" => "http://www.test.gov.uk/bar/baz2"},
247
+ {"format" => "guide", "web_url" => "http://www.test.gov.uk/vat2"},
248
+ ]
249
+ }.to_json
250
+ )
251
+ response = @api.artefacts
252
+ assert_equal 7, response.with_subsequent_pages.count
253
+ assert_equal "http://www.test.gov.uk/vat2", response.with_subsequent_pages.to_a.last.web_url
254
+ end
255
+ end
256
+
201
257
  describe "tags" do
202
258
  it "should produce an artefact with the provided tag" do
203
259
  tag = "crime-and-justice"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 6.0.0
5
+ version: 6.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Stewart
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-04-25 00:00:00 Z
13
+ date: 2013-05-24 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: plek
@@ -254,7 +254,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
254
254
  requirements:
255
255
  - - ">="
256
256
  - !ruby/object:Gem::Version
257
- hash: -4292266406700187648
257
+ hash: -673475242320565941
258
258
  segments:
259
259
  - 0
260
260
  version: "0"
@@ -263,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
263
  requirements:
264
264
  - - ">="
265
265
  - !ruby/object:Gem::Version
266
- hash: -4292266406700187648
266
+ hash: -673475242320565941
267
267
  segments:
268
268
  - 0
269
269
  version: "0"