gds-api-adapters 63.5.1 → 67.1.1
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 +2 -14
- data/lib/gds_api/asset_manager.rb +1 -1
- data/lib/gds_api/base.rb +8 -3
- data/lib/gds_api/email_alert_api.rb +10 -12
- data/lib/gds_api/exceptions.rb +3 -4
- data/lib/gds_api/imminence.rb +3 -3
- 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 +80 -6
- 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 +11 -35
- 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 +42 -61
- 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 +51 -31
- data/lib/gds_api/version.rb +1 -1
- metadata +15 -32
- 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,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
|
@@ -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"
|
@@ -7,7 +6,6 @@ module GdsApi
|
|
7
6
|
module TestHelpers
|
8
7
|
# @api documented
|
9
8
|
module PublishingApi
|
10
|
-
extend AliasDeprecated
|
11
9
|
include ContentItemHelpers
|
12
10
|
|
13
11
|
PUBLISHING_API_V2_ENDPOINT = Plek.current.find("publishing-api") + "/v2"
|
@@ -266,11 +264,11 @@ module GdsApi
|
|
266
264
|
# @param attributes_or_matcher [Object]
|
267
265
|
# @param times [Integer]
|
268
266
|
def assert_publishing_api(verb, url, attributes_or_matcher = nil, times = 1)
|
269
|
-
if attributes_or_matcher.is_a?(Hash)
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
267
|
+
matcher = if attributes_or_matcher.is_a?(Hash)
|
268
|
+
request_json_matches(attributes_or_matcher)
|
269
|
+
else
|
270
|
+
attributes_or_matcher
|
271
|
+
end
|
274
272
|
|
275
273
|
if matcher
|
276
274
|
assert_requested(verb, url, times: times, &matcher)
|
@@ -281,16 +279,16 @@ module GdsApi
|
|
281
279
|
|
282
280
|
# Get a request matcher that checks if a JSON request includes a set of attributes
|
283
281
|
def request_json_includes(required_attributes)
|
284
|
-
|
282
|
+
lambda do |request|
|
285
283
|
data = JSON.parse(request.body)
|
286
|
-
deep_stringify_keys(required_attributes)
|
287
|
-
to_a.all? { |key, value| data[key] == value }
|
284
|
+
deep_stringify_keys(required_attributes)
|
285
|
+
.to_a.all? { |key, value| data[key] == value }
|
288
286
|
end
|
289
287
|
end
|
290
288
|
|
291
289
|
# Get a request matcher that checks if a JSON request matches a hash
|
292
290
|
def request_json_matches(required_attributes)
|
293
|
-
|
291
|
+
lambda do |request|
|
294
292
|
data = JSON.parse(request.body)
|
295
293
|
deep_stringify_keys(required_attributes) == data
|
296
294
|
end
|
@@ -345,13 +343,13 @@ module GdsApi
|
|
345
343
|
# This method has been refactored into publishing_api_has_content (above)
|
346
344
|
# publishing_api_has_content allows for flexible passing in of arguments, please use instead
|
347
345
|
def stub_publishing_api_has_fields_for_document(document_type, items, fields)
|
348
|
-
body = Array(items).map
|
346
|
+
body = Array(items).map do |item|
|
349
347
|
deep_stringify_keys(item).slice(*fields)
|
350
|
-
|
348
|
+
end
|
351
349
|
|
352
|
-
query_params = fields.map
|
350
|
+
query_params = fields.map do |f|
|
353
351
|
"&fields%5B%5D=#{f}"
|
354
|
-
|
352
|
+
end
|
355
353
|
|
356
354
|
url = PUBLISHING_API_V2_ENDPOINT + "/content?document_type=#{document_type}#{query_params.join('')}"
|
357
355
|
|
@@ -396,9 +394,11 @@ module GdsApi
|
|
396
394
|
# Stub GET /v2/content/:content_id to return a 404 response
|
397
395
|
#
|
398
396
|
# @param content_id [UUID]
|
399
|
-
def stub_publishing_api_does_not_have_item(content_id)
|
397
|
+
def stub_publishing_api_does_not_have_item(content_id, params = {})
|
400
398
|
url = PUBLISHING_API_V2_ENDPOINT + "/content/" + content_id
|
401
|
-
stub_request(:get, url)
|
399
|
+
stub_request(:get, url)
|
400
|
+
.with(query: hash_including(params))
|
401
|
+
.to_return(status: 404, body: resource_not_found(content_id, "content item").to_json, headers: {})
|
402
402
|
end
|
403
403
|
|
404
404
|
# Stub a request to links endpoint
|
@@ -494,7 +494,7 @@ module GdsApi
|
|
494
494
|
def stub_publishing_api_has_expanded_links(links, with_drafts: true, generate: false)
|
495
495
|
links = deep_transform_keys(links, &:to_sym)
|
496
496
|
request_params = {}
|
497
|
-
request_params["with_drafts"] = false
|
497
|
+
request_params["with_drafts"] = false unless with_drafts
|
498
498
|
request_params["generate"] = true if generate
|
499
499
|
|
500
500
|
url = PUBLISHING_API_V2_ENDPOINT + "/expanded-links/" + links[:content_id]
|
@@ -576,7 +576,7 @@ module GdsApi
|
|
576
576
|
def stub_publishing_api_has_linked_items(items, params = {})
|
577
577
|
content_id = params.fetch(:content_id)
|
578
578
|
link_type = params.fetch(:link_type)
|
579
|
-
fields = params.fetch(:fields, %w
|
579
|
+
fields = params.fetch(:fields, %w[base_path content_id document_type title])
|
580
580
|
|
581
581
|
url = PUBLISHING_API_V2_ENDPOINT + "/linked/#{content_id}"
|
582
582
|
|
@@ -684,11 +684,11 @@ module GdsApi
|
|
684
684
|
end
|
685
685
|
|
686
686
|
def assert_publishing_api_put(url, attributes_or_matcher = {}, times = 1)
|
687
|
-
if attributes_or_matcher.is_a?(Hash)
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
687
|
+
matcher = if attributes_or_matcher.is_a?(Hash)
|
688
|
+
attributes_or_matcher.empty? ? nil : request_json_matching(attributes_or_matcher)
|
689
|
+
else
|
690
|
+
attributes_or_matcher
|
691
|
+
end
|
692
692
|
|
693
693
|
if matcher
|
694
694
|
assert_requested(:put, url, times: times, &matcher)
|
@@ -698,14 +698,14 @@ module GdsApi
|
|
698
698
|
end
|
699
699
|
|
700
700
|
def request_json_matching(required_attributes)
|
701
|
-
|
701
|
+
lambda do |request|
|
702
702
|
data = JSON.parse(request.body)
|
703
703
|
required_attributes.to_a.all? { |key, value| data[key.to_s] == value }
|
704
704
|
end
|
705
705
|
end
|
706
706
|
|
707
707
|
def request_json_including(required_attributes)
|
708
|
-
|
708
|
+
lambda do |request|
|
709
709
|
data = JSON.parse(request.body)
|
710
710
|
values_match_recursively(required_attributes, data)
|
711
711
|
end
|
@@ -739,7 +739,7 @@ module GdsApi
|
|
739
739
|
# @example
|
740
740
|
# stub_any_publishing_api_path_reservation
|
741
741
|
def stub_any_publishing_api_path_reservation
|
742
|
-
stub_request(:put, %r
|
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
744
|
body = JSON.parse(request.body).merge(base_path: base_path)
|
745
745
|
{
|
@@ -765,16 +765,16 @@ module GdsApi
|
|
765
765
|
message: "Base path #{message}",
|
766
766
|
fields: { base_path: [message] } }
|
767
767
|
|
768
|
-
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}")
|
769
|
-
to_return(status: 422,
|
770
|
-
|
771
|
-
|
768
|
+
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}")
|
769
|
+
.to_return(status: 422,
|
770
|
+
headers: { content_type: "application/json" },
|
771
|
+
body: { error: error }.to_json)
|
772
772
|
|
773
|
-
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}")
|
774
|
-
with(body: { "publishing_app" => publishing_app })
|
775
|
-
to_return(status: 200,
|
776
|
-
|
777
|
-
|
773
|
+
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}")
|
774
|
+
.with(body: { "publishing_app" => publishing_app })
|
775
|
+
.to_return(status: 200,
|
776
|
+
headers: { content_type: "application/json" },
|
777
|
+
body: { publishing_app: 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
|
@@ -797,30 +797,11 @@ module GdsApi
|
|
797
797
|
|
798
798
|
error = { code: 422, message: message, fields: error_fields }
|
799
799
|
|
800
|
-
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{base_path}")
|
801
|
-
to_return(status: 422,
|
802
|
-
|
803
|
-
|
804
|
-
end
|
805
|
-
|
806
|
-
alias_deprecated :publishing_api_isnt_available, :stub_publishing_api_isnt_available
|
807
|
-
alias_deprecated :publishing_api_has_content, :stub_publishing_api_has_content
|
808
|
-
alias_deprecated :publishing_api_has_fields_for_document, :stub_publishing_api_has_fields_for_document
|
809
|
-
alias_deprecated :publishing_api_has_linkables, :stub_publishing_api_has_linkables
|
810
|
-
alias_deprecated :publishing_api_has_item, :stub_publishing_api_has_item
|
811
|
-
alias_deprecated :publishing_api_has_item_in_sequence, :stub_publishing_api_has_item_in_sequence
|
812
|
-
alias_deprecated :publishing_api_does_not_have_item, :stub_publishing_api_does_not_have_item
|
813
|
-
alias_deprecated :publishing_api_has_links, :stub_publishing_api_has_links
|
814
|
-
alias_deprecated :publishing_api_has_expanded_links, :stub_publishing_api_has_expanded_links
|
815
|
-
alias_deprecated :publishing_api_has_links_for_content_ids, :stub_publishing_api_has_links_for_content_ids
|
816
|
-
alias_deprecated :publishing_api_does_not_have_links, :stub_publishing_api_does_not_have_links
|
817
|
-
alias_deprecated :publishing_api_has_lookups, :stub_publishing_api_has_lookups
|
818
|
-
alias_deprecated :publishing_api_has_linked_items, :stub_publishing_api_has_linked_items
|
819
|
-
alias_deprecated :publishing_api_get_editions, :stub_publishing_api_get_editions
|
820
|
-
alias_deprecated :publishing_api_has_path_reservation_for, :stub_publishing_api_has_path_reservation_for
|
821
|
-
alias_deprecated :publishing_api_returns_path_reservation_validation_error_for, :stub_publishing_api_returns_path_reservation_validation_error_for
|
822
|
-
alias_deprecated :stub_default_publishing_api_path_reservation, :stub_any_publishing_api_path_reservation
|
823
|
-
alias_deprecated :stub_default_publishing_api_put_intent, :stub_any_publishing_api_put_intent
|
800
|
+
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{base_path}")
|
801
|
+
.to_return(status: 422,
|
802
|
+
headers: { content_type: "application/json" },
|
803
|
+
body: { error: error }.to_json)
|
804
|
+
end
|
824
805
|
|
825
806
|
private
|
826
807
|
|
@@ -888,7 +869,7 @@ module GdsApi
|
|
888
869
|
return false unless actual_value.is_a?(Hash)
|
889
870
|
|
890
871
|
expected_value.all? do |expected_sub_key, expected_sub_value|
|
891
|
-
actual_value.
|
872
|
+
actual_value.key?(expected_sub_key.to_s) &&
|
892
873
|
values_match_recursively(expected_sub_value, actual_value[expected_sub_key.to_s])
|
893
874
|
end
|
894
875
|
when Array
|