gds-api-adapters 28.3.1 → 29.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 +4 -4
- data/lib/gds_api/base.rb +1 -0
- data/lib/gds_api/json_client.rb +5 -1
- data/lib/gds_api/publishing_api/special_route_publisher.rb +1 -1
- data/lib/gds_api/publishing_api_v2.rb +2 -2
- data/lib/gds_api/test_helpers/publishing_api_v2.rb +5 -5
- data/lib/gds_api/version.rb +1 -1
- data/test/publishing_api/special_route_publisher_test.rb +1 -1
- data/test/publishing_api_v2_test.rb +19 -19
- metadata +37 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71362128a4913b6fa7588f899cb6ec02ce1b9f8f
|
4
|
+
data.tar.gz: a401050ecf364fbc755e53d0abf0757e64ffbed7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a095ca287ef2049fa280105ffa09f4cd03397261a3c1b8e92e34db4603a00d16952339058fc8d82ef492bf22f3c855dfc170089de18965381e3530f3bb613a3f
|
7
|
+
data.tar.gz: 8935835598a80361fbb7392b5f2b57bea283f463920a985e344f8418f846de6544218642216941115d1d61e97943f7b81dbde35c50473e08f75019e77ed32b70
|
data/lib/gds_api/base.rb
CHANGED
data/lib/gds_api/json_client.rb
CHANGED
@@ -78,7 +78,7 @@ module GdsApi
|
|
78
78
|
# Each "bang method" tries to make a request, but raises an exception if
|
79
79
|
# the response is not successful. These methods discard the HTTPNotFound
|
80
80
|
# exceptions (and return nil), and pass through all other exceptions.
|
81
|
-
[:get, :post, :put, :delete].each do |http_method|
|
81
|
+
[:get, :post, :put, :patch, :delete].each do |http_method|
|
82
82
|
method_name = "#{http_method}_json"
|
83
83
|
define_method method_name do |url, *args, &block|
|
84
84
|
ignoring_missing do
|
@@ -99,6 +99,10 @@ module GdsApi
|
|
99
99
|
do_json_request(:put, url, params, additional_headers)
|
100
100
|
end
|
101
101
|
|
102
|
+
def patch_json!(url, params, additional_headers = {})
|
103
|
+
do_json_request(:patch, url, params, additional_headers)
|
104
|
+
end
|
105
|
+
|
102
106
|
def delete_json!(url, params = nil, additional_headers = {})
|
103
107
|
do_json_request(:delete, url, params, additional_headers)
|
104
108
|
end
|
@@ -27,7 +27,7 @@ module GdsApi
|
|
27
27
|
rendering_app: options.fetch(:rendering_app),
|
28
28
|
public_updated_at: time.now.iso8601,
|
29
29
|
})
|
30
|
-
publishing_api.
|
30
|
+
publishing_api.patch_links(options.fetch(:content_id), links: options[:links]) if options[:links]
|
31
31
|
publishing_api.publish(options.fetch(:content_id), 'major')
|
32
32
|
put_content_response
|
33
33
|
end
|
@@ -63,14 +63,14 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
|
|
63
63
|
get_json(links_url(content_id))
|
64
64
|
end
|
65
65
|
|
66
|
-
def
|
66
|
+
def patch_links(content_id, payload)
|
67
67
|
params = {
|
68
68
|
links: payload.fetch(:links)
|
69
69
|
}
|
70
70
|
|
71
71
|
params = merge_optional_keys(params, payload, [:previous_version])
|
72
72
|
|
73
|
-
|
73
|
+
patch_json!(links_url(content_id), params)
|
74
74
|
end
|
75
75
|
|
76
76
|
def get_content_items(params)
|
@@ -26,7 +26,7 @@ module GdsApi
|
|
26
26
|
stub_publishing_api_put(content_id, body, '/content', response_hash)
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def stub_publishing_api_patch_links(content_id, body)
|
30
30
|
stub_publishing_api_put(content_id, body, '/links')
|
31
31
|
end
|
32
32
|
|
@@ -48,7 +48,7 @@ module GdsApi
|
|
48
48
|
end
|
49
49
|
stubs = []
|
50
50
|
stubs << stub_publishing_api_put_content(content_id, body.except(:links))
|
51
|
-
stubs <<
|
51
|
+
stubs << stub_publishing_api_patch_links(content_id, body.slice(:links)) unless body.slice(:links).empty?
|
52
52
|
stubs << stub_publishing_api_publish(content_id, publish_body)
|
53
53
|
stubs
|
54
54
|
end
|
@@ -57,7 +57,7 @@ module GdsApi
|
|
57
57
|
stub_request(:put, %r{\A#{PUBLISHING_API_V2_ENDPOINT}/content/})
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
60
|
+
def stub_any_publishing_api_patch_links
|
61
61
|
stub_request(:put, %r{\A#{PUBLISHING_API_V2_ENDPOINT}/links/})
|
62
62
|
end
|
63
63
|
|
@@ -81,7 +81,7 @@ module GdsApi
|
|
81
81
|
publish_body[:locale] = body[:locale] if body[:locale]
|
82
82
|
end
|
83
83
|
assert_publishing_api_put_content(content_id, body.except(:links))
|
84
|
-
|
84
|
+
assert_publishing_api_patch_links(content_id, body.slice(:links)) unless body.slice(:links).empty?
|
85
85
|
assert_publishing_api_publish(content_id, publish_body)
|
86
86
|
end
|
87
87
|
|
@@ -95,7 +95,7 @@ module GdsApi
|
|
95
95
|
assert_publishing_api(:post, url, attributes_or_matcher, times)
|
96
96
|
end
|
97
97
|
|
98
|
-
def
|
98
|
+
def assert_publishing_api_patch_links(content_id, attributes_or_matcher = nil, times = 1)
|
99
99
|
url = PUBLISHING_API_V2_ENDPOINT + "/links/" + content_id
|
100
100
|
assert_publishing_api(:put, url, attributes_or_matcher, times)
|
101
101
|
end
|
data/lib/gds_api/version.rb
CHANGED
@@ -60,7 +60,7 @@ describe GdsApi::PublishingApi::SpecialRoutePublisher do
|
|
60
60
|
|
61
61
|
publisher.publish(special_route.merge(links))
|
62
62
|
|
63
|
-
assert_requested(:
|
63
|
+
assert_requested(:patch, "#{endpoint}/v2/links/#{content_id}", body: links)
|
64
64
|
end
|
65
65
|
|
66
66
|
describe 'Timezone handling' do
|
@@ -615,14 +615,14 @@ describe GdsApi::PublishingApiV2 do
|
|
615
615
|
end
|
616
616
|
end
|
617
617
|
|
618
|
-
describe "#
|
618
|
+
describe "#patch_links" do
|
619
619
|
describe "when setting links of the same type" do
|
620
620
|
before do
|
621
621
|
publishing_api
|
622
622
|
.given("organisation links exist for content_id #{@content_id}")
|
623
|
-
.upon_receiving("a
|
623
|
+
.upon_receiving("a patch organisation links request")
|
624
624
|
.with(
|
625
|
-
method: :
|
625
|
+
method: :patch,
|
626
626
|
path: "/v2/links/#{@content_id}",
|
627
627
|
body: {
|
628
628
|
links: {
|
@@ -644,7 +644,7 @@ describe GdsApi::PublishingApiV2 do
|
|
644
644
|
end
|
645
645
|
|
646
646
|
it "replaces the links and responds with the new links" do
|
647
|
-
response = @api_client.
|
647
|
+
response = @api_client.patch_links(@content_id, links: {
|
648
648
|
organisations: ["591436ab-c2ae-416f-a3c5-1901d633fbfb"],
|
649
649
|
})
|
650
650
|
assert_equal 200, response.code
|
@@ -656,9 +656,9 @@ describe GdsApi::PublishingApiV2 do
|
|
656
656
|
before do
|
657
657
|
publishing_api
|
658
658
|
.given("organisation links exist for content_id #{@content_id}")
|
659
|
-
.upon_receiving("a
|
659
|
+
.upon_receiving("a patch topic links request")
|
660
660
|
.with(
|
661
|
-
method: :
|
661
|
+
method: :patch,
|
662
662
|
path: "/v2/links/#{@content_id}",
|
663
663
|
body: {
|
664
664
|
links: {
|
@@ -681,7 +681,7 @@ describe GdsApi::PublishingApiV2 do
|
|
681
681
|
end
|
682
682
|
|
683
683
|
it "adds the new type of links and responds with the whole link set" do
|
684
|
-
response = @api_client.
|
684
|
+
response = @api_client.patch_links(@content_id, links: {
|
685
685
|
topics: ["225df4a8-2945-4e9b-8799-df7424a90b69"],
|
686
686
|
})
|
687
687
|
|
@@ -697,9 +697,9 @@ describe GdsApi::PublishingApiV2 do
|
|
697
697
|
before do
|
698
698
|
publishing_api
|
699
699
|
.given("organisation links exist for content_id #{@content_id}")
|
700
|
-
.upon_receiving("a
|
700
|
+
.upon_receiving("a patch blank organisation links request")
|
701
701
|
.with(
|
702
|
-
method: :
|
702
|
+
method: :patch,
|
703
703
|
path: "/v2/links/#{@content_id}",
|
704
704
|
body: {
|
705
705
|
links: {
|
@@ -719,7 +719,7 @@ describe GdsApi::PublishingApiV2 do
|
|
719
719
|
end
|
720
720
|
|
721
721
|
it "responds with the links" do
|
722
|
-
response = @api_client.
|
722
|
+
response = @api_client.patch_links(@content_id, links: {
|
723
723
|
organisations: [],
|
724
724
|
})
|
725
725
|
|
@@ -732,9 +732,9 @@ describe GdsApi::PublishingApiV2 do
|
|
732
732
|
before do
|
733
733
|
publishing_api
|
734
734
|
.given("no links exist for content_id #{@content_id}")
|
735
|
-
.upon_receiving("a
|
735
|
+
.upon_receiving("a patch organisation links request")
|
736
736
|
.with(
|
737
|
-
method: :
|
737
|
+
method: :patch,
|
738
738
|
path: "/v2/links/#{@content_id}",
|
739
739
|
body: {
|
740
740
|
links: {
|
@@ -756,7 +756,7 @@ describe GdsApi::PublishingApiV2 do
|
|
756
756
|
end
|
757
757
|
|
758
758
|
it "responds with the links" do
|
759
|
-
response = @api_client.
|
759
|
+
response = @api_client.patch_links(@content_id, links: {
|
760
760
|
organisations: ["591436ab-c2ae-416f-a3c5-1901d633fbfb"],
|
761
761
|
})
|
762
762
|
|
@@ -774,7 +774,7 @@ describe GdsApi::PublishingApiV2 do
|
|
774
774
|
.given("the linkset for #{@content_id} is at version 3")
|
775
775
|
.upon_receiving("a request to update the linkset at version 3")
|
776
776
|
.with(
|
777
|
-
method: :
|
777
|
+
method: :patch,
|
778
778
|
path: "/v2/links/#{@content_id}",
|
779
779
|
body: {
|
780
780
|
links: {
|
@@ -792,7 +792,7 @@ describe GdsApi::PublishingApiV2 do
|
|
792
792
|
end
|
793
793
|
|
794
794
|
it "responds with 200 OK" do
|
795
|
-
response = @api_client.
|
795
|
+
response = @api_client.patch_links(@content_id,
|
796
796
|
links: {
|
797
797
|
organisations: ["591436ab-c2ae-416f-a3c5-1901d633fbfb"],
|
798
798
|
},
|
@@ -809,7 +809,7 @@ describe GdsApi::PublishingApiV2 do
|
|
809
809
|
.given("the linkset for #{@content_id} is at version 3")
|
810
810
|
.upon_receiving("a request to update the linkset at version 2")
|
811
811
|
.with(
|
812
|
-
method: :
|
812
|
+
method: :patch,
|
813
813
|
path: "/v2/links/#{@content_id}",
|
814
814
|
body: {
|
815
815
|
links: {
|
@@ -840,7 +840,7 @@ describe GdsApi::PublishingApiV2 do
|
|
840
840
|
|
841
841
|
it "responds with 409 Conflict" do
|
842
842
|
error = assert_raises GdsApi::HTTPClientError do
|
843
|
-
@api_client.
|
843
|
+
@api_client.patch_links(@content_id,
|
844
844
|
links: {
|
845
845
|
organisations: ["591436ab-c2ae-416f-a3c5-1901d633fbfb"],
|
846
846
|
},
|
@@ -1210,8 +1210,8 @@ describe GdsApi::PublishingApiV2 do
|
|
1210
1210
|
proc { @api_client.put_content(nil, {}) }.must_raise ArgumentError
|
1211
1211
|
end
|
1212
1212
|
|
1213
|
-
it "happens on
|
1214
|
-
proc { @api_client.
|
1213
|
+
it "happens on patch_links" do
|
1214
|
+
proc { @api_client.patch_links(nil, links: {}) }.must_raise ArgumentError
|
1215
1215
|
end
|
1216
1216
|
end
|
1217
1217
|
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:
|
4
|
+
version: 29.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-02-
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plek
|
@@ -458,51 +458,51 @@ signing_key:
|
|
458
458
|
specification_version: 4
|
459
459
|
summary: Adapters to work with GDS APIs
|
460
460
|
test_files:
|
461
|
-
- test/
|
462
|
-
- test/
|
461
|
+
- test/content_api_test.rb
|
462
|
+
- test/json_client_test.rb
|
463
|
+
- test/content_store_test.rb
|
463
464
|
- test/publishing_api_test.rb
|
465
|
+
- test/business_support_api_test.rb
|
466
|
+
- test/middleware/govuk_header_sniffer_test.rb
|
464
467
|
- test/whitehall_admin_api_test.rb
|
465
|
-
- test/
|
466
|
-
- test/
|
467
|
-
- test/
|
468
|
+
- test/list_response_test.rb
|
469
|
+
- test/maslow_test.rb
|
470
|
+
- test/panopticon_registerer_test.rb
|
471
|
+
- test/support_test.rb
|
472
|
+
- test/asset_manager_test.rb
|
473
|
+
- test/helpers_test.rb
|
474
|
+
- test/licence_application_api_test.rb
|
475
|
+
- test/test_helper.rb
|
468
476
|
- test/publisher_api_test.rb
|
477
|
+
- test/mapit_test.rb
|
469
478
|
- test/rummager_helpers_test.rb
|
470
|
-
- test/
|
471
|
-
- test/
|
479
|
+
- test/publishing_api_v2_test.rb
|
480
|
+
- test/support_api_test.rb
|
481
|
+
- test/organisations_api_test.rb
|
482
|
+
- test/gds_api_base_test.rb
|
483
|
+
- test/router_test.rb
|
484
|
+
- test/publishing_api/special_route_publisher_test.rb
|
485
|
+
- test/external_link_tracker_test.rb
|
472
486
|
- test/fact_cave_test.rb
|
473
|
-
- test/
|
474
|
-
- test/
|
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
|
487
|
+
- test/need_api_test.rb
|
488
|
+
- test/content_register_test.rb
|
482
489
|
- test/panopticon_test.rb
|
483
|
-
- test/
|
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
|
490
|
+
- test/pp_data_in_test.rb
|
493
491
|
- test/fixtures/hello.txt
|
494
492
|
- test/fixtures/new_policies_for_dwp.json
|
495
|
-
- test/fixtures/world_organisations_australia.json
|
496
493
|
- test/fixtures/no_services_and_info_data_found_fixture.json
|
497
|
-
- test/fixtures/old_policies_for_dwp.json
|
498
494
|
- test/fixtures/services_and_info_fixture.json
|
495
|
+
- test/fixtures/old_policies_for_dwp.json
|
496
|
+
- test/fixtures/world_organisations_australia.json
|
499
497
|
- test/fixtures/sub_sector_organisations.json
|
500
498
|
- 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
499
|
- test/worldwide_api_test.rb
|
506
|
-
- test/
|
507
|
-
- test/
|
508
|
-
- test/
|
500
|
+
- test/test_helpers/publishing_api_test.rb
|
501
|
+
- test/test_helpers/pact_helper.rb
|
502
|
+
- test/test_helpers/panopticon_test.rb
|
503
|
+
- test/test_helpers/email_alert_api_test.rb
|
504
|
+
- test/gov_uk_delivery_test.rb
|
505
|
+
- test/imminence_api_test.rb
|
506
|
+
- test/email_alert_api_test.rb
|
507
|
+
- test/response_test.rb
|
508
|
+
- test/rummager_test.rb
|