gds-api-adapters 93.0.0 → 94.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/account_api.rb +8 -8
- data/lib/gds_api/asset_manager.rb +2 -2
- data/lib/gds_api/email_alert_api.rb +17 -17
- data/lib/gds_api/imminence.rb +3 -3
- data/lib/gds_api/json_client.rb +2 -2
- data/lib/gds_api/link_checker_api.rb +7 -7
- data/lib/gds_api/publishing_api/special_route_publisher.rb +3 -3
- data/lib/gds_api/publishing_api.rb +10 -10
- data/lib/gds_api/router.rb +2 -2
- data/lib/gds_api/test_helpers/account_api.rb +23 -23
- data/lib/gds_api/test_helpers/asset_manager.rb +1 -1
- data/lib/gds_api/test_helpers/calendars.rb +7 -7
- data/lib/gds_api/test_helpers/content_store.rb +3 -3
- data/lib/gds_api/test_helpers/email_alert_api.rb +40 -40
- data/lib/gds_api/test_helpers/imminence.rb +3 -3
- data/lib/gds_api/test_helpers/link_checker_api.rb +24 -24
- data/lib/gds_api/test_helpers/local_links_manager.rb +13 -13
- data/lib/gds_api/test_helpers/publishing_api.rb +17 -17
- data/lib/gds_api/test_helpers/router.rb +6 -6
- data/lib/gds_api/test_helpers/support_api.rb +1 -1
- data/lib/gds_api/version.rb +1 -1
- metadata +8 -22
@@ -28,7 +28,7 @@ module GdsApi
|
|
28
28
|
stub_request(:patch, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/#{subscription_id}")
|
29
29
|
.to_return(
|
30
30
|
status: 200,
|
31
|
-
body: get_subscription_response(subscription_id, frequency:
|
31
|
+
body: get_subscription_response(subscription_id, frequency:).to_json,
|
32
32
|
)
|
33
33
|
end
|
34
34
|
|
@@ -43,7 +43,7 @@ module GdsApi
|
|
43
43
|
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/#{id}/subscriptions#{params}")
|
44
44
|
.to_return(
|
45
45
|
status: 200,
|
46
|
-
body: get_subscriber_subscriptions_response(id, address, subscriptions:
|
46
|
+
body: get_subscriber_subscriptions_response(id, address, subscriptions:).to_json,
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
@@ -62,11 +62,11 @@ module GdsApi
|
|
62
62
|
)
|
63
63
|
response = get_subscription_response(
|
64
64
|
id,
|
65
|
-
frequency
|
66
|
-
title
|
67
|
-
subscriber_id
|
68
|
-
subscriber_list_id
|
69
|
-
ended
|
65
|
+
frequency:,
|
66
|
+
title:,
|
67
|
+
subscriber_id:,
|
68
|
+
subscriber_list_id:,
|
69
|
+
ended:,
|
70
70
|
).to_json
|
71
71
|
|
72
72
|
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/#{id}")
|
@@ -217,16 +217,16 @@ module GdsApi
|
|
217
217
|
)
|
218
218
|
response = get_subscription_response(
|
219
219
|
returned_subscription_id,
|
220
|
-
frequency
|
221
|
-
subscriber_list_id
|
222
|
-
subscriber_id
|
220
|
+
frequency:,
|
221
|
+
subscriber_list_id:,
|
222
|
+
subscriber_id:,
|
223
223
|
)
|
224
224
|
|
225
225
|
request_params = {
|
226
|
-
subscriber_list_id
|
227
|
-
address
|
228
|
-
frequency
|
229
|
-
skip_confirmation_email
|
226
|
+
subscriber_list_id:,
|
227
|
+
address:,
|
228
|
+
frequency:,
|
229
|
+
skip_confirmation_email:,
|
230
230
|
}
|
231
231
|
|
232
232
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
@@ -238,9 +238,9 @@ module GdsApi
|
|
238
238
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
239
239
|
.with(
|
240
240
|
body: hash_including(
|
241
|
-
subscriber_list_id
|
242
|
-
address
|
243
|
-
frequency
|
241
|
+
subscriber_list_id:,
|
242
|
+
address:,
|
243
|
+
frequency:,
|
244
244
|
),
|
245
245
|
).to_return(status: 422)
|
246
246
|
end
|
@@ -248,14 +248,14 @@ module GdsApi
|
|
248
248
|
def stub_email_alert_api_sends_subscription_verification_email(address, frequency, topic_id)
|
249
249
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/auth-token")
|
250
250
|
.with(
|
251
|
-
body: { address
|
251
|
+
body: { address:, frequency:, topic_id: }.to_json,
|
252
252
|
).to_return(status: 200)
|
253
253
|
end
|
254
254
|
|
255
255
|
def stub_email_alert_api_subscription_verification_email_invalid(address, frequency, topic_id)
|
256
256
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/auth-token")
|
257
257
|
.with(
|
258
|
-
body: { address
|
258
|
+
body: { address:, frequency:, topic_id: }.to_json,
|
259
259
|
).to_return(status: 422)
|
260
260
|
end
|
261
261
|
|
@@ -285,7 +285,7 @@ module GdsApi
|
|
285
285
|
def stub_email_alert_api_authenticate_subscriber_by_govuk_account(govuk_account_session, subscriber_id, address, govuk_account_id: "user-id", new_govuk_account_session: nil)
|
286
286
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account")
|
287
287
|
.with(
|
288
|
-
body: { govuk_account_session:
|
288
|
+
body: { govuk_account_session: }.to_json,
|
289
289
|
).to_return(
|
290
290
|
status: 200,
|
291
291
|
body: {
|
@@ -297,7 +297,7 @@ module GdsApi
|
|
297
297
|
def stub_email_alert_api_authenticate_subscriber_by_govuk_account_session_invalid(govuk_account_session)
|
298
298
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account")
|
299
299
|
.with(
|
300
|
-
body: { govuk_account_session:
|
300
|
+
body: { govuk_account_session: }.to_json,
|
301
301
|
).to_return(
|
302
302
|
status: 401,
|
303
303
|
)
|
@@ -306,7 +306,7 @@ module GdsApi
|
|
306
306
|
def stub_email_alert_api_authenticate_subscriber_by_govuk_account_email_unverified(govuk_account_session, new_govuk_account_session: nil)
|
307
307
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account")
|
308
308
|
.with(
|
309
|
-
body: { govuk_account_session:
|
309
|
+
body: { govuk_account_session: }.to_json,
|
310
310
|
).to_return(
|
311
311
|
status: 403,
|
312
312
|
body: {
|
@@ -318,7 +318,7 @@ module GdsApi
|
|
318
318
|
def stub_email_alert_api_authenticate_subscriber_by_govuk_account_no_subscriber(govuk_account_session, new_govuk_account_session: nil)
|
319
319
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account")
|
320
320
|
.with(
|
321
|
-
body: { govuk_account_session:
|
321
|
+
body: { govuk_account_session: }.to_json,
|
322
322
|
).to_return(
|
323
323
|
status: 404,
|
324
324
|
body: {
|
@@ -330,7 +330,7 @@ module GdsApi
|
|
330
330
|
def stub_email_alert_api_link_subscriber_to_govuk_account(govuk_account_session, subscriber_id, address, govuk_account_id: "user-id", new_govuk_account_session: nil)
|
331
331
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account/link")
|
332
332
|
.with(
|
333
|
-
body: { govuk_account_session:
|
333
|
+
body: { govuk_account_session: }.to_json,
|
334
334
|
).to_return(
|
335
335
|
status: 200,
|
336
336
|
body: {
|
@@ -342,7 +342,7 @@ module GdsApi
|
|
342
342
|
def stub_email_alert_api_link_subscriber_to_govuk_account_session_invalid(govuk_account_session)
|
343
343
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account/link")
|
344
344
|
.with(
|
345
|
-
body: { govuk_account_session:
|
345
|
+
body: { govuk_account_session: }.to_json,
|
346
346
|
).to_return(
|
347
347
|
status: 401,
|
348
348
|
)
|
@@ -351,7 +351,7 @@ module GdsApi
|
|
351
351
|
def stub_email_alert_api_link_subscriber_to_govuk_account_email_unverified(govuk_account_session, new_govuk_account_session: nil)
|
352
352
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account/link")
|
353
353
|
.with(
|
354
|
-
body: { govuk_account_session:
|
354
|
+
body: { govuk_account_session: }.to_json,
|
355
355
|
).to_return(
|
356
356
|
status: 403,
|
357
357
|
body: {
|
@@ -380,9 +380,9 @@ module GdsApi
|
|
380
380
|
def assert_subscribed(subscriber_list_id, address, frequency = "immediately")
|
381
381
|
assert_requested(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions") do |req|
|
382
382
|
JSON.parse(req.body).symbolize_keys == {
|
383
|
-
subscriber_list_id
|
384
|
-
address
|
385
|
-
frequency
|
383
|
+
subscriber_list_id:,
|
384
|
+
address:,
|
385
|
+
frequency:,
|
386
386
|
}
|
387
387
|
end
|
388
388
|
end
|
@@ -411,8 +411,8 @@ module GdsApi
|
|
411
411
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
|
412
412
|
.with({
|
413
413
|
body: {
|
414
|
-
body
|
415
|
-
sender_message_id
|
414
|
+
body:,
|
415
|
+
sender_message_id:,
|
416
416
|
}.to_json,
|
417
417
|
}.tap { |attr| attr[:headers] = { "Govuk-Request-Id" => govuk_request_id } if govuk_request_id })
|
418
418
|
.to_return(status: 202)
|
@@ -427,8 +427,8 @@ module GdsApi
|
|
427
427
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
|
428
428
|
.with({
|
429
429
|
body: {
|
430
|
-
body
|
431
|
-
sender_message_id
|
430
|
+
body:,
|
431
|
+
sender_message_id:,
|
432
432
|
}.to_json,
|
433
433
|
}.tap { |attr| attr[:headers] = { "Govuk-Request-Id" => govuk_request_id } if govuk_request_id })
|
434
434
|
.to_return(status: 404)
|
@@ -443,8 +443,8 @@ module GdsApi
|
|
443
443
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
|
444
444
|
.with({
|
445
445
|
body: {
|
446
|
-
body
|
447
|
-
sender_message_id
|
446
|
+
body:,
|
447
|
+
sender_message_id:,
|
448
448
|
}.to_json,
|
449
449
|
}.tap { |attr| attr[:headers] = { "Govuk-Request-Id" => govuk_request_id } if govuk_request_id })
|
450
450
|
.to_return(status: 409)
|
@@ -459,8 +459,8 @@ module GdsApi
|
|
459
459
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
|
460
460
|
.with({
|
461
461
|
body: {
|
462
|
-
body
|
463
|
-
sender_message_id
|
462
|
+
body:,
|
463
|
+
sender_message_id:,
|
464
464
|
}.to_json,
|
465
465
|
}.tap { |attr| attr[:headers] = { "Govuk-Request-Id" => govuk_request_id } if govuk_request_id })
|
466
466
|
.to_return(status: 422)
|
@@ -468,19 +468,19 @@ module GdsApi
|
|
468
468
|
|
469
469
|
def stub_email_alert_api_bulk_migrate(from_slug:, to_slug:)
|
470
470
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/bulk-migrate")
|
471
|
-
.with(body: { from_slug
|
471
|
+
.with(body: { from_slug:, to_slug: }.to_json)
|
472
472
|
.to_return(status: 202)
|
473
473
|
end
|
474
474
|
|
475
475
|
def stub_email_alert_api_bulk_migrate_bad_request(from_slug:, to_slug:)
|
476
476
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/bulk-migrate")
|
477
|
-
.with(body: { from_slug
|
477
|
+
.with(body: { from_slug:, to_slug: }.to_json)
|
478
478
|
.to_return(status: 422)
|
479
479
|
end
|
480
480
|
|
481
481
|
def stub_email_alert_api_bulk_migrate_not_found(from_slug:, to_slug:)
|
482
482
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/bulk-migrate")
|
483
|
-
.with(body: { from_slug
|
483
|
+
.with(body: { from_slug:, to_slug: }.to_json)
|
484
484
|
.to_return(status: 404)
|
485
485
|
end
|
486
486
|
|
@@ -22,18 +22,18 @@ module GdsApi
|
|
22
22
|
response_data = {
|
23
23
|
status: "address-information-required",
|
24
24
|
content: "addresses",
|
25
|
-
addresses
|
25
|
+
addresses:,
|
26
26
|
}
|
27
27
|
stub_imminence_places_request(slug, query_hash, response_data)
|
28
28
|
end
|
29
29
|
|
30
30
|
def stub_imminence_has_places_for_postcode(places, slug, postcode, limit, local_authority_slug)
|
31
31
|
query_hash = { "postcode" => postcode, "limit" => limit }
|
32
|
-
query_hash.merge!(local_authority_slug:
|
32
|
+
query_hash.merge!(local_authority_slug:) if local_authority_slug
|
33
33
|
response_data = {
|
34
34
|
status: "ok",
|
35
35
|
content: "places",
|
36
|
-
places
|
36
|
+
places:,
|
37
37
|
}
|
38
38
|
stub_imminence_places_request(slug, query_hash, response_data)
|
39
39
|
end
|
@@ -7,61 +7,61 @@ module GdsApi
|
|
7
7
|
|
8
8
|
def link_checker_api_link_report_hash(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil)
|
9
9
|
{
|
10
|
-
uri
|
11
|
-
status
|
10
|
+
uri:,
|
11
|
+
status:,
|
12
12
|
checked: checked || Time.now.iso8601,
|
13
|
-
errors
|
14
|
-
warnings
|
15
|
-
problem_summary
|
16
|
-
suggested_fix
|
13
|
+
errors:,
|
14
|
+
warnings:,
|
15
|
+
problem_summary:,
|
16
|
+
suggested_fix:,
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
20
|
def link_checker_api_batch_report_hash(id:, status: :completed, links: [], totals: {}, completed_at: nil)
|
21
21
|
{
|
22
|
-
id
|
23
|
-
status
|
22
|
+
id:,
|
23
|
+
status:,
|
24
24
|
links: links.map { |hash| link_checker_api_link_report_hash(**hash) },
|
25
|
-
totals
|
25
|
+
totals:,
|
26
26
|
completed_at: completed_at || Time.now.iso8601,
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
30
|
def stub_link_checker_api_check(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil)
|
31
31
|
body = link_checker_api_link_report_hash(
|
32
|
-
uri
|
32
|
+
uri:, status:, checked:, errors:, warnings:, problem_summary:, suggested_fix:,
|
33
33
|
).to_json
|
34
34
|
|
35
35
|
stub_request(:get, "#{LINK_CHECKER_API_ENDPOINT}/check")
|
36
|
-
.with(query: { uri:
|
37
|
-
.to_return(body
|
36
|
+
.with(query: { uri: })
|
37
|
+
.to_return(body:, status: 200, headers: { "Content-Type" => "application/json" })
|
38
38
|
end
|
39
39
|
|
40
40
|
def stub_link_checker_api_get_batch(id:, status: :completed, links: [], totals: {}, completed_at: nil)
|
41
41
|
body = link_checker_api_batch_report_hash(
|
42
|
-
id
|
42
|
+
id:, status:, links:, totals:, completed_at:,
|
43
43
|
).to_json
|
44
44
|
|
45
45
|
stub_request(:get, "#{LINK_CHECKER_API_ENDPOINT}/batch/#{id}")
|
46
|
-
.to_return(body
|
46
|
+
.to_return(body:, status: 200, headers: { "Content-Type" => "application/json" })
|
47
47
|
end
|
48
48
|
|
49
49
|
def stub_link_checker_api_create_batch(uris:, checked_within: nil, webhook_uri: nil, webhook_secret_token: nil, id: 0, status: :in_progress, links: nil, totals: {}, completed_at: nil)
|
50
|
-
links = uris.map { |uri| { uri:
|
50
|
+
links = uris.map { |uri| { uri: } } if links.nil?
|
51
51
|
|
52
52
|
response_body = link_checker_api_batch_report_hash(
|
53
|
-
id
|
54
|
-
status
|
55
|
-
links
|
56
|
-
totals
|
57
|
-
completed_at
|
53
|
+
id:,
|
54
|
+
status:,
|
55
|
+
links:,
|
56
|
+
totals:,
|
57
|
+
completed_at:,
|
58
58
|
).to_json
|
59
59
|
|
60
60
|
request_body = {
|
61
|
-
uris
|
62
|
-
checked_within
|
63
|
-
webhook_uri
|
64
|
-
webhook_secret_token
|
61
|
+
uris:,
|
62
|
+
checked_within:,
|
63
|
+
webhook_uri:,
|
64
|
+
webhook_secret_token:,
|
65
65
|
}.delete_if { |_, v| v.nil? }.to_json
|
66
66
|
|
67
67
|
stub_request(:post, "#{LINK_CHECKER_API_ENDPOINT}/batch")
|
@@ -25,12 +25,12 @@ module GdsApi
|
|
25
25
|
response["local_authority"]["snac"] = snac if snac
|
26
26
|
|
27
27
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
28
|
-
.with(query: { authority_slug
|
28
|
+
.with(query: { authority_slug:, lgsl:, lgil: })
|
29
29
|
.to_return(body: response.to_json, status: 200)
|
30
30
|
|
31
31
|
unless local_custodian_code.nil?
|
32
32
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
33
|
-
.with(query: { local_custodian_code
|
33
|
+
.with(query: { local_custodian_code:, lgsl:, lgil: })
|
34
34
|
.to_return(body: response.to_json, status: 200)
|
35
35
|
end
|
36
36
|
end
|
@@ -49,12 +49,12 @@ module GdsApi
|
|
49
49
|
response["local_authority"]["snac"] = snac if snac
|
50
50
|
|
51
51
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
52
|
-
.with(query: { authority_slug
|
52
|
+
.with(query: { authority_slug:, lgsl:, lgil: })
|
53
53
|
.to_return(body: response.to_json, status: 200)
|
54
54
|
|
55
55
|
unless local_custodian_code.nil?
|
56
56
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
57
|
-
.with(query: { local_custodian_code
|
57
|
+
.with(query: { local_custodian_code:, lgsl:, lgil: })
|
58
58
|
.to_return(body: response.to_json, status: 200)
|
59
59
|
end
|
60
60
|
end
|
@@ -73,12 +73,12 @@ module GdsApi
|
|
73
73
|
response["local_authority"]["snac"] = snac if snac
|
74
74
|
|
75
75
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
76
|
-
.with(query: { authority_slug
|
76
|
+
.with(query: { authority_slug:, lgsl:, lgil: })
|
77
77
|
.to_return(body: response.to_json, status: 200)
|
78
78
|
|
79
79
|
unless local_custodian_code.nil?
|
80
80
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
|
81
|
-
.with(query: { local_custodian_code
|
81
|
+
.with(query: { local_custodian_code:, lgsl:, lgil: })
|
82
82
|
.to_return(body: response.to_json, status: 200)
|
83
83
|
end
|
84
84
|
end
|
@@ -117,12 +117,12 @@ module GdsApi
|
|
117
117
|
response["local_authorities"][0]["snac"] = snac if snac
|
118
118
|
|
119
119
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
120
|
-
.with(query: { authority_slug:
|
120
|
+
.with(query: { authority_slug: })
|
121
121
|
.to_return(body: response.to_json, status: 200)
|
122
122
|
|
123
123
|
unless local_custodian_code.nil?
|
124
124
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
125
|
-
.with(query: { local_custodian_code:
|
125
|
+
.with(query: { local_custodian_code: })
|
126
126
|
.to_return(body: response.to_json, status: 200)
|
127
127
|
end
|
128
128
|
end
|
@@ -157,7 +157,7 @@ module GdsApi
|
|
157
157
|
|
158
158
|
unless local_custodian_code.nil?
|
159
159
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
160
|
-
.with(query: { local_custodian_code:
|
160
|
+
.with(query: { local_custodian_code: })
|
161
161
|
.to_return(body: response.to_json, status: 200)
|
162
162
|
end
|
163
163
|
end
|
@@ -176,13 +176,13 @@ module GdsApi
|
|
176
176
|
|
177
177
|
def stub_local_links_manager_does_not_have_an_authority(authority_slug)
|
178
178
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
179
|
-
.with(query: { authority_slug:
|
179
|
+
.with(query: { authority_slug: })
|
180
180
|
.to_return(body: {}.to_json, status: 404)
|
181
181
|
end
|
182
182
|
|
183
183
|
def stub_local_links_manager_does_not_have_a_custodian_code(local_custodian_code)
|
184
184
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
185
|
-
.with(query: { local_custodian_code:
|
185
|
+
.with(query: { local_custodian_code: })
|
186
186
|
.to_return(body: {}.to_json, status: 404)
|
187
187
|
end
|
188
188
|
|
@@ -202,12 +202,12 @@ module GdsApi
|
|
202
202
|
response["local_authorities"][0]["snac"] = snac if snac
|
203
203
|
|
204
204
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
205
|
-
.with(query: { authority_slug:
|
205
|
+
.with(query: { authority_slug: })
|
206
206
|
.to_return(body: response.to_json, status: 200)
|
207
207
|
|
208
208
|
unless local_custodian_code.nil?
|
209
209
|
stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
|
210
|
-
.with(query: { local_custodian_code:
|
210
|
+
.with(query: { local_custodian_code: })
|
211
211
|
.to_return(body: response.to_json, status: 200)
|
212
212
|
end
|
213
213
|
end
|
@@ -80,7 +80,7 @@ module GdsApi
|
|
80
80
|
body: "{}",
|
81
81
|
headers: { "Content-Type" => "application/json; charset=utf-8" },
|
82
82
|
}.merge(response_hash)
|
83
|
-
stub_request(:post, url).with(body:
|
83
|
+
stub_request(:post, url).with(body:).to_return(response)
|
84
84
|
end
|
85
85
|
|
86
86
|
# Stub a POST /v2/content/:content_id/republish request
|
@@ -95,7 +95,7 @@ module GdsApi
|
|
95
95
|
body: "{}",
|
96
96
|
headers: { "Content-Type" => "application/json; charset=utf-8" },
|
97
97
|
}.merge(response_hash)
|
98
|
-
stub_request(:post, url).with(body:
|
98
|
+
stub_request(:post, url).with(body:).to_return(response)
|
99
99
|
end
|
100
100
|
|
101
101
|
# Stub a POST /v2/content/:content_id/unpublish request
|
@@ -271,9 +271,9 @@ module GdsApi
|
|
271
271
|
end
|
272
272
|
|
273
273
|
if matcher
|
274
|
-
assert_requested(verb, url, times
|
274
|
+
assert_requested(verb, url, times:, &matcher)
|
275
275
|
else
|
276
|
-
assert_requested(verb, url, times:
|
276
|
+
assert_requested(verb, url, times:)
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
@@ -617,7 +617,7 @@ module GdsApi
|
|
617
617
|
results = results.take(per_page)
|
618
618
|
|
619
619
|
body = {
|
620
|
-
results
|
620
|
+
results:,
|
621
621
|
links: [
|
622
622
|
{ rel: "self", href: "#{PUBLISHING_API_V2_ENDPOINT}/editions" },
|
623
623
|
],
|
@@ -664,7 +664,7 @@ module GdsApi
|
|
664
664
|
response = {
|
665
665
|
status: 200,
|
666
666
|
headers: { content_type: "application/json" },
|
667
|
-
body
|
667
|
+
body:,
|
668
668
|
}
|
669
669
|
stub_request(:put, url).with(body: params).to_return(response)
|
670
670
|
end
|
@@ -691,9 +691,9 @@ module GdsApi
|
|
691
691
|
end
|
692
692
|
|
693
693
|
if matcher
|
694
|
-
assert_requested(:put, url, times
|
694
|
+
assert_requested(:put, url, times:, &matcher)
|
695
695
|
else
|
696
|
-
assert_requested(:put, url, times:
|
696
|
+
assert_requested(:put, url, times:)
|
697
697
|
end
|
698
698
|
end
|
699
699
|
|
@@ -728,7 +728,7 @@ module GdsApi
|
|
728
728
|
response = {
|
729
729
|
status: 200,
|
730
730
|
headers: { content_type: "application/json" },
|
731
|
-
body: params.merge(base_path:
|
731
|
+
body: params.merge(base_path:).to_json,
|
732
732
|
}
|
733
733
|
|
734
734
|
stub_request(:put, url).with(body: params).to_return(response)
|
@@ -741,7 +741,7 @@ module GdsApi
|
|
741
741
|
def stub_any_publishing_api_path_reservation
|
742
742
|
stub_request(:put, %r{\A#{PUBLISHING_API_ENDPOINT}/paths/}).to_return do |request|
|
743
743
|
base_path = request.uri.path.sub(%r{\A/paths}, "")
|
744
|
-
body = JSON.parse(request.body).merge(base_path:
|
744
|
+
body = JSON.parse(request.body).merge(base_path:)
|
745
745
|
{
|
746
746
|
status: 200,
|
747
747
|
headers: { content_type: "application/json" },
|
@@ -768,13 +768,13 @@ module GdsApi
|
|
768
768
|
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}")
|
769
769
|
.to_return(status: 422,
|
770
770
|
headers: { content_type: "application/json" },
|
771
|
-
body: { error:
|
771
|
+
body: { error: }.to_json)
|
772
772
|
|
773
773
|
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}")
|
774
774
|
.with(body: { "publishing_app" => publishing_app })
|
775
775
|
.to_return(status: 200,
|
776
776
|
headers: { content_type: "application/json" },
|
777
|
-
body: { publishing_app
|
777
|
+
body: { publishing_app:, base_path: path }.to_json)
|
778
778
|
end
|
779
779
|
|
780
780
|
# Stub a PUT /paths/:base_path request for a particular publishing
|
@@ -794,12 +794,12 @@ module GdsApi
|
|
794
794
|
|
795
795
|
message = "#{error_fields.keys.first.to_s.capitalize.gsub(/_/, ' ')} #{error_fields.values.flatten.first}"
|
796
796
|
|
797
|
-
error = { code: 422, message
|
797
|
+
error = { code: 422, message:, fields: error_fields }
|
798
798
|
|
799
799
|
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{base_path}")
|
800
800
|
.to_return(status: 422,
|
801
801
|
headers: { content_type: "application/json" },
|
802
|
-
body: { error:
|
802
|
+
body: { error: }.to_json)
|
803
803
|
end
|
804
804
|
|
805
805
|
private
|
@@ -817,7 +817,7 @@ module GdsApi
|
|
817
817
|
response_hash.merge!(override_response_hash)
|
818
818
|
response_hash[:body] = response_hash[:body].to_json if response_hash[:body].is_a?(Hash)
|
819
819
|
url = "#{PUBLISHING_API_V2_ENDPOINT}#{resource_path}/#{content_id}"
|
820
|
-
stub_request(method, url).with(body:
|
820
|
+
stub_request(method, url).with(body:).to_return(response_hash)
|
821
821
|
end
|
822
822
|
|
823
823
|
def deep_stringify_keys(hash)
|
@@ -858,8 +858,8 @@ module GdsApi
|
|
858
858
|
|
859
859
|
def stub_publishing_api_unreserve_path_with_code(base_path, publishing_app, code)
|
860
860
|
url = "#{PUBLISHING_API_ENDPOINT}/paths#{base_path}"
|
861
|
-
body = { publishing_app:
|
862
|
-
stub_request(:delete, url).with(body:
|
861
|
+
body = { publishing_app: }
|
862
|
+
stub_request(:delete, url).with(body:).to_return(status: code, body: "{}", headers: { "Content-Type" => "application/json; charset=utf-8" })
|
863
863
|
end
|
864
864
|
|
865
865
|
def values_match_recursively(expected_value, actual_value)
|
@@ -18,15 +18,15 @@ module GdsApi
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def stub_router_has_backend_route(path, backend_id:, route_type: "exact", disabled: false)
|
21
|
-
stub_router_has_route(path, handler: "backend", backend_id
|
21
|
+
stub_router_has_route(path, handler: "backend", backend_id:, disabled:, route_type:)
|
22
22
|
end
|
23
23
|
|
24
24
|
def stub_router_has_redirect_route(path, redirect_to:, redirect_type: "permanent", route_type: "exact", disabled: false)
|
25
|
-
stub_router_has_route(path, handler: "redirect", redirect_to
|
25
|
+
stub_router_has_route(path, handler: "redirect", redirect_to:, redirect_type:, disabled:, route_type:)
|
26
26
|
end
|
27
27
|
|
28
28
|
def stub_router_has_gone_route(path, route_type: "exact", disabled: false)
|
29
|
-
stub_router_has_route(path, handler: "gone", route_type
|
29
|
+
stub_router_has_route(path, handler: "gone", route_type:, disabled:)
|
30
30
|
end
|
31
31
|
|
32
32
|
def stub_all_router_registration
|
@@ -47,7 +47,7 @@ module GdsApi
|
|
47
47
|
incoming_path: path,
|
48
48
|
route_type: type,
|
49
49
|
handler: "backend",
|
50
|
-
backend_id
|
50
|
+
backend_id:,
|
51
51
|
},
|
52
52
|
})
|
53
53
|
end
|
@@ -59,8 +59,8 @@ module GdsApi
|
|
59
59
|
route_type: type,
|
60
60
|
handler: "redirect",
|
61
61
|
redirect_to: destination,
|
62
|
-
redirect_type
|
63
|
-
segments_mode
|
62
|
+
redirect_type:,
|
63
|
+
segments_mode:,
|
64
64
|
},
|
65
65
|
})
|
66
66
|
end
|
@@ -115,7 +115,7 @@ module GdsApi
|
|
115
115
|
|
116
116
|
def stub_support_api_organisation(slug = "cabinet-office", response_body = nil)
|
117
117
|
response_body ||= {
|
118
|
-
slug
|
118
|
+
slug:,
|
119
119
|
web_url: "https://www.gov.uk/government/organisations/#{slug}",
|
120
120
|
title: "Cabinet Office",
|
121
121
|
acronym: "CO",
|
data/lib/gds_api/version.rb
CHANGED