gds-api-adapters 38.0.0 → 38.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +5 -5
- data/lib/gds_api/asset_manager.rb +7 -7
- data/lib/gds_api/base.rb +13 -11
- data/lib/gds_api/business_support_api.rb +3 -4
- data/lib/gds_api/content_api.rb +31 -44
- data/lib/gds_api/content_store.rb +2 -3
- data/lib/gds_api/email_alert_api.rb +6 -7
- data/lib/gds_api/exceptions.rb +4 -1
- data/lib/gds_api/gov_uk_delivery.rb +9 -8
- data/lib/gds_api/govuk_headers.rb +1 -1
- data/lib/gds_api/imminence.rb +9 -10
- data/lib/gds_api/json_client.rb +21 -34
- data/lib/gds_api/licence_application.rb +2 -2
- data/lib/gds_api/list_response.rb +7 -10
- data/lib/gds_api/local_links_manager.rb +1 -1
- data/lib/gds_api/mapit.rb +5 -6
- data/lib/gds_api/middleware/govuk_header_sniffer.rb +1 -1
- data/lib/gds_api/need_api.rb +7 -8
- data/lib/gds_api/null_cache.rb +2 -2
- data/lib/gds_api/organisations.rb +2 -2
- data/lib/gds_api/panopticon.rb +11 -11
- data/lib/gds_api/performance_platform/data_in.rb +4 -4
- data/lib/gds_api/performance_platform/data_out.rb +1 -1
- data/lib/gds_api/publishing_api.rb +4 -5
- data/lib/gds_api/publishing_api/special_route_publisher.rb +5 -3
- data/lib/gds_api/publishing_api_v2.rb +8 -16
- data/lib/gds_api/response.rb +2 -5
- data/lib/gds_api/router.rb +18 -9
- data/lib/gds_api/rummager.rb +6 -7
- data/lib/gds_api/support.rb +7 -6
- data/lib/gds_api/support_api.rb +14 -14
- data/lib/gds_api/test_helpers/asset_manager.rb +3 -6
- data/lib/gds_api/test_helpers/business_support_api.rb +4 -4
- data/lib/gds_api/test_helpers/business_support_helper.rb +9 -8
- data/lib/gds_api/test_helpers/common_responses.rb +10 -12
- data/lib/gds_api/test_helpers/content_api.rb +23 -23
- data/lib/gds_api/test_helpers/content_api/artefact_stub.rb +13 -12
- data/lib/gds_api/test_helpers/content_item_helpers.rb +4 -4
- data/lib/gds_api/test_helpers/content_store.rb +3 -3
- data/lib/gds_api/test_helpers/email_alert_api.rb +8 -10
- data/lib/gds_api/test_helpers/gov_uk_delivery.rb +0 -1
- data/lib/gds_api/test_helpers/imminence.rb +4 -4
- data/lib/gds_api/test_helpers/intent_helpers.rb +0 -2
- data/lib/gds_api/test_helpers/local_links_manager.rb +12 -13
- data/lib/gds_api/test_helpers/mapit.rb +14 -15
- data/lib/gds_api/test_helpers/need_api.rb +4 -4
- data/lib/gds_api/test_helpers/organisations.rb +13 -15
- data/lib/gds_api/test_helpers/panopticon.rb +6 -6
- data/lib/gds_api/test_helpers/performance_platform/data_in.rb +8 -8
- data/lib/gds_api/test_helpers/publishing_api.rb +19 -20
- data/lib/gds_api/test_helpers/publishing_api_v2.rb +13 -13
- data/lib/gds_api/test_helpers/router.rb +5 -5
- data/lib/gds_api/test_helpers/rummager.rb +5 -4
- data/lib/gds_api/test_helpers/support.rb +11 -11
- data/lib/gds_api/test_helpers/support_api.rb +14 -14
- data/lib/gds_api/test_helpers/whitehall_admin_api.rb +1 -1
- data/lib/gds_api/test_helpers/worldwide.rb +16 -19
- data/lib/gds_api/version.rb +1 -1
- data/lib/gds_api/worldwide.rb +4 -4
- data/test/asset_manager_test.rb +6 -6
- data/test/business_support_api_test.rb +9 -10
- data/test/content_api_test.rb +81 -83
- data/test/email_alert_api_test.rb +3 -5
- data/test/gds_api_base_test.rb +9 -10
- data/test/gov_uk_delivery_test.rb +4 -6
- data/test/imminence_api_test.rb +7 -9
- data/test/json_client_test.rb +71 -64
- data/test/licence_application_api_test.rb +5 -7
- data/test/list_response_test.rb +27 -32
- data/test/mapit_test.rb +7 -9
- data/test/middleware/govuk_header_sniffer_test.rb +1 -1
- data/test/need_api_test.rb +8 -8
- data/test/organisations_api_test.rb +2 -2
- data/test/panopticon_registerer_test.rb +10 -10
- data/test/panopticon_test.rb +5 -5
- data/test/pp_data_in_test.rb +3 -3
- data/test/publishing_api_test.rb +2 -6
- data/test/publishing_api_v2_test.rb +40 -50
- data/test/response_test.rb +21 -22
- data/test/router_test.rb +78 -80
- data/test/rummager_test.rb +14 -14
- data/test/support_api_test.rb +13 -13
- data/test/support_test.rb +15 -16
- data/test/test_helper.rb +1 -1
- data/test/test_helpers/email_alert_api_test.rb +3 -3
- data/test/test_helpers/pact_helper.rb +1 -1
- data/test/test_helpers/panopticon_test.rb +1 -1
- data/test/test_helpers/publishing_api_test.rb +7 -7
- data/test/test_helpers/publishing_api_v2_test.rb +5 -9
- data/test/worldwide_api_test.rb +3 -3
- metadata +2 -3
- data/lib/gds_api/core-ext/openstruct.rb +0 -5
data/test/rummager_test.rb
CHANGED
@@ -12,28 +12,28 @@ describe GdsApi::Rummager do
|
|
12
12
|
it "#advanced_search should raise an exception if the service at the search URI returns a 500" do
|
13
13
|
stub_request(:get, /example.com\/advanced_search/).to_return(status: [500, "Internal Server Error"])
|
14
14
|
assert_raises(GdsApi::HTTPServerError) do
|
15
|
-
GdsApi::Rummager.new("http://example.com").advanced_search(
|
15
|
+
GdsApi::Rummager.new("http://example.com").advanced_search(keywords: "query")
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
it "#advanced_search should raise an exception if the service at the search URI returns a 404" do
|
20
20
|
stub_request(:get, /example.com\/advanced_search/).to_return(status: [404, "Not Found"])
|
21
21
|
assert_raises(GdsApi::HTTPNotFound) do
|
22
|
-
GdsApi::Rummager.new("http://example.com").advanced_search(
|
22
|
+
GdsApi::Rummager.new("http://example.com").advanced_search(keywords: "query")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
it "#advanced_search should raise an exception if the service at the search URI times out" do
|
27
27
|
stub_request(:get, /example.com\/advanced_search/).to_timeout
|
28
28
|
assert_raises(GdsApi::TimedOutException) do
|
29
|
-
GdsApi::Rummager.new("http://example.com").advanced_search(
|
29
|
+
GdsApi::Rummager.new("http://example.com").advanced_search(keywords: "query")
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
it "#advanced_search should return the search deserialized from json" do
|
34
|
-
search_results = [{"title" => "document-title"}]
|
34
|
+
search_results = [{ "title" => "document-title" }]
|
35
35
|
stub_request(:get, /example.com\/advanced_search/).to_return(body: search_results.to_json)
|
36
|
-
results = GdsApi::Rummager.new("http://example.com").advanced_search(
|
36
|
+
results = GdsApi::Rummager.new("http://example.com").advanced_search(keywords: "query")
|
37
37
|
|
38
38
|
assert_equal search_results, results.to_hash
|
39
39
|
end
|
@@ -46,18 +46,18 @@ describe GdsApi::Rummager do
|
|
46
46
|
|
47
47
|
it "#advanced_search should return an empty set of results without making request if arguments is nil" do
|
48
48
|
assert_raises(ArgumentError) do
|
49
|
-
|
49
|
+
GdsApi::Rummager.new("http://example.com").advanced_search(nil)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
it "#advanced_search should request the search results in JSON format" do
|
54
|
-
GdsApi::Rummager.new("http://example.com").advanced_search(
|
54
|
+
GdsApi::Rummager.new("http://example.com").advanced_search(keywords: "query")
|
55
55
|
|
56
|
-
assert_requested :get, /.*/, headers: {"Accept" => "application/json"}
|
56
|
+
assert_requested :get, /.*/, headers: { "Accept" => "application/json" }
|
57
57
|
end
|
58
58
|
|
59
59
|
it "#advanced_search should issue a request for all the params supplied" do
|
60
|
-
GdsApi::Rummager.new("http://example.com").advanced_search(
|
60
|
+
GdsApi::Rummager.new("http://example.com").advanced_search(keywords: "query & stuff", topics: %w(1 2), order: { public_timestamp: "desc" })
|
61
61
|
|
62
62
|
assert_requested :get, /keywords=query%20%26%20stuff/
|
63
63
|
assert_requested :get, /topics\[\]=1&topics\[\]=2/
|
@@ -83,7 +83,7 @@ describe GdsApi::Rummager do
|
|
83
83
|
it "#search should raise an exception if the service at the search URI returns a 400" do
|
84
84
|
stub_request(:get, /example.com\/search/).to_return(
|
85
85
|
status: [400, "Bad Request"],
|
86
|
-
body:
|
86
|
+
body: '"error":"Filtering by \"coffee\" is not allowed"',
|
87
87
|
)
|
88
88
|
assert_raises(GdsApi::HTTPClientError) do
|
89
89
|
GdsApi::Rummager.new("http://example.com").search(q: "query", filter_coffee: "tea")
|
@@ -93,7 +93,7 @@ describe GdsApi::Rummager do
|
|
93
93
|
it "#search should raise an exception if the service at the search URI returns a 422" do
|
94
94
|
stub_request(:get, /example.com\/search/).to_return(
|
95
95
|
status: [422, "Bad Request"],
|
96
|
-
body:
|
96
|
+
body: '"error":"Filtering by \"coffee\" is not allowed"',
|
97
97
|
)
|
98
98
|
assert_raises(GdsApi::HTTPClientError) do
|
99
99
|
GdsApi::Rummager.new("http://example.com").search(q: "query", filter_coffee: "tea")
|
@@ -108,7 +108,7 @@ describe GdsApi::Rummager do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
it "#search should return the search deserialized from json" do
|
111
|
-
search_results = [{"title" => "document-title"}]
|
111
|
+
search_results = [{ "title" => "document-title" }]
|
112
112
|
stub_request(:get, /example.com\/search/).to_return(body: search_results.to_json)
|
113
113
|
results = GdsApi::Rummager.new("http://example.com").search(q: "query")
|
114
114
|
assert_equal search_results, results.to_hash
|
@@ -117,13 +117,13 @@ describe GdsApi::Rummager do
|
|
117
117
|
it "#search should request the search results in JSON format" do
|
118
118
|
GdsApi::Rummager.new("http://example.com").search(q: "query")
|
119
119
|
|
120
|
-
assert_requested :get, /.*/, headers: {"Accept" => "application/json"}
|
120
|
+
assert_requested :get, /.*/, headers: { "Accept" => "application/json" }
|
121
121
|
end
|
122
122
|
|
123
123
|
it "#search should issue a request for all the params supplied" do
|
124
124
|
GdsApi::Rummager.new("http://example.com").search(
|
125
125
|
q: "query & stuff",
|
126
|
-
filter_topics:
|
126
|
+
filter_topics: %w(1 2),
|
127
127
|
order: "-public_timestamp",
|
128
128
|
)
|
129
129
|
|
data/test/support_api_test.rb
CHANGED
@@ -11,11 +11,11 @@ describe GdsApi::SupportApi do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "can report a problem" do
|
14
|
-
request_details = {certain: "details"}
|
14
|
+
request_details = { certain: "details" }
|
15
15
|
|
16
16
|
stub_post = stub_request(:post, "#{@base_api_url}/anonymous-feedback/problem-reports").
|
17
|
-
with(:
|
18
|
-
to_return(:
|
17
|
+
with(body: { "problem_report" => request_details }.to_json).
|
18
|
+
to_return(status: 201)
|
19
19
|
|
20
20
|
@api.create_problem_report(request_details)
|
21
21
|
|
@@ -23,11 +23,11 @@ describe GdsApi::SupportApi do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "can pass service feedback" do
|
26
|
-
request_details = {"transaction-completed-values"=>"1", "details"=>"abc"}
|
26
|
+
request_details = { "transaction-completed-values" => "1", "details" => "abc" }
|
27
27
|
|
28
28
|
stub_post = stub_request(:post, "#{@base_api_url}/anonymous-feedback/service-feedback").
|
29
|
-
with(:
|
30
|
-
to_return(:
|
29
|
+
with(body: { "service_feedback" => request_details }.to_json).
|
30
|
+
to_return(status: 201)
|
31
31
|
|
32
32
|
@api.create_service_feedback(request_details)
|
33
33
|
|
@@ -35,11 +35,11 @@ describe GdsApi::SupportApi do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it "can submit long-form anonymous feedback" do
|
38
|
-
request_details = {certain: "details"}
|
38
|
+
request_details = { certain: "details" }
|
39
39
|
|
40
40
|
stub_post = stub_request(:post, "#{@base_api_url}/anonymous-feedback/long-form-contacts").
|
41
|
-
with(:
|
42
|
-
to_return(:
|
41
|
+
with(body: { "long_form_contact" => request_details }.to_json).
|
42
|
+
to_return(status: 201)
|
43
43
|
|
44
44
|
@api.create_anonymous_long_form_contact(request_details)
|
45
45
|
|
@@ -47,10 +47,10 @@ describe GdsApi::SupportApi do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it "fetches problem report daily totals" do
|
50
|
-
response_body = {"data" => ["results"]}
|
50
|
+
response_body = { "data" => ["results"] }
|
51
51
|
|
52
52
|
stub_get = stub_request(:get, "#{@base_api_url}/anonymous-feedback/problem-reports/2014-07-12/totals").
|
53
|
-
to_return(:
|
53
|
+
to_return(status: 200, body: response_body.to_json)
|
54
54
|
|
55
55
|
result = @api.problem_report_daily_totals_for(Date.new(2014, 7, 12))
|
56
56
|
|
@@ -115,7 +115,7 @@ describe GdsApi::SupportApi do
|
|
115
115
|
|
116
116
|
describe "POST /anonymous-feedback/global-export-requests" do
|
117
117
|
it "makes a POST request to the support API" do
|
118
|
-
params = {from_date: "1 June 2016", to_date: "8 June 2016", notification_email: "foo@example.com"}
|
118
|
+
params = { from_date: "1 June 2016", to_date: "8 June 2016", notification_email: "foo@example.com" }
|
119
119
|
stub_post = stub_support_global_export_request_creation(params)
|
120
120
|
|
121
121
|
@api.create_global_export_request(params)
|
@@ -125,7 +125,7 @@ describe GdsApi::SupportApi do
|
|
125
125
|
|
126
126
|
describe "POST /page-improvements" do
|
127
127
|
it "makes a POST request to the support API" do
|
128
|
-
params = {description: "The title could be better."}
|
128
|
+
params = { description: "The title could be better." }
|
129
129
|
stub_post = stub_create_page_improvement(params)
|
130
130
|
|
131
131
|
@api.create_page_improvement(params)
|
data/test/support_test.rb
CHANGED
@@ -11,11 +11,11 @@ describe GdsApi::Support do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "can create an FOI request" do
|
14
|
-
request_details = {"foi_request"=>{"requester"=>{"name"=>"A", "email"=>"a@b.com"}, "details"=>"abc"}}
|
14
|
+
request_details = { "foi_request" => { "requester" => { "name" => "A", "email" => "a@b.com" }, "details" => "abc" } }
|
15
15
|
|
16
16
|
stub_post = stub_request(:post, "#{@base_api_url}/foi_requests").
|
17
|
-
with(:
|
18
|
-
to_return(:
|
17
|
+
with(body: { "foi_request" => request_details }.to_json).
|
18
|
+
to_return(status: 201)
|
19
19
|
|
20
20
|
@api.create_foi_request(request_details)
|
21
21
|
|
@@ -29,11 +29,11 @@ describe GdsApi::Support do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "can report a problem" do
|
32
|
-
request_details = {certain: "details"}
|
32
|
+
request_details = { certain: "details" }
|
33
33
|
|
34
34
|
stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/problem_reports").
|
35
|
-
with(:
|
36
|
-
to_return(:
|
35
|
+
with(body: { "problem_report" => request_details }.to_json).
|
36
|
+
to_return(status: 201)
|
37
37
|
|
38
38
|
@api.create_problem_report(request_details)
|
39
39
|
|
@@ -41,11 +41,11 @@ describe GdsApi::Support do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it "can submit long-form anonymous feedback" do
|
44
|
-
request_details = {certain: "details"}
|
44
|
+
request_details = { certain: "details" }
|
45
45
|
|
46
46
|
stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/long_form_contacts").
|
47
|
-
with(:
|
48
|
-
to_return(:
|
47
|
+
with(body: { "long_form_contact" => request_details }.to_json).
|
48
|
+
to_return(status: 201)
|
49
49
|
|
50
50
|
@api.create_anonymous_long_form_contact(request_details)
|
51
51
|
|
@@ -53,11 +53,11 @@ describe GdsApi::Support do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "can create a named contact" do
|
56
|
-
request_details = {certain: "details"}
|
56
|
+
request_details = { certain: "details" }
|
57
57
|
|
58
58
|
stub_post = stub_request(:post, "#{@base_api_url}/named_contacts").
|
59
|
-
with(:
|
60
|
-
to_return(:
|
59
|
+
with(body: { "named_contact" => request_details }.to_json).
|
60
|
+
to_return(status: 201)
|
61
61
|
|
62
62
|
@api.create_named_contact(request_details)
|
63
63
|
|
@@ -71,11 +71,11 @@ describe GdsApi::Support do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
it "can pass service feedback" do
|
74
|
-
request_details = {"transaction-completed-values"=>"1", "details"=>"abc"}
|
74
|
+
request_details = { "transaction-completed-values" => "1", "details" => "abc" }
|
75
75
|
|
76
76
|
stub_post = stub_request(:post, "#{@base_api_url}/anonymous_feedback/service_feedback").
|
77
|
-
with(:
|
78
|
-
to_return(:
|
77
|
+
with(body: { "service_feedback" => request_details }.to_json).
|
78
|
+
to_return(status: 201)
|
79
79
|
|
80
80
|
@api.create_service_feedback(request_details)
|
81
81
|
|
@@ -91,6 +91,5 @@ describe GdsApi::Support do
|
|
91
91
|
it "gets the correct feedback URL" do
|
92
92
|
assert_equal("#{@base_api_url}/anonymous_feedback?path=foo",
|
93
93
|
@api.feedback_url('foo'))
|
94
|
-
|
95
94
|
end
|
96
95
|
end
|
data/test/test_helper.rb
CHANGED
@@ -45,7 +45,7 @@ module PactTest
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def load_fixture_file(filename)
|
48
|
-
File.open(
|
48
|
+
File.open(File.join(File.dirname(__FILE__), "fixtures", filename), encoding: 'utf-8')
|
49
49
|
end
|
50
50
|
|
51
51
|
require 'webmock/minitest'
|
@@ -12,13 +12,13 @@ describe GdsApi::TestHelpers::EmailAlertApi do
|
|
12
12
|
before { stub_any_email_alert_api_call }
|
13
13
|
|
14
14
|
it "matches a post request with any empty attributes by default" do
|
15
|
-
email_alert_api.send_alert(
|
15
|
+
email_alert_api.send_alert("foo" => "bar")
|
16
16
|
assert_email_alert_sent
|
17
17
|
end
|
18
18
|
|
19
19
|
it "matches a post request subset of attributes" do
|
20
|
-
email_alert_api.send_alert(
|
21
|
-
assert_email_alert_sent(
|
20
|
+
email_alert_api.send_alert("foo" => "bar", "baz" => "qux")
|
21
|
+
assert_email_alert_sent("foo" => "bar")
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -10,7 +10,7 @@ describe GdsApi::TestHelpers::Panopticon do
|
|
10
10
|
|
11
11
|
assert(
|
12
12
|
WebMock::StubRegistry.instance.registered_request?(expected_signature),
|
13
|
-
"Stub is not registered:\n\t#{expected_signature
|
13
|
+
"Stub is not registered:\n\t#{expected_signature}"
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
@@ -9,7 +9,7 @@ describe GdsApi::TestHelpers::PublishingApi do
|
|
9
9
|
|
10
10
|
describe '#request_json_matching predicate' do
|
11
11
|
describe "nested required attribute" do
|
12
|
-
let(:matcher) { request_json_matching(
|
12
|
+
let(:matcher) { request_json_matching("a" => { "b" => 1 }) }
|
13
13
|
|
14
14
|
it "matches a body with exact same nested hash strucure" do
|
15
15
|
assert matcher.call(stub("request", body: '{"a": {"b": 1}}'))
|
@@ -33,7 +33,7 @@ describe GdsApi::TestHelpers::PublishingApi do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
describe "hash to match uses symbol keys" do
|
36
|
-
let(:matcher) { request_json_matching(
|
36
|
+
let(:matcher) { request_json_matching(a: 1) }
|
37
37
|
|
38
38
|
it "matches a json body" do
|
39
39
|
assert matcher.call(stub("request", body: '{"a": 1}'))
|
@@ -55,7 +55,7 @@ describe GdsApi::TestHelpers::PublishingApi do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
describe "one required attribute" do
|
58
|
-
let(:matcher) { request_json_including(
|
58
|
+
let(:matcher) { request_json_including("a" => 1) }
|
59
59
|
|
60
60
|
it "does not match an empty body" do
|
61
61
|
refute matcher.call(stub("request", body: "{}"))
|
@@ -75,7 +75,7 @@ describe GdsApi::TestHelpers::PublishingApi do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
describe "nested required attribute" do
|
78
|
-
let(:matcher) { request_json_including(
|
78
|
+
let(:matcher) { request_json_including("a" => { "b" => 1 }) }
|
79
79
|
|
80
80
|
it "matches a body with exact same nested hash strucure" do
|
81
81
|
assert matcher.call(stub("request", body: '{"a": {"b": 1}}'))
|
@@ -95,7 +95,7 @@ describe GdsApi::TestHelpers::PublishingApi do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
describe "hash to match uses symbol keys" do
|
98
|
-
let(:matcher) { request_json_including(
|
98
|
+
let(:matcher) { request_json_including(a: { b: 1 }) }
|
99
99
|
|
100
100
|
it "matches a json body" do
|
101
101
|
assert matcher.call(stub("request", body: '{"a": {"b": 1}}'))
|
@@ -103,7 +103,7 @@ describe GdsApi::TestHelpers::PublishingApi do
|
|
103
103
|
end
|
104
104
|
|
105
105
|
describe "nested arrays" do
|
106
|
-
let(:matcher) { request_json_including(
|
106
|
+
let(:matcher) { request_json_including("a" => [1]) }
|
107
107
|
|
108
108
|
it "matches a body with exact same inner array" do
|
109
109
|
assert matcher.call(stub("request", body: '{"a": [1]}'))
|
@@ -115,7 +115,7 @@ describe GdsApi::TestHelpers::PublishingApi do
|
|
115
115
|
end
|
116
116
|
|
117
117
|
describe "hashes in nested arrays" do
|
118
|
-
let(:matcher) { request_json_including(
|
118
|
+
let(:matcher) { request_json_including("a" => [{ "b" => 1 }, 2]) }
|
119
119
|
|
120
120
|
it "matches a body with exact same inner array" do
|
121
121
|
assert matcher.call(stub("request", body: '{"a": [{"b": 1}, 2]}'))
|
@@ -45,7 +45,7 @@ describe GdsApi::TestHelpers::PublishingApiV2 do
|
|
45
45
|
|
46
46
|
describe "#publishing_api_has_content" do
|
47
47
|
it "stubs the call to get content items" do
|
48
|
-
publishing_api_has_content([{"content_id" => "2878337b-bed9-4e7f-85b6-10ed2cbcd504"}])
|
48
|
+
publishing_api_has_content([{ "content_id" => "2878337b-bed9-4e7f-85b6-10ed2cbcd504" }])
|
49
49
|
|
50
50
|
response = publishing_api.get_content_items({})['results']
|
51
51
|
|
@@ -83,13 +83,11 @@ describe GdsApi::TestHelpers::PublishingApiV2 do
|
|
83
83
|
{ "content_id" => content_id_2 },
|
84
84
|
{ "content_id" => content_id_3 },
|
85
85
|
],
|
86
|
-
|
87
|
-
page: 1,
|
86
|
+
page: 1,
|
88
87
|
per_page: 2
|
89
|
-
}
|
90
88
|
)
|
91
89
|
|
92
|
-
response = publishing_api.get_content_items(
|
90
|
+
response = publishing_api.get_content_items(page: 1, per_page: 2)
|
93
91
|
records = response['results']
|
94
92
|
|
95
93
|
assert_equal(response['total'], 3)
|
@@ -110,13 +108,11 @@ describe GdsApi::TestHelpers::PublishingApiV2 do
|
|
110
108
|
{ "content_id" => content_id_1 },
|
111
109
|
{ "content_id" => content_id_2 },
|
112
110
|
],
|
113
|
-
|
114
|
-
page: 10,
|
111
|
+
page: 10,
|
115
112
|
per_page: 2
|
116
|
-
}
|
117
113
|
)
|
118
114
|
|
119
|
-
response = publishing_api.get_content_items(
|
115
|
+
response = publishing_api.get_content_items(page: 10, per_page: 2)
|
120
116
|
records = response['results']
|
121
117
|
|
122
118
|
assert_equal(records, [])
|
data/test/worldwide_api_test.rb
CHANGED
@@ -21,7 +21,7 @@ describe GdsApi::Worldwide do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should handle the pagination" do
|
24
|
-
country_slugs = (1..50).map {|n| "country-#{n}" }
|
24
|
+
country_slugs = (1..50).map { |n| "country-#{n}" }
|
25
25
|
worldwide_api_has_locations(country_slugs)
|
26
26
|
|
27
27
|
response = @api.world_locations
|
@@ -32,7 +32,7 @@ describe GdsApi::Worldwide do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should raise error if endpoint 404s" do
|
35
|
-
stub_request(:get, "#{@base_api_url}/api/world-locations").to_return(:
|
35
|
+
stub_request(:get, "#{@base_api_url}/api/world-locations").to_return(status: 404)
|
36
36
|
assert_raises GdsApi::HTTPNotFound do
|
37
37
|
@api.world_locations
|
38
38
|
end
|
@@ -73,7 +73,7 @@ describe GdsApi::Worldwide do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should raise error on 404" do
|
76
|
-
stub_request(:get, "#{@base_api_url}/api/world-locations/non-existent/organisations").to_return(:
|
76
|
+
stub_request(:get, "#{@base_api_url}/api/world-locations/non-existent/organisations").to_return(status: 404)
|
77
77
|
assert_raises GdsApi::HTTPNotFound do
|
78
78
|
@api.organisations_for_world_location('non-existent')
|
79
79
|
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: 38.
|
4
|
+
version: 38.1.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-12-
|
11
|
+
date: 2016-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plek
|
@@ -347,7 +347,6 @@ files:
|
|
347
347
|
- lib/gds_api/business_support_api.rb
|
348
348
|
- lib/gds_api/content_api.rb
|
349
349
|
- lib/gds_api/content_store.rb
|
350
|
-
- lib/gds_api/core-ext/openstruct.rb
|
351
350
|
- lib/gds_api/email_alert_api.rb
|
352
351
|
- lib/gds_api/exceptions.rb
|
353
352
|
- lib/gds_api/gov_uk_delivery.rb
|