gds-api-adapters 31.4.0 → 32.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1d2d6fa7d1e06178938f8bfc2dfc9c2dff6cce9
4
- data.tar.gz: a353fc5d44e6190d2b33ea88279992122081edd5
3
+ metadata.gz: ea71976a45af00221c91a69f9bf5e880913339ec
4
+ data.tar.gz: f25bf52a8ef88d54cd83080c80b87ba7d8a9c96a
5
5
  SHA512:
6
- metadata.gz: d4ceec5bd237d900a3a3d4eec48212afd6f8665b1ed4efe26babbb481ba2e18b89b120fb9c1c279ba98f1359785e3c2a5fe2276387d28ccd413c3b22dd7baf1d
7
- data.tar.gz: 30304753613699ff2c9f81ca7be4dd0bd89016f8b20eafb5b2b627cf71aebb822a03fb5a64b63aaf9d061180c69763d69bba312fdfb75c0df4732186ec5b8358
6
+ metadata.gz: 65a1b28bb05b35f6a4fc8bc91c0733dc0672107a5dd2f8201d68bc6ad5002f69b4aeda420024219032009afb52d13b5515f92fac20a1d278d2363affd2b5a2a8
7
+ data.tar.gz: 7ac7469c0bb5b2221d4ed36b1694ac8f2ccf436020eaaeaa20137ac955bd36a9b19c07478c28a4cf1dfae020af9e092248dc699bb041d3398a8f667c3e636cc5
data/README.md CHANGED
@@ -14,7 +14,7 @@ Example adapters for frequently used applications:
14
14
 
15
15
  - [Publishing API](lib/gds_api/publishing_api_v2.rb) ([docs](http://www.rubydoc.info/github/alphagov/gds-api-adapters/master/GdsApi/PublishingApiV2), [test helper code](https://github.com/alphagov/gds-api-adapters/blob/master/lib/gds_api/test_helpers/publishing_api_v2.rb), [test helper docs](http://www.rubydoc.info/github/alphagov/gds-api-adapters/master/GdsApi/TestHelpers/PublishingApiV2))
16
16
  - [Content Store](lib/gds_api/content_store.rb) ([docs](http://www.rubydoc.info/github/alphagov/gds-api-adapters/master/GdsApi/ContentStore), [test helper code](https://github.com/alphagov/gds-api-adapters/blob/master/lib/gds_api/test_helpers/content_store.rb), [test helper docs](http://www.rubydoc.info/github/alphagov/gds-api-adapters/master/GdsApi/TestHelpers/ContentStore))
17
- - [Rummager](lib/gds_api/publishing_api_v2.rb) ([docs](http://www.rubydoc.info/github/alphagov/gds-api-adapters/master/GdsApi/Rummager), [test helper code](https://github.com/alphagov/gds-api-adapters/blob/master/lib/gds_api/test_helpers/rummager.rb), [test helper docs](http://www.rubydoc.info/github/alphagov/gds-api-adapters/master/GdsApi/TestHelpers/Rummager))
17
+ - [Rummager](lib/gds_api/rummager.rb) ([docs](http://www.rubydoc.info/github/alphagov/gds-api-adapters/master/GdsApi/Rummager), [test helper code](https://github.com/alphagov/gds-api-adapters/blob/master/lib/gds_api/test_helpers/rummager.rb), [test helper docs](http://www.rubydoc.info/github/alphagov/gds-api-adapters/master/GdsApi/TestHelpers/Rummager))
18
18
 
19
19
  ## Logging
20
20
 
@@ -4,17 +4,19 @@ require 'gds_api/test_helpers/json_client_helper'
4
4
  module GdsApi
5
5
  module TestHelpers
6
6
  module Rummager
7
+ RUMMAGER_ENDPOINT = Plek.current.find('rummager')
8
+
7
9
  def stub_any_rummager_post
8
- stub_request(:post, %r{#{Plek.new.find('search')}/documents})
10
+ stub_request(:post, %r{#{RUMMAGER_ENDPOINT}/documents})
9
11
  end
10
12
 
11
13
  def stub_any_rummager_post_with_queueing_enabled
12
- stub_request(:post, %r{#{Plek.new.find('search')}/documents}) \
14
+ stub_request(:post, %r{#{RUMMAGER_ENDPOINT}/documents}) \
13
15
  .to_return(status: [202, "Accepted"])
14
16
  end
15
17
 
16
18
  def assert_rummager_posted_item(attributes)
17
- url = Plek.new.find('search') + "/documents"
19
+ url = RUMMAGER_ENDPOINT + "/documents"
18
20
  assert_requested(:post, url) do |req|
19
21
  data = JSON.parse(req.body)
20
22
  attributes.to_a.all? do |key, value|
@@ -25,23 +27,26 @@ module GdsApi
25
27
 
26
28
  # @deprecated Rummager.delete_docment is deprecated, so is this stub! Use `stub_any_rummager_delete_content`
27
29
  def stub_any_rummager_delete
28
- stub_request(:delete, %r{#{Plek.new.find('search')}/documents/.*})
30
+ warn "stub_any_rummager_delete is deprecated, instead use: stub_any_rummager_delete_content"
31
+ stub_request(:delete, %r{#{RUMMAGER_ENDPOINT}/documents/.*})
29
32
  end
30
33
 
31
34
  def stub_any_rummager_delete_content
32
- stub_request(:delete, %r{#{Plek.new.find('search')}/content.*})
35
+ stub_request(:delete, %r{#{RUMMAGER_ENDPOINT}/content.*})
33
36
  end
34
37
 
35
38
  # @deprecated Rummager.delete_docment is deprecated, so is this stub! Use `assert_rummager_deleted_content`
36
39
  def assert_rummager_deleted_item(id)
40
+ warn "assert_rummager_deleted_item stub is deprecated, instead use: assert_rummager_deleted_content"
41
+
37
42
  if id =~ %r{^/}
38
43
  raise ArgumentError, 'Rummager id must not start with a slash'
39
44
  end
40
- assert_requested(:delete, %r{#{Plek.new.find('search')}/documents/#{id}})
45
+ assert_requested(:delete, %r{#{RUMMAGER_ENDPOINT}/documents/#{id}})
41
46
  end
42
47
 
43
48
  def assert_rummager_deleted_content(base_path)
44
- assert_requested(:delete, %r{#{Plek.new.find('search')}/content.*#{base_path}})
49
+ assert_requested(:delete, %r{#{RUMMAGER_ENDPOINT}/content.*#{base_path}})
45
50
  end
46
51
 
47
52
  def rummager_has_services_and_info_data_for_organisation
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '31.4.0'
2
+ VERSION = '32.0.0'
3
3
  end
@@ -6,6 +6,10 @@ describe GdsApi::GovukHeaders do
6
6
  Thread.current[:headers] = nil if Thread.current[:headers]
7
7
  end
8
8
 
9
+ after :each do
10
+ GdsApi::GovukHeaders.clear_headers
11
+ end
12
+
9
13
  it "supports read/write of headers" do
10
14
  GdsApi::GovukHeaders.set_header("GDS-Request-Id", "123-456")
11
15
  GdsApi::GovukHeaders.set_header("Content-Type", "application/pdf")
@@ -286,6 +286,124 @@ describe GdsApi::PublishingApiV2 do
286
286
  end
287
287
  end
288
288
 
289
+ describe "when a content item exists in with a superseded version" do
290
+ describe "when requesting the superseded version" do
291
+ before do
292
+ @content_item = content_item_for_content_id(@content_id)
293
+
294
+ publishing_api
295
+ .given("a content item exists in with a superseded version with content_id: #{@content_id}")
296
+ .upon_receiving("a request to return the superseded content item")
297
+ .with(
298
+ method: :get,
299
+ path: "/v2/content/#{@content_id}",
300
+ query: "version=1",
301
+ )
302
+ .will_respond_with(
303
+ status: 200,
304
+ body: {
305
+ "content_id" => @content_id,
306
+ "document_type" => Pact.like("special_route"),
307
+ "schema_name" => Pact.like("special_route"),
308
+ "publishing_app" => Pact.like("publisher"),
309
+ "rendering_app" => Pact.like("frontend"),
310
+ "locale" => Pact.like("en"),
311
+ "routes" => Pact.like([{}]),
312
+ "public_updated_at" => Pact.like("2015-07-30T13:58:11.000Z"),
313
+ "details" => Pact.like({}),
314
+ "publication_state" => "superseded"
315
+ },
316
+ headers: {
317
+ "Content-Type" => "application/json; charset=utf-8",
318
+ },
319
+ )
320
+ end
321
+
322
+ it "responds with 200 and the superseded content item" do
323
+ response = @api_client.get_content(@content_id, version: 1)
324
+ assert_equal 200, response.code
325
+ assert_equal response["publication_state"], "superseded"
326
+ end
327
+ end
328
+
329
+ describe "when requesting the published version" do
330
+ before do
331
+ @content_item = content_item_for_content_id(@content_id)
332
+
333
+ publishing_api
334
+ .given("a content item exists in with a superseded version with content_id: #{@content_id}")
335
+ .upon_receiving("a request to return the published content item")
336
+ .with(
337
+ method: :get,
338
+ path: "/v2/content/#{@content_id}",
339
+ query: "version=2",
340
+ )
341
+ .will_respond_with(
342
+ status: 200,
343
+ body: {
344
+ "content_id" => @content_id,
345
+ "document_type" => Pact.like("special_route"),
346
+ "schema_name" => Pact.like("special_route"),
347
+ "publishing_app" => Pact.like("publisher"),
348
+ "rendering_app" => Pact.like("frontend"),
349
+ "locale" => Pact.like("en"),
350
+ "routes" => Pact.like([{}]),
351
+ "public_updated_at" => Pact.like("2015-07-30T13:58:11.000Z"),
352
+ "details" => Pact.like({}),
353
+ "publication_state" => "live"
354
+ },
355
+ headers: {
356
+ "Content-Type" => "application/json; charset=utf-8",
357
+ },
358
+ )
359
+ end
360
+
361
+ it "responds with 200 and the published content item" do
362
+ response = @api_client.get_content(@content_id, version: 2)
363
+ assert_equal 200, response.code
364
+ assert_equal response["publication_state"], "live"
365
+ end
366
+ end
367
+
368
+ describe "when requesting no specific version" do
369
+ before do
370
+ @content_item = content_item_for_content_id(@content_id)
371
+
372
+ publishing_api
373
+ .given("a content item exists in with a superseded version with content_id: #{@content_id}")
374
+ .upon_receiving("a request to return the content item")
375
+ .with(
376
+ method: :get,
377
+ path: "/v2/content/#{@content_id}",
378
+ )
379
+ .will_respond_with(
380
+ status: 200,
381
+ body: {
382
+ "content_id" => @content_id,
383
+ "document_type" => Pact.like("special_route"),
384
+ "schema_name" => Pact.like("special_route"),
385
+ "publishing_app" => Pact.like("publisher"),
386
+ "rendering_app" => Pact.like("frontend"),
387
+ "locale" => Pact.like("en"),
388
+ "routes" => Pact.like([{}]),
389
+ "public_updated_at" => Pact.like("2015-07-30T13:58:11.000Z"),
390
+ "details" => Pact.like({}),
391
+ "publication_state" => "live"
392
+ },
393
+ headers: {
394
+ "Content-Type" => "application/json; charset=utf-8",
395
+ },
396
+ )
397
+ end
398
+
399
+ it "responds with 200 and the published content item" do
400
+ response = @api_client.get_content(@content_id)
401
+ assert_equal 200, response.code
402
+ assert_equal response["publication_state"], "live"
403
+ end
404
+ end
405
+ end
406
+
289
407
  describe "a non-existent item" do
290
408
  before do
291
409
  publishing_api
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 31.4.0
4
+ version: 32.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Stewart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-05 00:00:00.000000000 Z
11
+ date: 2016-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek