gds-api-adapters 29.5.0 → 29.6.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: 06d4bf9f7af61e5fb2907ce142588d086fb91dc3
4
- data.tar.gz: f72878999ef140fa17ed686f27f8b08a8db9b725
3
+ metadata.gz: 9740e0fbf18097b3bda609a31d95238d536d5f19
4
+ data.tar.gz: f32388c9c90841aca6e94ac516cbddf429e2a92a
5
5
  SHA512:
6
- metadata.gz: bd4045e258186c9d7143874174a47be6f07ba0d05f6499abf2f0070a39af11527f3aca76c48848855e0a7e4e514f3ac1ad4668424e37ee10328c8da518047d06
7
- data.tar.gz: a5c7d1daeec6dab5feeb76a2d4bf38872577467a063d511f1ba50bd6e75edfe0c71f869a4dbcb0e16d1b72e057f5fc81dc4d2af633268e3a8cf6e5761e69b576
6
+ metadata.gz: 1dc950579af1a75714fa5b17133a64720b070bbe88867f23eb1b62de5bf447979c7c5042aa478b69bb5b657f2b752e3d1f0131dda67c1c35604cedd709a83ef3
7
+ data.tar.gz: e1fc3c89d8bb44abb11b5b6f4bbd06e288983abf93cb416dc00b73ae39f456bf1ae82d57f8cc8a5be0fdf47fd20e69412a3a6a9d3e318f4f63e209be87311538
data/README.md CHANGED
@@ -94,6 +94,14 @@ At time of writing, these are:
94
94
 
95
95
  * [WebMock](https://github.com/bblimke/webmock)
96
96
 
97
+ ### Documentation
98
+
99
+ See [RubyDoc](http://www.rubydoc.info/gems/gds-api-adapters) for some limited documentation.
100
+
101
+ To run a Yard server locally to preview documentation, run:
102
+
103
+ $ bundle exec yard server --reload
104
+
97
105
  ## Licence
98
106
 
99
107
  Released under the MIT Licence, a copy of which can be found in the file
@@ -33,6 +33,39 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
33
33
  get_json!(content_url(content_id, params))
34
34
  end
35
35
 
36
+ # Find the content_ids for a list of base_paths.
37
+ #
38
+ # @param base_paths [Array]
39
+ # @return [Hash] a hash, keyed by `base_path` with `content_id` as value
40
+ # @example
41
+ #
42
+ # publishing_api.lookup_content_ids(base_paths: ['/foo', '/bar'])
43
+ # # => { "/foo" => "51ac4247-fd92-470a-a207-6b852a97f2db", "/bar" => "261bd281-f16c-48d5-82d2-9544019ad9ca" }
44
+ #
45
+ def lookup_content_ids(base_paths:)
46
+ response = post_json!("#{endpoint}/lookup-by-base-path", base_paths: base_paths)
47
+ response.to_hash
48
+ end
49
+
50
+ # Find the content_id for a base_path.
51
+ #
52
+ # Convenience method if you only need to look up one content_id for a
53
+ # base_path. For multiple base_paths, use {GdsApi::PublishingApiV2#lookup_content_ids}.
54
+ #
55
+ # @param base_path [String]
56
+ #
57
+ # @return [UUID] the `content_id` for the `base_path`
58
+ #
59
+ # @example
60
+ #
61
+ # publishing_api.lookup_content_id(base_path: '/foo')
62
+ # # => "51ac4247-fd92-470a-a207-6b852a97f2db"
63
+ #
64
+ def lookup_content_id(base_path:)
65
+ lookups = lookup_content_ids(base_paths: [base_path])
66
+ lookups[base_path]
67
+ end
68
+
36
69
  def publish(content_id, update_type, options = {})
37
70
  params = {
38
71
  update_type: update_type
@@ -175,7 +175,24 @@ module GdsApi
175
175
  stub_request(:get, url).to_return(status: 404, body: resource_not_found(content_id, "link set").to_json, headers: {})
176
176
  end
177
177
 
178
+ # Stub calls to the lookups endpoint
179
+ #
180
+ # @param lookup_hash [Hash] Hash with base_path as key, content_id as value.
181
+ #
182
+ # @example
183
+ #
184
+ # publishing_api_has_lookups({
185
+ # "/foo" => "51ac4247-fd92-470a-a207-6b852a97f2db",
186
+ # "/bar" => "261bd281-f16c-48d5-82d2-9544019ad9ca"
187
+ # })
188
+ #
189
+ def publishing_api_has_lookups(lookup_hash)
190
+ url = Plek.current.find('publishing-api') + '/lookup-by-base-path'
191
+ stub_request(:post, url).to_return(body: lookup_hash.to_json)
192
+ end
193
+
178
194
  private
195
+
179
196
  def stub_publishing_api_put(*args)
180
197
  stub_publishing_api_postlike_call(:put, *args)
181
198
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '29.5.0'
2
+ VERSION = '29.6.0'
3
3
  end
@@ -0,0 +1,70 @@
1
+ require 'test_helper'
2
+ require 'gds_api/publishing_api_v2'
3
+ require 'json'
4
+
5
+ describe GdsApi::PublishingApiV2 do
6
+ include PactTest
7
+
8
+ before do
9
+ @api_client = GdsApi::PublishingApiV2.new('http://localhost:3093')
10
+ end
11
+
12
+ describe "#lookup_content_id" do
13
+ it "returns the content_id for a base_path" do
14
+ publishing_api
15
+ .given("there are live content items with base_paths /foo and /bar")
16
+ .upon_receiving("a /lookup-by-base-path-request")
17
+ .with(
18
+ method: :post,
19
+ path: "/lookup-by-base-path",
20
+ body: {
21
+ base_paths: ["/foo"]
22
+ },
23
+ headers: {
24
+ "Content-Type" => "application/json",
25
+ },
26
+ )
27
+ .will_respond_with(
28
+ status: 200,
29
+ body: {
30
+ "/foo" => "08f86d00-e95f-492f-af1d-470c5ba4752e"
31
+ }
32
+ )
33
+
34
+ content_id = @api_client.lookup_content_id(base_path: "/foo")
35
+
36
+ assert_equal "08f86d00-e95f-492f-af1d-470c5ba4752e", content_id
37
+ end
38
+ end
39
+
40
+ describe "#lookup_content_ids" do
41
+ it "returns the content_id for a base_path" do
42
+ reponse_hash = {
43
+ "/foo" => "08f86d00-e95f-492f-af1d-470c5ba4752e",
44
+ "/bar" => "ca6c58a6-fb9d-479d-b3e6-74908781cb18",
45
+ }
46
+
47
+ publishing_api
48
+ .given("there are live content items with base_paths /foo and /bar")
49
+ .upon_receiving("a request for multiple base_paths")
50
+ .with(
51
+ method: :post,
52
+ path: "/lookup-by-base-path",
53
+ body: {
54
+ base_paths: ["/foo", "/bar"]
55
+ },
56
+ headers: {
57
+ "Content-Type" => "application/json",
58
+ },
59
+ )
60
+ .will_respond_with(
61
+ status: 200,
62
+ body: reponse_hash,
63
+ )
64
+
65
+ content_id = @api_client.lookup_content_ids(base_paths: ["/foo", "/bar"])
66
+
67
+ assert_equal(reponse_hash, content_id)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+ require 'gds_api/publishing_api_v2'
3
+ require 'gds_api/test_helpers/publishing_api_v2'
4
+
5
+ describe GdsApi::TestHelpers::PublishingApiV2 do
6
+ include GdsApi::TestHelpers::PublishingApiV2
7
+ let(:publishing_api) { GdsApi::PublishingApiV2.new(Plek.current.find("publishing-api")) }
8
+
9
+ describe "#publishing_api_has_lookups" do
10
+ it "stubs the lookup for content items" do
11
+ lookup_hash = { "/foo" => "2878337b-bed9-4e7f-85b6-10ed2cbcd504" }
12
+
13
+ publishing_api_has_lookups(lookup_hash)
14
+
15
+ assert_equal publishing_api.lookup_content_ids(base_paths: ["/foo"]), lookup_hash
16
+ assert_equal publishing_api.lookup_content_id(base_path: "/foo"), "2878337b-bed9-4e7f-85b6-10ed2cbcd504"
17
+ end
18
+ end
19
+ end
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: 29.5.0
4
+ version: 29.6.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-03-09 00:00:00.000000000 Z
11
+ date: 2016-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek
@@ -221,19 +221,19 @@ dependencies:
221
221
  - !ruby/object:Gem::Version
222
222
  version: 0.9.2.2
223
223
  - !ruby/object:Gem::Dependency
224
- name: rdoc
224
+ name: yard
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - '='
228
228
  - !ruby/object:Gem::Version
229
- version: '3.12'
229
+ version: 0.8.7.6
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - '='
235
235
  - !ruby/object:Gem::Version
236
- version: '3.12'
236
+ version: 0.8.7.6
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: simplecov
239
239
  requirement: !ruby/object:Gem::Requirement
@@ -420,6 +420,7 @@ files:
420
420
  - test/publisher_api_test.rb
421
421
  - test/publishing_api/special_route_publisher_test.rb
422
422
  - test/publishing_api_test.rb
423
+ - test/publishing_api_v2/lookup_test.rb
423
424
  - test/publishing_api_v2_test.rb
424
425
  - test/response_test.rb
425
426
  - test/router_test.rb
@@ -432,6 +433,7 @@ files:
432
433
  - test/test_helpers/pact_helper.rb
433
434
  - test/test_helpers/panopticon_test.rb
434
435
  - test/test_helpers/publishing_api_test.rb
436
+ - test/test_helpers/publishing_api_v2_test.rb
435
437
  - test/whitehall_admin_api_test.rb
436
438
  - test/worldwide_api_test.rb
437
439
  homepage: http://github.com/alphagov/gds-api-adapters
@@ -458,51 +460,54 @@ signing_key:
458
460
  specification_version: 4
459
461
  summary: Adapters to work with GDS APIs
460
462
  test_files:
461
- - test/support_api_test.rb
462
- - test/mapit_test.rb
463
+ - test/content_api_test.rb
464
+ - test/json_client_test.rb
465
+ - test/content_store_test.rb
463
466
  - test/publishing_api_test.rb
467
+ - test/business_support_api_test.rb
468
+ - test/middleware/govuk_header_sniffer_test.rb
464
469
  - test/whitehall_admin_api_test.rb
465
- - test/pp_data_in_test.rb
466
- - test/publishing_api/special_route_publisher_test.rb
467
- - test/need_api_test.rb
470
+ - test/list_response_test.rb
471
+ - test/maslow_test.rb
472
+ - test/panopticon_registerer_test.rb
473
+ - test/support_test.rb
474
+ - test/asset_manager_test.rb
475
+ - test/helpers_test.rb
476
+ - test/licence_application_api_test.rb
477
+ - test/test_helper.rb
468
478
  - test/publisher_api_test.rb
479
+ - test/mapit_test.rb
469
480
  - test/rummager_helpers_test.rb
470
- - test/support_test.rb
471
- - test/content_register_test.rb
481
+ - test/publishing_api_v2_test.rb
482
+ - test/publishing_api_v2/lookup_test.rb
483
+ - test/support_api_test.rb
484
+ - test/organisations_api_test.rb
485
+ - test/gds_api_base_test.rb
486
+ - test/router_test.rb
487
+ - test/publishing_api/special_route_publisher_test.rb
488
+ - test/external_link_tracker_test.rb
472
489
  - test/fact_cave_test.rb
473
- - test/test_helpers/publishing_api_test.rb
474
- - test/test_helpers/pact_helper.rb
475
- - test/test_helpers/panopticon_test.rb
476
- - test/test_helpers/email_alert_api_test.rb
477
- - test/licence_application_api_test.rb
478
- - test/gov_uk_delivery_test.rb
479
- - test/maslow_test.rb
480
- - test/helpers_test.rb
481
- - test/panopticon_registerer_test.rb
490
+ - test/need_api_test.rb
491
+ - test/content_register_test.rb
482
492
  - test/panopticon_test.rb
483
- - test/middleware/govuk_header_sniffer_test.rb
484
- - test/rummager_test.rb
485
- - test/json_client_test.rb
486
- - test/email_alert_api_test.rb
487
- - test/content_api_test.rb
488
- - test/response_test.rb
489
- - test/organisations_api_test.rb
490
- - test/imminence_api_test.rb
491
- - test/content_store_test.rb
492
- - test/asset_manager_test.rb
493
+ - test/pp_data_in_test.rb
493
494
  - test/fixtures/hello.txt
494
495
  - test/fixtures/new_policies_for_dwp.json
495
- - test/fixtures/world_organisations_australia.json
496
496
  - test/fixtures/no_services_and_info_data_found_fixture.json
497
- - test/fixtures/old_policies_for_dwp.json
498
497
  - test/fixtures/services_and_info_fixture.json
498
+ - test/fixtures/old_policies_for_dwp.json
499
+ - test/fixtures/world_organisations_australia.json
499
500
  - test/fixtures/sub_sector_organisations.json
500
501
  - test/fixtures/finder_api/cma-case-schema.json
501
- - test/router_test.rb
502
- - test/list_response_test.rb
503
- - test/external_link_tracker_test.rb
504
- - test/gds_api_base_test.rb
505
502
  - test/worldwide_api_test.rb
506
- - test/test_helper.rb
507
- - test/publishing_api_v2_test.rb
508
- - test/business_support_api_test.rb
503
+ - test/test_helpers/publishing_api_test.rb
504
+ - test/test_helpers/publishing_api_v2_test.rb
505
+ - test/test_helpers/pact_helper.rb
506
+ - test/test_helpers/panopticon_test.rb
507
+ - test/test_helpers/email_alert_api_test.rb
508
+ - test/gov_uk_delivery_test.rb
509
+ - test/imminence_api_test.rb
510
+ - test/email_alert_api_test.rb
511
+ - test/response_test.rb
512
+ - test/rummager_test.rb
513
+ has_rdoc: