gds-api-adapters 63.3.0 → 67.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -23
- data/Rakefile +7 -8
- data/lib/gds_api.rb +1 -15
- data/lib/gds_api/base.rb +4 -3
- data/lib/gds_api/exceptions.rb +3 -4
- data/lib/gds_api/imminence.rb +2 -2
- data/lib/gds_api/json_client.rb +8 -8
- data/lib/gds_api/list_response.rb +6 -6
- data/lib/gds_api/performance_platform/data_out.rb +21 -21
- data/lib/gds_api/publishing_api.rb +2 -2
- data/lib/gds_api/response.rb +8 -4
- data/lib/gds_api/test_helpers/asset_manager.rb +0 -17
- data/lib/gds_api/test_helpers/calendars.rb +0 -9
- data/lib/gds_api/test_helpers/content_store.rb +0 -9
- data/lib/gds_api/test_helpers/email_alert_api.rb +8 -32
- data/lib/gds_api/test_helpers/imminence.rb +11 -14
- data/lib/gds_api/test_helpers/licence_application.rb +8 -16
- data/lib/gds_api/test_helpers/link_checker_api.rb +0 -8
- data/lib/gds_api/test_helpers/local_links_manager.rb +0 -13
- data/lib/gds_api/test_helpers/mapit.rb +15 -26
- data/lib/gds_api/test_helpers/organisations.rb +13 -18
- data/lib/gds_api/test_helpers/performance_platform/data_out.rb +34 -34
- data/lib/gds_api/test_helpers/publishing_api.rb +47 -65
- data/lib/gds_api/test_helpers/search.rb +5 -5
- data/lib/gds_api/test_helpers/support.rb +0 -5
- data/lib/gds_api/test_helpers/support_api.rb +16 -20
- data/lib/gds_api/test_helpers/worldwide.rb +52 -32
- data/lib/gds_api/version.rb +1 -1
- metadata +3 -6
- data/lib/gds_api/publishing_api_v2.rb +0 -14
- data/lib/gds_api/test_helpers/alias_deprecated.rb +0 -13
- data/lib/gds_api/test_helpers/publishing_api_v2.rb +0 -13
@@ -1,4 +1,3 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
1
|
require "gds_api/test_helpers/json_client_helper"
|
3
2
|
require "gds_api/test_helpers/content_item_helpers"
|
4
3
|
require "json"
|
@@ -6,7 +5,6 @@ require "json"
|
|
6
5
|
module GdsApi
|
7
6
|
module TestHelpers
|
8
7
|
module ContentStore
|
9
|
-
extend AliasDeprecated
|
10
8
|
include ContentItemHelpers
|
11
9
|
|
12
10
|
def content_store_endpoint(draft = false)
|
@@ -93,13 +91,6 @@ module GdsApi
|
|
93
91
|
|
94
92
|
stub_request(:get, url).to_return(body: body)
|
95
93
|
end
|
96
|
-
|
97
|
-
# Aliases for DEPRECATED methods
|
98
|
-
alias_deprecated :content_store_has_item, :stub_content_store_has_item
|
99
|
-
alias_deprecated :content_store_does_not_have_item, :stub_content_store_does_not_have_item
|
100
|
-
alias_deprecated :content_store_has_gone_item, :stub_content_store_has_gone_item
|
101
|
-
alias_deprecated :content_store_isnt_available, :stub_content_store_isnt_available
|
102
|
-
alias_deprecated :content_store_has_incoming_links, :stub_content_store_has_incoming_links
|
103
94
|
end
|
104
95
|
end
|
105
96
|
end
|
@@ -83,12 +83,12 @@ module GdsApi
|
|
83
83
|
# stub_email_alert_api_has_subscriptions([
|
84
84
|
# {
|
85
85
|
# id: 'id-of-my-subscriber-list',
|
86
|
-
#
|
86
|
+
# frequency: 'weekly',
|
87
87
|
# ended: true,
|
88
88
|
# },
|
89
89
|
# {
|
90
90
|
# id: 'id-of-my-subscriber-list',
|
91
|
-
#
|
91
|
+
# frequency: 'daily',
|
92
92
|
# },
|
93
93
|
# ])
|
94
94
|
#
|
@@ -176,7 +176,7 @@ module GdsApi
|
|
176
176
|
|
177
177
|
def assert_email_alert_api_content_change_created(attributes = nil)
|
178
178
|
if attributes
|
179
|
-
matcher =
|
179
|
+
matcher = lambda do |request|
|
180
180
|
payload = JSON.parse(request.body)
|
181
181
|
payload.select { |k, _| attributes.key?(k) } == attributes
|
182
182
|
end
|
@@ -187,7 +187,7 @@ module GdsApi
|
|
187
187
|
|
188
188
|
def assert_email_alert_api_message_created(attributes = nil)
|
189
189
|
if attributes
|
190
|
-
matcher =
|
190
|
+
matcher = lambda do |request|
|
191
191
|
payload = JSON.parse(request.body)
|
192
192
|
payload.select { |k, _| attributes.key?(k) } == attributes
|
193
193
|
end
|
@@ -222,21 +222,21 @@ module GdsApi
|
|
222
222
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
223
223
|
.with(
|
224
224
|
body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json,
|
225
|
-
|
225
|
+
).to_return(status: 201, body: { subscription_id: returned_subscription_id }.to_json)
|
226
226
|
end
|
227
227
|
|
228
228
|
def stub_email_alert_api_creates_an_existing_subscription(subscriber_list_id, address, frequency, returned_subscription_id)
|
229
229
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
230
230
|
.with(
|
231
231
|
body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json,
|
232
|
-
|
232
|
+
).to_return(status: 200, body: { subscription_id: returned_subscription_id }.to_json)
|
233
233
|
end
|
234
234
|
|
235
235
|
def stub_email_alert_api_refuses_to_create_subscription(subscriber_list_id, address, frequency)
|
236
236
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
237
237
|
.with(
|
238
238
|
body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json,
|
239
|
-
|
239
|
+
).to_return(status: 422)
|
240
240
|
end
|
241
241
|
|
242
242
|
def stub_email_alert_api_sends_subscription_verification_email(address, frequency, topic_id)
|
@@ -292,7 +292,7 @@ module GdsApi
|
|
292
292
|
body: {
|
293
293
|
subscriber_list: returned_attributes,
|
294
294
|
}.to_json,
|
295
|
-
|
295
|
+
)
|
296
296
|
end
|
297
297
|
|
298
298
|
def stub_email_alert_api_does_not_have_subscriber_list_by_slug(slug:)
|
@@ -300,30 +300,6 @@ module GdsApi
|
|
300
300
|
.to_return(status: 404)
|
301
301
|
end
|
302
302
|
|
303
|
-
# Aliases for DEPRECATED methods
|
304
|
-
alias_method :email_alert_api_has_updated_subscriber, :stub_email_alert_api_has_updated_subscriber
|
305
|
-
alias_method :email_alert_api_does_not_have_updated_subscriber, :stub_email_alert_api_does_not_have_updated_subscriber
|
306
|
-
alias_method :email_alert_api_has_updated_subscription, :stub_email_alert_api_has_updated_subscription
|
307
|
-
alias_method :email_alert_api_does_not_have_updated_subscription, :stub_email_alert_api_does_not_have_updated_subscription
|
308
|
-
alias_method :email_alert_api_has_subscriber_subscriptions, :stub_email_alert_api_has_subscriber_subscriptions
|
309
|
-
alias_method :email_alert_api_does_not_have_subscriber_subscriptions, :stub_email_alert_api_does_not_have_subscriber_subscriptions
|
310
|
-
alias_method :email_alert_api_has_subscription, :stub_email_alert_api_has_subscription
|
311
|
-
alias_method :email_alert_api_has_subscriptions, :stub_email_alert_api_has_subscriptions
|
312
|
-
alias_method :email_alert_api_has_subscriber_list, :stub_email_alert_api_has_subscriber_list
|
313
|
-
alias_method :email_alert_api_does_not_have_subscriber_list, :stub_email_alert_api_does_not_have_subscriber_list
|
314
|
-
alias_method :email_alert_api_creates_subscriber_list, :stub_email_alert_api_creates_subscriber_list
|
315
|
-
alias_method :email_alert_api_refuses_to_create_subscriber_list, :stub_email_alert_api_refuses_to_create_subscriber_list
|
316
|
-
alias_method :email_alert_api_accepts_unpublishing_message, :stub_email_alert_api_accepts_unpublishing_message
|
317
|
-
alias_method :email_alert_api_unsubscribes_a_subscription, :stub_email_alert_api_unsubscribes_a_subscription
|
318
|
-
alias_method :email_alert_api_has_no_subscription_for_uuid, :stub_email_alert_api_has_no_subscription_for_uuid
|
319
|
-
alias_method :email_alert_api_unsubscribes_a_subscriber, :stub_email_alert_api_unsubscribes_a_subscriber
|
320
|
-
alias_method :email_alert_api_has_no_subscriber, :stub_email_alert_api_has_no_subscriber
|
321
|
-
alias_method :email_alert_api_creates_a_subscription, :stub_email_alert_api_creates_a_subscription
|
322
|
-
alias_method :email_alert_api_creates_an_existing_subscription, :stub_email_alert_api_creates_an_existing_subscription
|
323
|
-
alias_method :email_alert_api_refuses_to_create_subscription, :stub_email_alert_api_refuses_to_create_subscription
|
324
|
-
alias_method :email_alert_api_has_subscriber_list_by_slug, :stub_email_alert_api_has_subscriber_list_by_slug
|
325
|
-
alias_method :email_alert_api_does_not_have_subscriber_list_by_slug, :stub_email_alert_api_does_not_have_subscriber_list_by_slug
|
326
|
-
|
327
303
|
private
|
328
304
|
|
329
305
|
def get_subscriber_response(id, address)
|
@@ -1,11 +1,8 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
1
|
require "gds_api/test_helpers/json_client_helper"
|
3
2
|
|
4
3
|
module GdsApi
|
5
4
|
module TestHelpers
|
6
5
|
module Imminence
|
7
|
-
extend AliasDeprecated
|
8
|
-
|
9
6
|
# Generally true. If you are initializing the client differently,
|
10
7
|
# you could redefine/override the constant or stub directly.
|
11
8
|
IMMINENCE_API_ENDPOINT = Plek.current.find("imminence")
|
@@ -18,12 +15,16 @@ module GdsApi
|
|
18
15
|
def stub_imminence_has_areas_for_postcode(postcode, areas)
|
19
16
|
results = {
|
20
17
|
"_response_info" => { "status" => "ok" },
|
21
|
-
"total" => areas.size,
|
22
|
-
"
|
18
|
+
"total" => areas.size,
|
19
|
+
"startIndex" => 1,
|
20
|
+
"pageSize" => areas.size,
|
21
|
+
"currentPage" => 1,
|
22
|
+
"pages" => 1,
|
23
|
+
"results" => areas,
|
23
24
|
}
|
24
25
|
|
25
|
-
stub_request(:get, %r{\A#{IMMINENCE_API_ENDPOINT}/areas/#{postcode}\.json})
|
26
|
-
to_return(body: results.to_json)
|
26
|
+
stub_request(:get, %r{\A#{IMMINENCE_API_ENDPOINT}/areas/#{postcode}\.json})
|
27
|
+
.to_return(body: results.to_json)
|
27
28
|
end
|
28
29
|
|
29
30
|
def stub_imminence_has_places_for_postcode(places, slug, postcode, limit)
|
@@ -32,14 +33,10 @@ module GdsApi
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def stub_imminence_places_request(slug, query_hash, return_data, status_code = 200)
|
35
|
-
stub_request(:get, "#{IMMINENCE_API_ENDPOINT}/places/#{slug}.json")
|
36
|
-
with(query: query_hash)
|
37
|
-
to_return(status: status_code, body: return_data.to_json, headers: {})
|
36
|
+
stub_request(:get, "#{IMMINENCE_API_ENDPOINT}/places/#{slug}.json")
|
37
|
+
.with(query: query_hash)
|
38
|
+
.to_return(status: status_code, body: return_data.to_json, headers: {})
|
38
39
|
end
|
39
|
-
|
40
|
-
alias_deprecated :imminence_has_places, :stub_imminence_has_places
|
41
|
-
alias_deprecated :imminence_has_areas_for_postcode, :stub_imminence_has_areas_for_postcode
|
42
|
-
alias_deprecated :imminence_has_places_for_postcode, :stub_imminence_has_places_for_postcode
|
43
40
|
end
|
44
41
|
end
|
45
42
|
end
|
@@ -1,28 +1,25 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
1
|
require "gds_api/test_helpers/json_client_helper"
|
3
2
|
|
4
3
|
module GdsApi
|
5
4
|
module TestHelpers
|
6
5
|
module LicenceApplication
|
7
|
-
extend AliasDeprecated
|
8
|
-
|
9
6
|
# Generally true. If you are initializing the client differently,
|
10
7
|
# you could redefine/override the constant or stub directly.
|
11
8
|
LICENCE_APPLICATION_ENDPOINT = Plek.current.find("licensify")
|
12
9
|
|
13
10
|
def stub_licence_exists(identifier, licence)
|
14
11
|
licence = licence.to_json unless licence.is_a?(String)
|
15
|
-
stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}")
|
16
|
-
with(headers: GdsApi::JsonClient.default_request_headers)
|
17
|
-
to_return(status: 200,
|
18
|
-
|
12
|
+
stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}")
|
13
|
+
.with(headers: GdsApi::JsonClient.default_request_headers)
|
14
|
+
.to_return(status: 200,
|
15
|
+
body: licence)
|
19
16
|
end
|
20
17
|
|
21
18
|
def stub_licence_does_not_exist(identifier)
|
22
|
-
stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}")
|
23
|
-
with(headers: GdsApi::JsonClient.default_request_headers)
|
24
|
-
to_return(status: 404,
|
25
|
-
|
19
|
+
stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}")
|
20
|
+
.with(headers: GdsApi::JsonClient.default_request_headers)
|
21
|
+
.to_return(status: 404,
|
22
|
+
body: "{\"error\": [\"Unrecognised Licence Id: #{identifier}\"]}")
|
26
23
|
end
|
27
24
|
|
28
25
|
def stub_licence_times_out(identifier)
|
@@ -32,11 +29,6 @@ module GdsApi
|
|
32
29
|
def stub_licence_returns_error(identifier)
|
33
30
|
stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").to_return(status: 500)
|
34
31
|
end
|
35
|
-
|
36
|
-
alias_deprecated :licence_exists, :stub_licence_exists
|
37
|
-
alias_deprecated :licence_does_not_exist, :stub_licence_does_not_exist
|
38
|
-
alias_deprecated :licence_times_out, :stub_licence_times_out
|
39
|
-
alias_deprecated :licence_returns_error, :stub_licence_returns_error
|
40
32
|
end
|
41
33
|
end
|
42
34
|
end
|
@@ -1,10 +1,8 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
1
|
require "gds_api/test_helpers/json_client_helper"
|
3
2
|
|
4
3
|
module GdsApi
|
5
4
|
module TestHelpers
|
6
5
|
module LinkCheckerApi
|
7
|
-
extend AliasDeprecated
|
8
6
|
LINK_CHECKER_API_ENDPOINT = Plek.current.find("link-checker-api")
|
9
7
|
|
10
8
|
def link_checker_api_link_report_hash(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil)
|
@@ -91,12 +89,6 @@ module GdsApi
|
|
91
89
|
headers: { "Content-Type" => "application/json" },
|
92
90
|
)
|
93
91
|
end
|
94
|
-
|
95
|
-
# Aliases for DEPRECATED methods
|
96
|
-
alias_deprecated :link_checker_api_check, :stub_link_checker_api_check
|
97
|
-
alias_deprecated :link_checker_api_get_batch, :stub_link_checker_api_get_batch
|
98
|
-
alias_deprecated :link_checker_api_create_batch, :stub_link_checker_api_create_batch
|
99
|
-
alias_deprecated :link_checker_api_upsert_resource_monitor, :stub_link_checker_api_upsert_resource_monitor
|
100
92
|
end
|
101
93
|
end
|
102
94
|
end
|
@@ -1,10 +1,8 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
1
|
require "gds_api/test_helpers/json_client_helper"
|
3
2
|
|
4
3
|
module GdsApi
|
5
4
|
module TestHelpers
|
6
5
|
module LocalLinksManager
|
7
|
-
extend AliasDeprecated
|
8
6
|
LOCAL_LINKS_MANAGER_ENDPOINT = Plek.current.find("local-links-manager")
|
9
7
|
|
10
8
|
def stub_local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:)
|
@@ -142,17 +140,6 @@ module GdsApi
|
|
142
140
|
.with(query: { authority_slug: authority_slug })
|
143
141
|
.to_return(body: response.to_json, status: 200)
|
144
142
|
end
|
145
|
-
|
146
|
-
alias_deprecated :local_links_manager_has_a_link, :stub_local_links_manager_has_a_link
|
147
|
-
alias_deprecated :local_links_manager_has_no_link, :stub_local_links_manager_has_no_link
|
148
|
-
alias_deprecated :local_links_manager_has_no_link_and_no_homepage_url, :stub_local_links_manager_has_no_link_and_no_homepage_url
|
149
|
-
alias_deprecated :local_links_manager_request_with_missing_parameters, :stub_local_links_manager_request_with_missing_parameters
|
150
|
-
alias_deprecated :local_links_manager_does_not_have_required_objects, :stub_local_links_manager_does_not_have_required_objects
|
151
|
-
alias_deprecated :local_links_manager_has_a_local_authority, :stub_local_links_manager_has_a_local_authority
|
152
|
-
alias_deprecated :local_links_manager_has_a_district_and_county_local_authority, :stub_local_links_manager_has_a_district_and_county_local_authority
|
153
|
-
alias_deprecated :local_links_manager_request_without_local_authority_slug, :stub_local_links_manager_request_without_local_authority_slug
|
154
|
-
alias_deprecated :local_links_manager_does_not_have_an_authority, :stub_local_links_manager_does_not_have_an_authority
|
155
|
-
alias_deprecated :local_links_manager_has_a_local_authority_without_homepage, :stub_local_links_manager_has_a_local_authority_without_homepage
|
156
143
|
end
|
157
144
|
end
|
158
145
|
end
|
@@ -1,16 +1,13 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
|
-
|
3
1
|
module GdsApi
|
4
2
|
module TestHelpers
|
5
3
|
module Mapit
|
6
|
-
extend AliasDeprecated
|
7
4
|
MAPIT_ENDPOINT = Plek.current.find("mapit")
|
8
5
|
|
9
6
|
def stub_mapit_has_a_postcode(postcode, coords)
|
10
7
|
response = {
|
11
8
|
"wgs84_lat" => coords.first,
|
12
9
|
"wgs84_lon" => coords.last,
|
13
|
-
"postcode"
|
10
|
+
"postcode" => postcode,
|
14
11
|
}
|
15
12
|
|
16
13
|
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/" + postcode.tr(" ", "+") + ".json")
|
@@ -23,21 +20,22 @@ module GdsApi
|
|
23
20
|
response = {
|
24
21
|
"wgs84_lat" => coords.first,
|
25
22
|
"wgs84_lon" => coords.last,
|
26
|
-
"postcode"
|
23
|
+
"postcode" => postcode,
|
27
24
|
}
|
28
25
|
|
29
|
-
area_response = Hash[areas.map.with_index
|
30
|
-
[i,
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
26
|
+
area_response = Hash[areas.map.with_index do |area, i|
|
27
|
+
[i,
|
28
|
+
{
|
29
|
+
"codes" => {
|
30
|
+
"ons" => area["ons"],
|
31
|
+
"gss" => area["gss"],
|
32
|
+
"govuk_slug" => area["govuk_slug"],
|
33
|
+
},
|
34
|
+
"name" => area["name"],
|
35
|
+
"type" => area["type"],
|
36
|
+
"country_name" => area["country_name"],
|
37
|
+
}]
|
38
|
+
end]
|
41
39
|
|
42
40
|
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/" + postcode.tr(" ", "+") + ".json")
|
43
41
|
.to_return(body: response.merge("areas" => area_response).to_json, status: 200)
|
@@ -74,15 +72,6 @@ module GdsApi
|
|
74
72
|
stub_request(:get, "#{MAPIT_ENDPOINT}/code/#{code_type}/#{code}.json")
|
75
73
|
.to_return(body: { "code" => 404, "error" => "No areas were found that matched code #{code_type} = #{code}." }.to_json, status: 404)
|
76
74
|
end
|
77
|
-
|
78
|
-
alias_deprecated :mapit_has_a_postcode, :stub_mapit_has_a_postcode
|
79
|
-
alias_deprecated :mapit_has_a_postcode_and_areas, :stub_mapit_has_a_postcode_and_areas
|
80
|
-
alias_deprecated :mapit_does_not_have_a_postcode, :stub_mapit_does_not_have_a_postcode
|
81
|
-
alias_deprecated :mapit_does_not_have_a_bad_postcode, :stub_mapit_does_not_have_a_bad_postcode
|
82
|
-
alias_deprecated :mapit_has_areas, :stub_mapit_has_areas
|
83
|
-
alias_deprecated :mapit_does_not_have_areas, :stub_mapit_does_not_have_areas
|
84
|
-
alias_deprecated :mapit_has_area_for_code, :stub_mapit_has_area_for_code
|
85
|
-
alias_deprecated :mapit_does_not_have_area_for_code, :stub_mapit_does_not_have_area_for_code
|
86
75
|
end
|
87
76
|
end
|
88
77
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
1
|
require "gds_api/test_helpers/json_client_helper"
|
3
2
|
require "gds_api/test_helpers/common_responses"
|
4
3
|
require "plek"
|
@@ -7,7 +6,6 @@ require "securerandom"
|
|
7
6
|
module GdsApi
|
8
7
|
module TestHelpers
|
9
8
|
module Organisations
|
10
|
-
extend AliasDeprecated
|
11
9
|
include GdsApi::TestHelpers::CommonResponses
|
12
10
|
|
13
11
|
WEBSITE_ROOT = Plek.new.website_root
|
@@ -35,12 +33,14 @@ module GdsApi
|
|
35
33
|
end
|
36
34
|
|
37
35
|
pages.each_with_index do |page, i|
|
38
|
-
page_details = plural_response_base.merge(
|
36
|
+
page_details = plural_response_base.merge(
|
37
|
+
"results" => page,
|
39
38
|
"total" => organisation_bodies.size,
|
40
39
|
"pages" => pages.size,
|
41
40
|
"current_page" => i + 1,
|
42
41
|
"page_size" => 20,
|
43
|
-
"start_index" => i * 20 + 1
|
42
|
+
"start_index" => i * 20 + 1,
|
43
|
+
)
|
44
44
|
|
45
45
|
links = { self: "#{WEBSITE_ROOT}/api/organisations?page=#{i + 1}" }
|
46
46
|
links[:next] = "#{WEBSITE_ROOT}/api/organisations?page=#{i + 2}" if pages[i + 1]
|
@@ -52,14 +52,14 @@ module GdsApi
|
|
52
52
|
link_headers << "<#{href}>; rel=\"#{rel}\""
|
53
53
|
end
|
54
54
|
|
55
|
-
stub_request(:get, links[:self])
|
56
|
-
to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
|
55
|
+
stub_request(:get, links[:self])
|
56
|
+
.to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
next unless i.zero?
|
59
|
+
|
60
|
+
# First page exists at URL with and without page param
|
61
|
+
stub_request(:get, links[:self].sub(/\?page=1/, ""))
|
62
|
+
.to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
|
63
63
|
end
|
64
64
|
|
65
65
|
if pages.empty?
|
@@ -70,8 +70,8 @@ module GdsApi
|
|
70
70
|
|
71
71
|
def stub_organisations_api_has_organisation(organisation_slug, details = nil)
|
72
72
|
details ||= organisation_for_slug(organisation_slug)
|
73
|
-
stub_request(:get, "#{WEBSITE_ROOT}/api/organisations/#{organisation_slug}")
|
74
|
-
to_return(status: 200, body: details.to_json)
|
73
|
+
stub_request(:get, "#{WEBSITE_ROOT}/api/organisations/#{organisation_slug}")
|
74
|
+
.to_return(status: 200, body: details.to_json)
|
75
75
|
end
|
76
76
|
|
77
77
|
def stub_organisations_api_does_not_have_organisation(organisation_slug)
|
@@ -117,11 +117,6 @@ module GdsApi
|
|
117
117
|
],
|
118
118
|
}
|
119
119
|
end
|
120
|
-
|
121
|
-
alias_deprecated :organisations_api_has_organisations, :stub_organisations_api_has_organisations
|
122
|
-
alias_deprecated :organisations_api_has_organisations_with_bodies, :stub_organisations_api_has_organisations_with_bodies
|
123
|
-
alias_deprecated :organisations_api_has_organisation, :stub_organisations_api_has_organisation
|
124
|
-
alias_deprecated :organisations_api_does_not_have_organisation, :stub_organisations_api_does_not_have_organisation
|
125
120
|
end
|
126
121
|
end
|
127
122
|
end
|
@@ -5,13 +5,13 @@ module GdsApi
|
|
5
5
|
PP_DATA_OUT_ENDPOINT = "https://www.performance.service.gov.uk".freeze
|
6
6
|
|
7
7
|
def stub_service_feedback(slug, response_body = {})
|
8
|
-
stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction")
|
9
|
-
to_return(status: 200, body: response_body.to_json)
|
8
|
+
stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction")
|
9
|
+
.to_return(status: 200, body: response_body.to_json)
|
10
10
|
end
|
11
11
|
|
12
12
|
def stub_data_set_not_available(slug)
|
13
|
-
stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction")
|
14
|
-
to_return(status: 404)
|
13
|
+
stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction")
|
14
|
+
.to_return(status: 404)
|
15
15
|
end
|
16
16
|
|
17
17
|
def stub_service_not_available
|
@@ -20,51 +20,51 @@ module GdsApi
|
|
20
20
|
|
21
21
|
def stub_search_terms(slug, response_body = {})
|
22
22
|
options = {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
slug: slug,
|
24
|
+
transaction: "search-terms",
|
25
|
+
group_by: "searchKeyword",
|
26
|
+
collect: "searchUniques:sum",
|
27
27
|
}
|
28
28
|
stub_statistics(options, false, response_body)
|
29
29
|
end
|
30
30
|
|
31
31
|
def stub_searches(slug, is_multipart, response_body = {})
|
32
32
|
options = {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
slug: slug,
|
34
|
+
transaction: "search-terms",
|
35
|
+
group_by: "pagePath",
|
36
|
+
collect: "searchUniques:sum",
|
37
37
|
}
|
38
38
|
stub_statistics(options, is_multipart, response_body)
|
39
39
|
end
|
40
40
|
|
41
41
|
def stub_page_views(slug, is_multipart, response_body = {})
|
42
42
|
options = {
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
slug: slug,
|
44
|
+
transaction: "page-statistics",
|
45
|
+
group_by: "pagePath",
|
46
|
+
collect: "uniquePageviews:sum",
|
47
47
|
}
|
48
48
|
stub_statistics(options, is_multipart, response_body)
|
49
49
|
end
|
50
50
|
|
51
51
|
def stub_problem_reports(slug, is_multipart, response_body = {})
|
52
52
|
options = {
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
slug: slug,
|
54
|
+
transaction: "page-contacts",
|
55
|
+
group_by: "pagePath",
|
56
|
+
collect: "total:sum",
|
57
57
|
}
|
58
58
|
stub_statistics(options, is_multipart, response_body)
|
59
59
|
end
|
60
60
|
|
61
61
|
def stub_statistics(options, is_multipart, response_body = {})
|
62
62
|
params = {
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
group_by: options[:group_by],
|
64
|
+
collect: options[:collect],
|
65
|
+
duration: 42,
|
66
|
+
period: "day",
|
67
|
+
end_at: Date.today.to_time.getutc.iso8601,
|
68
68
|
}
|
69
69
|
|
70
70
|
filter_param = is_multipart ? :filter_by_prefix : :filter_by
|
@@ -76,21 +76,21 @@ module GdsApi
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def stub_search_404(slug)
|
79
|
-
stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/search-terms")
|
80
|
-
with(query: hash_including(filter_by: slug))
|
81
|
-
to_return(status: 404, headers: { content_type: "application/json" })
|
79
|
+
stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/search-terms")
|
80
|
+
.with(query: hash_including(filter_by: slug))
|
81
|
+
.to_return(status: 404, headers: { content_type: "application/json" })
|
82
82
|
end
|
83
83
|
|
84
84
|
def stub_page_views_404(slug)
|
85
|
-
stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-statistics")
|
86
|
-
with(query: hash_including(filter_by: slug))
|
87
|
-
to_return(status: 404, headers: { content_type: "application/json" })
|
85
|
+
stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-statistics")
|
86
|
+
.with(query: hash_including(filter_by: slug))
|
87
|
+
.to_return(status: 404, headers: { content_type: "application/json" })
|
88
88
|
end
|
89
89
|
|
90
90
|
def stub_problem_reports_404(slug)
|
91
|
-
stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-contacts")
|
92
|
-
with(query: hash_including(filter_by: slug))
|
93
|
-
to_return(status: 404, headers: { content_type: "application/json" })
|
91
|
+
stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-contacts")
|
92
|
+
.with(query: hash_including(filter_by: slug))
|
93
|
+
.to_return(status: 404, headers: { content_type: "application/json" })
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|