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
@@ -20,8 +20,8 @@ class LicenceApplicationApiTest < Minitest::Test
|
|
20
20
|
def test_should_return_list_of_licences
|
21
21
|
stub_request(:get, "#{@core_url}/api/licences").
|
22
22
|
with(headers: GdsApi::JsonClient.default_request_headers).
|
23
|
-
to_return(:
|
24
|
-
:
|
23
|
+
to_return(status: 200,
|
24
|
+
body: <<-EOS
|
25
25
|
[
|
26
26
|
{
|
27
27
|
"code":"1324-5-1",
|
@@ -81,11 +81,11 @@ EOS
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_should_provide_full_licence_details_for_canonical_id
|
84
|
-
licence_exists('590001',
|
84
|
+
licence_exists('590001', "isLocationSpecific" => true, "geographicalAvailability" => %w(England Wales), "issuingAuthorities" => [])
|
85
85
|
|
86
86
|
expected = {
|
87
87
|
"isLocationSpecific" => true,
|
88
|
-
"geographicalAvailability" =>
|
88
|
+
"geographicalAvailability" => %w(England Wales),
|
89
89
|
"issuingAuthorities" => []
|
90
90
|
}
|
91
91
|
|
@@ -172,12 +172,10 @@ EOS
|
|
172
172
|
|
173
173
|
assert_equal true, response["isLocationSpecific"]
|
174
174
|
|
175
|
-
assert_includes response["issuingAuthorities"][0]["authorityInteractions"]["apply"],
|
176
|
-
"url" => "https://www.gov.uk/motor-salvage-operator-registration/city-of-london/apply-1",
|
175
|
+
assert_includes response["issuingAuthorities"][0]["authorityInteractions"]["apply"], "url" => "https://www.gov.uk/motor-salvage-operator-registration/city-of-london/apply-1",
|
177
176
|
"usesLicensify" => true,
|
178
177
|
"description" => "Application to register as a motor salvage operator",
|
179
178
|
"payment" => "none"
|
180
|
-
}
|
181
179
|
end
|
182
180
|
|
183
181
|
def test_should_raise_exception_on_timeout
|
data/test/list_response_test.rb
CHANGED
@@ -2,24 +2,19 @@ require_relative 'test_helper'
|
|
2
2
|
require 'gds_api/list_response'
|
3
3
|
|
4
4
|
describe GdsApi::ListResponse do
|
5
|
-
|
6
5
|
describe "accessing results" do
|
7
6
|
before :each do
|
8
7
|
end
|
9
8
|
|
10
9
|
it "should allow Enumerable access to the results array" do
|
11
10
|
data = {
|
12
|
-
"results" =>
|
13
|
-
"foo",
|
14
|
-
"bar",
|
15
|
-
"baz",
|
16
|
-
],
|
11
|
+
"results" => %w(foo bar baz),
|
17
12
|
"total" => 3,
|
18
13
|
"_response_info" => {
|
19
14
|
"status" => "ok",
|
20
15
|
}
|
21
16
|
}
|
22
|
-
response = GdsApi::ListResponse.new(stub(:
|
17
|
+
response = GdsApi::ListResponse.new(stub(body: data.to_json), nil)
|
23
18
|
|
24
19
|
assert_equal "foo", response.first
|
25
20
|
assert_equal %w(foo bar baz), response.to_a
|
@@ -34,7 +29,7 @@ describe GdsApi::ListResponse do
|
|
34
29
|
"status" => "ok",
|
35
30
|
}
|
36
31
|
}
|
37
|
-
response = GdsApi::ListResponse.new(stub(:
|
32
|
+
response = GdsApi::ListResponse.new(stub(body: data.to_json), nil)
|
38
33
|
|
39
34
|
assert_equal [], response.to_a
|
40
35
|
assert ! response.any?
|
@@ -44,39 +39,39 @@ describe GdsApi::ListResponse do
|
|
44
39
|
describe "handling pagination" do
|
45
40
|
before :each do
|
46
41
|
page_1 = {
|
47
|
-
"results" =>
|
42
|
+
"results" => %w(foo1 bar1),
|
48
43
|
"total" => 6,
|
49
44
|
"current_page" => 1, "pages" => 3, "page_size" => 2,
|
50
45
|
"_response_info" => {
|
51
46
|
"status" => "ok",
|
52
47
|
"links" => [
|
53
|
-
{"href" => "http://www.example.com/2", "rel" => "next"},
|
54
|
-
{"href" => "http://www.example.com/1", "rel" => "self"},
|
48
|
+
{ "href" => "http://www.example.com/2", "rel" => "next" },
|
49
|
+
{ "href" => "http://www.example.com/1", "rel" => "self" },
|
55
50
|
]
|
56
51
|
}
|
57
52
|
}
|
58
53
|
page_2 = {
|
59
|
-
"results" =>
|
54
|
+
"results" => %w(foo2 bar2),
|
60
55
|
"total" => 6,
|
61
56
|
"current_page" => 2, "pages" => 3, "page_size" => 2,
|
62
57
|
"_response_info" => {
|
63
58
|
"status" => "ok",
|
64
59
|
"links" => [
|
65
|
-
{"href" => "http://www.example.com/1", "rel" => "previous"},
|
66
|
-
{"href" => "http://www.example.com/3", "rel" => "next"},
|
67
|
-
{"href" => "http://www.example.com/2", "rel" => "self"},
|
60
|
+
{ "href" => "http://www.example.com/1", "rel" => "previous" },
|
61
|
+
{ "href" => "http://www.example.com/3", "rel" => "next" },
|
62
|
+
{ "href" => "http://www.example.com/2", "rel" => "self" },
|
68
63
|
]
|
69
64
|
}
|
70
65
|
}
|
71
66
|
page_3 = {
|
72
|
-
"results" =>
|
67
|
+
"results" => %w(foo3 bar3),
|
73
68
|
"total" => 6,
|
74
69
|
"current_page" => 3, "pages" => 3, "page_size" => 2,
|
75
70
|
"_response_info" => {
|
76
71
|
"status" => "ok",
|
77
72
|
"links" => [
|
78
|
-
{"href" => "http://www.example.com/2", "rel" => "previous"},
|
79
|
-
{"href" => "http://www.example.com/3", "rel" => "self"},
|
73
|
+
{ "href" => "http://www.example.com/2", "rel" => "previous" },
|
74
|
+
{ "href" => "http://www.example.com/3", "rel" => "self" },
|
80
75
|
]
|
81
76
|
}
|
82
77
|
}
|
@@ -102,10 +97,10 @@ describe GdsApi::ListResponse do
|
|
102
97
|
}
|
103
98
|
)
|
104
99
|
|
105
|
-
@client = stub
|
106
|
-
@client.stubs(:get_list
|
107
|
-
@client.stubs(:get_list
|
108
|
-
@client.stubs(:get_list
|
100
|
+
@client = stub
|
101
|
+
@client.stubs(:get_list).with("http://www.example.com/1").returns(GdsApi::ListResponse.new(@p1_response, @client))
|
102
|
+
@client.stubs(:get_list).with("http://www.example.com/2").returns(GdsApi::ListResponse.new(@p2_response, @client))
|
103
|
+
@client.stubs(:get_list).with("http://www.example.com/3").returns(GdsApi::ListResponse.new(@p3_response, @client))
|
109
104
|
end
|
110
105
|
|
111
106
|
describe "accessing next page" do
|
@@ -125,8 +120,8 @@ describe GdsApi::ListResponse do
|
|
125
120
|
resp = GdsApi::ListResponse.new(@p1_response, @client)
|
126
121
|
first_call = resp.next_page
|
127
122
|
|
128
|
-
@client.unstub(:get_list
|
129
|
-
@client.expects(:get_list
|
123
|
+
@client.unstub(:get_list) # Necessary because of https://github.com/freerange/mocha/issues/44
|
124
|
+
@client.expects(:get_list).never
|
130
125
|
second_call = resp.next_page
|
131
126
|
assert_equal first_call, second_call
|
132
127
|
end
|
@@ -149,8 +144,8 @@ describe GdsApi::ListResponse do
|
|
149
144
|
resp = GdsApi::ListResponse.new(@p3_response, @client)
|
150
145
|
first_call = resp.previous_page
|
151
146
|
|
152
|
-
@client.unstub(:get_list
|
153
|
-
@client.expects(:get_list
|
147
|
+
@client.unstub(:get_list) # Necessary because of https://github.com/freerange/mocha/issues/44
|
148
|
+
@client.expects(:get_list).never
|
154
149
|
second_call = resp.previous_page
|
155
150
|
assert_equal first_call, second_call
|
156
151
|
end
|
@@ -164,13 +159,13 @@ describe GdsApi::ListResponse do
|
|
164
159
|
it "should allow iteration across multiple pages" do
|
165
160
|
assert_equal 6, @response.with_subsequent_pages.count
|
166
161
|
assert_equal %w(foo1 bar1 foo2 bar2 foo3 bar3), @response.with_subsequent_pages.to_a
|
167
|
-
assert_equal %w(foo1 foo2 foo3), @response.with_subsequent_pages.select {|s| s =~ /foo/}
|
162
|
+
assert_equal %w(foo1 foo2 foo3), @response.with_subsequent_pages.select { |s| s =~ /foo/ }
|
168
163
|
end
|
169
164
|
|
170
165
|
it "should not load a page multiple times" do
|
171
|
-
@client.unstub(:get_list
|
172
|
-
@client.expects(:get_list
|
173
|
-
@client.expects(:get_list
|
166
|
+
@client.unstub(:get_list) # Necessary because of https://github.com/freerange/mocha/issues/44
|
167
|
+
@client.expects(:get_list).with("http://www.example.com/2").once.returns(GdsApi::ListResponse.new(@p2_response, @client))
|
168
|
+
@client.expects(:get_list).with("http://www.example.com/3").once.returns(GdsApi::ListResponse.new(@p3_response, @client))
|
174
169
|
|
175
170
|
3.times do
|
176
171
|
@response.with_subsequent_pages.to_a
|
@@ -179,13 +174,13 @@ describe GdsApi::ListResponse do
|
|
179
174
|
|
180
175
|
it "should work with a non-paginated response" do
|
181
176
|
data = {
|
182
|
-
"results" =>
|
177
|
+
"results" => %w(foo1 bar1),
|
183
178
|
"total" => 2,
|
184
179
|
"_response_info" => {
|
185
180
|
"status" => "ok",
|
186
181
|
}
|
187
182
|
}
|
188
|
-
response = GdsApi::ListResponse.new(stub(:
|
183
|
+
response = GdsApi::ListResponse.new(stub(body: data.to_json, status: 200, headers: {}), nil)
|
189
184
|
|
190
185
|
assert_equal %w(foo1 bar1), response.with_subsequent_pages.to_a
|
191
186
|
end
|
data/test/mapit_test.rb
CHANGED
@@ -12,22 +12,22 @@ describe GdsApi::Mapit do
|
|
12
12
|
|
13
13
|
describe "postcodes" do
|
14
14
|
it "should return the coordinates" do
|
15
|
-
mapit_has_a_postcode("SW1A 1AA", [
|
15
|
+
mapit_has_a_postcode("SW1A 1AA", [51.5010096, -0.1415870])
|
16
16
|
|
17
17
|
response = @api.location_for_postcode("SW1A 1AA")
|
18
18
|
assert_equal 51.5010096, response.lat
|
19
|
-
assert_equal
|
19
|
+
assert_equal(-0.1415870, response.lon)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should return the postcode" do
|
23
|
-
mapit_has_a_postcode("SW1A 1AA", [
|
23
|
+
mapit_has_a_postcode("SW1A 1AA", [51.5010096, -0.1415870])
|
24
24
|
|
25
25
|
response = @api.location_for_postcode("SW1A 1AA")
|
26
26
|
assert_equal "SW1A 1AA", response.postcode
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should return areas" do
|
30
|
-
mapit_has_a_postcode_and_areas("SW1A 1AA", [
|
30
|
+
mapit_has_a_postcode_and_areas("SW1A 1AA", [51.5010096, -0.1415870], [
|
31
31
|
{ 'name' => 'Lancashire County Council', 'type' => 'CTY', 'ons' => '30', 'gss' => 'E10000017' },
|
32
32
|
{ 'name' => 'South Ribble Borough Council', 'type' => 'DIS', 'ons' => '30UN', 'gss' => 'E07000126' }
|
33
33
|
])
|
@@ -64,11 +64,9 @@ describe GdsApi::Mapit do
|
|
64
64
|
|
65
65
|
describe "areas_for_type" do
|
66
66
|
before do
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
"345" => { "name" => "Scotland", "id" => "345", "country_name" => "Scotland" }
|
71
|
-
})
|
67
|
+
mapit_has_areas('EUR', "123" => { "name" => "Eastern", "id" => "123", "country_name" => "England" },
|
68
|
+
"234" => { "name" => "North West", "id" => "234", "country_name" => "England" },
|
69
|
+
"345" => { "name" => "Scotland", "id" => "345", "country_name" => "Scotland" })
|
72
70
|
mapit_does_not_have_areas('FOO')
|
73
71
|
end
|
74
72
|
it "should return areas of a type" do
|
@@ -5,7 +5,7 @@ describe GdsApi::GovukHeaderSniffer do
|
|
5
5
|
include Rack::Test::Methods
|
6
6
|
|
7
7
|
let(:inner_app) do
|
8
|
-
lambda { |
|
8
|
+
lambda { |_env| [200, { 'Content-Type' => 'text/plain' }, ['All good!']] }
|
9
9
|
end
|
10
10
|
|
11
11
|
let(:app) { GdsApi::GovukHeaderSniffer.new(inner_app, 'HTTP_GOVUK_REQUEST_ID') }
|
data/test/need_api_test.rb
CHANGED
@@ -35,7 +35,7 @@ describe GdsApi::NeedApi do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it "returns a list of needs matching the IDs" do
|
38
|
-
needs = @api.needs_by_id(1,2,3)
|
38
|
+
needs = @api.needs_by_id(1, 2, 3)
|
39
39
|
|
40
40
|
assert_equal 3, needs.count
|
41
41
|
assert_equal %w(1 2 3), needs.map { |need| need['id'] }
|
@@ -45,7 +45,7 @@ describe GdsApi::NeedApi do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it "makes the same request regardless of the order of the IDs" do
|
48
|
-
needs = @api.needs_by_id(2,1,3)
|
48
|
+
needs = @api.needs_by_id(2, 1, 3)
|
49
49
|
|
50
50
|
assert_equal 3, needs.count
|
51
51
|
assert_equal %w(1 2 3), needs.map { |need| need['id'] }
|
@@ -139,9 +139,9 @@ describe GdsApi::NeedApi do
|
|
139
139
|
describe "creating needs" do
|
140
140
|
it "should post to the right endpoint" do
|
141
141
|
request_stub = stub_request(:post, @base_api_url + "/needs").with(
|
142
|
-
:
|
142
|
+
body: '{"goal":"I wanna sammich!"}'
|
143
143
|
)
|
144
|
-
@api.create_need(
|
144
|
+
@api.create_need("goal" => "I wanna sammich!")
|
145
145
|
assert_requested(request_stub)
|
146
146
|
end
|
147
147
|
end
|
@@ -278,10 +278,10 @@ describe GdsApi::NeedApi do
|
|
278
278
|
|
279
279
|
it "should return organisations with abbreviations if present" do
|
280
280
|
request_stub = need_api_has_organisations(
|
281
|
-
"committee-on-climate-change" => {"name" => "Committee on Climate Change",
|
282
|
-
"abbreviation" => "CCC"},
|
283
|
-
"competition-commission" => {"name" => "Competition Commission",
|
284
|
-
"abbreviation" => "CC"}
|
281
|
+
"committee-on-climate-change" => { "name" => "Committee on Climate Change",
|
282
|
+
"abbreviation" => "CCC" },
|
283
|
+
"competition-commission" => { "name" => "Competition Commission",
|
284
|
+
"abbreviation" => "CC" }
|
285
285
|
)
|
286
286
|
orgs = @api.organisations
|
287
287
|
|
@@ -21,7 +21,7 @@ describe GdsApi::Organisations do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should handle the pagination" do
|
24
|
-
organisation_slugs = (1..50).map {|n| "organisation-#{n}" }
|
24
|
+
organisation_slugs = (1..50).map { |n| "organisation-#{n}" }
|
25
25
|
organisations_api_has_organisations(organisation_slugs)
|
26
26
|
|
27
27
|
response = @api.organisations
|
@@ -32,7 +32,7 @@ describe GdsApi::Organisations do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should raise error if endpoint 404s" do
|
35
|
-
stub_request(:get, "#{@base_api_url}/api/organisations").to_return(:
|
35
|
+
stub_request(:get, "#{@base_api_url}/api/organisations").to_return(status: 404)
|
36
36
|
assert_raises GdsApi::HTTPNotFound do
|
37
37
|
@api.organisations
|
38
38
|
end
|
@@ -11,7 +11,7 @@ describe GdsApi::Panopticon::Registerer do
|
|
11
11
|
it "should create an instance using the current Plek environment as the platform by default" do
|
12
12
|
Plek.stubs(:current).returns(stub(find: "http://thisplace"))
|
13
13
|
|
14
|
-
GdsApi::Panopticon.expects(:new).with("http://thisplace", anything
|
14
|
+
GdsApi::Panopticon.expects(:new).with("http://thisplace", anything).returns(:panopticon_instance)
|
15
15
|
r = GdsApi::Panopticon::Registerer.new({})
|
16
16
|
assert_equal :panopticon_instance, r.send(:panopticon)
|
17
17
|
end
|
@@ -19,28 +19,28 @@ describe GdsApi::Panopticon::Registerer do
|
|
19
19
|
it "should pass through the endpoint url" do
|
20
20
|
Plek.stubs(:current).returns(stub(find: "http://thisplace"))
|
21
21
|
|
22
|
-
GdsApi::Panopticon.expects(:new).with("http://otherplace", anything
|
23
|
-
r = GdsApi::Panopticon::Registerer.new(
|
22
|
+
GdsApi::Panopticon.expects(:new).with("http://otherplace", anything).returns(:panopticon_instance)
|
23
|
+
r = GdsApi::Panopticon::Registerer.new(endpoint_url: "http://otherplace")
|
24
24
|
assert_equal :panopticon_instance, r.send(:panopticon)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "setting other options" do
|
29
29
|
it "should create an instance with a default timeout of 10 seconds" do
|
30
|
-
GdsApi::Panopticon.expects(:new).with(anything
|
30
|
+
GdsApi::Panopticon.expects(:new).with(anything, timeout: 10).returns(:panopticon_instance)
|
31
31
|
r = GdsApi::Panopticon::Registerer.new({})
|
32
32
|
assert_equal :panopticon_instance, r.send(:panopticon)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should allow overriding the timeout" do
|
36
|
-
GdsApi::Panopticon.expects(:new).with(anything
|
37
|
-
r = GdsApi::Panopticon::Registerer.new(
|
36
|
+
GdsApi::Panopticon.expects(:new).with(anything, timeout: 15).returns(:panopticon_instance)
|
37
|
+
r = GdsApi::Panopticon::Registerer.new(timeout: 15)
|
38
38
|
assert_equal :panopticon_instance, r.send(:panopticon)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "shoule merge in the api credentials" do
|
42
|
-
GdsApi::Panopticon::Registerer.any_instance.stubs(:panopticon_api_credentials).returns(
|
43
|
-
GdsApi::Panopticon.expects(:new).with(anything
|
42
|
+
GdsApi::Panopticon::Registerer.any_instance.stubs(:panopticon_api_credentials).returns(foo: "Bar", baz: "kablooie")
|
43
|
+
GdsApi::Panopticon.expects(:new).with(anything, timeout: 10, foo: "Bar", baz: "kablooie").returns(:panopticon_instance)
|
44
44
|
r = GdsApi::Panopticon::Registerer.new({})
|
45
45
|
assert_equal :panopticon_instance, r.send(:panopticon)
|
46
46
|
end
|
@@ -63,7 +63,7 @@ describe GdsApi::Panopticon::Registerer do
|
|
63
63
|
name: 'A guide to beards',
|
64
64
|
description: '5 tips for keeping your beard in check',
|
65
65
|
state: 'draft',
|
66
|
-
need_ids:
|
66
|
+
need_ids: %w(100001 100002),
|
67
67
|
public_timestamp: "2014-01-01T12:00:00+00:00",
|
68
68
|
latest_change_note: 'Added more stubble',
|
69
69
|
content_id: 'f47b4fab-46fa-4020-97a2-3413a5d75402'
|
@@ -78,7 +78,7 @@ describe GdsApi::Panopticon::Registerer do
|
|
78
78
|
title: 'A guide to beards',
|
79
79
|
description: '5 tips for keeping your beard in check',
|
80
80
|
state: 'draft',
|
81
|
-
need_ids:
|
81
|
+
need_ids: %w(100001 100002),
|
82
82
|
primary_section: "tax/vat",
|
83
83
|
sections: ["tax/vat", "tax/capital-gains"],
|
84
84
|
specialist_sectors: ["oil-and-gas/wells", "oil-and-gas/licensing"],
|
data/test/panopticon_test.rb
CHANGED
@@ -44,13 +44,13 @@ describe GdsApi::Panopticon do
|
|
44
44
|
|
45
45
|
it 'fetches an artefact as a hash given a slug' do
|
46
46
|
panopticon_has_metadata(basic_artefact)
|
47
|
-
artefact = api.artefact_for_slug(basic_artefact[:slug], :
|
47
|
+
artefact = api.artefact_for_slug(basic_artefact[:slug], as_hash: true)
|
48
48
|
assert_equal basic_artefact[:name], artefact['name']
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'fetches and parses JSON into a hash' do
|
52
52
|
url = "#{base_api_endpoint}/some.json"
|
53
|
-
stub_request(:get, url).to_return(body: {a:1}.to_json)
|
53
|
+
stub_request(:get, url).to_return(body: { a: 1 }.to_json)
|
54
54
|
|
55
55
|
assert_equal 1, api.get_json(url)['a']
|
56
56
|
end
|
@@ -110,7 +110,7 @@ describe GdsApi::Panopticon do
|
|
110
110
|
end
|
111
111
|
|
112
112
|
it 'uses basic auth' do
|
113
|
-
credentials = {user: 'fred', password: 'secret'}
|
113
|
+
credentials = { user: 'fred', password: 'secret' }
|
114
114
|
api = GdsApi::Panopticon.new('http://some.url', basic_auth: credentials)
|
115
115
|
url = "http://#{credentials[:user]}:#{credentials[:password]}@some.url/artefacts/1.json"
|
116
116
|
stub_request(:put, url)
|
@@ -121,7 +121,7 @@ describe GdsApi::Panopticon do
|
|
121
121
|
|
122
122
|
it 'registers new artefacts en masse' do
|
123
123
|
r = GdsApi::Panopticon::Registerer.new(endpoint_url: base_api_endpoint, owning_app: 'my-app')
|
124
|
-
artefact = registerable_artefact
|
124
|
+
artefact = registerable_artefact
|
125
125
|
panopticon_has_no_metadata_for('foo')
|
126
126
|
|
127
127
|
stub_request(:put, "#{base_api_endpoint}/artefacts/foo.json")
|
@@ -138,7 +138,7 @@ describe GdsApi::Panopticon do
|
|
138
138
|
end
|
139
139
|
|
140
140
|
it 'registers existing artefacts en masse' do
|
141
|
-
artefact = registerable_artefact
|
141
|
+
artefact = registerable_artefact
|
142
142
|
r = GdsApi::Panopticon::Registerer.new(endpoint_url: base_api_endpoint, owning_app: 'my-app')
|
143
143
|
|
144
144
|
panopticon_has_metadata(artefact)
|
data/test/pp_data_in_test.rb
CHANGED
@@ -11,7 +11,7 @@ describe GdsApi::PerformancePlatform::DataIn do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "can submit a day aggregate for service feedback for a particular slug" do
|
14
|
-
request_details = {"some"=> "data"}
|
14
|
+
request_details = { "some" => "data" }
|
15
15
|
|
16
16
|
stub_post = stub_service_feedback_day_aggregate_submission("some-slug", request_details)
|
17
17
|
|
@@ -21,7 +21,7 @@ describe GdsApi::PerformancePlatform::DataIn do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "can submit entries counts for corporate content problem reports" do
|
24
|
-
entries =
|
24
|
+
entries = %w(some entries)
|
25
25
|
|
26
26
|
stub_post = stub_corporate_content_problem_report_count_submission(entries)
|
27
27
|
|
@@ -31,7 +31,7 @@ describe GdsApi::PerformancePlatform::DataIn do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "can submit the corporate content urls with the most problem reports" do
|
34
|
-
entries =
|
34
|
+
entries = %w(some entries)
|
35
35
|
|
36
36
|
stub_post = stub_corporate_content_urls_with_the_most_problem_reports_submission(entries)
|
37
37
|
|
data/test/publishing_api_test.rb
CHANGED
@@ -44,8 +44,6 @@ describe GdsApi::PublishingApi do
|
|
44
44
|
it "returns 200 OK if intent existed and was deleted" do
|
45
45
|
base_path = "/test-intent"
|
46
46
|
|
47
|
-
publish_intent = intent_for_publishing_api(base_path)
|
48
|
-
|
49
47
|
publishing_api
|
50
48
|
.given("a publish intent exists at /test-intent")
|
51
49
|
.upon_receiving("a request to delete a publish intent")
|
@@ -68,8 +66,6 @@ describe GdsApi::PublishingApi do
|
|
68
66
|
it "returns 404 Not found if the intent does not exist" do
|
69
67
|
base_path = "/test-intent"
|
70
68
|
|
71
|
-
publish_intent = intent_for_publishing_api(base_path)
|
72
|
-
|
73
69
|
publishing_api
|
74
70
|
.given("no content exists")
|
75
71
|
.upon_receiving("a request to delete a publish intent")
|
@@ -143,9 +139,9 @@ describe GdsApi::PublishingApi do
|
|
143
139
|
body: {
|
144
140
|
"error" => {
|
145
141
|
"code" => 422,
|
146
|
-
"message" => Pact.term(generate: "Unprocessable", matcher
|
142
|
+
"message" => Pact.term(generate: "Unprocessable", matcher: /\S+/),
|
147
143
|
"fields" => {
|
148
|
-
"base_path" => Pact.each_like("has been reserved", :
|
144
|
+
"base_path" => Pact.each_like("has been reserved", min: 1),
|
149
145
|
},
|
150
146
|
},
|
151
147
|
},
|