gds-api-adapters 63.3.0 → 67.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/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"
|
@@ -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"
|
@@ -174,20 +172,19 @@ module GdsApi
|
|
174
172
|
stub_request(:post, %r{\A#{PUBLISHING_API_V2_ENDPOINT}/content/.*/discard-draft})
|
175
173
|
end
|
176
174
|
|
177
|
-
# Stub any
|
175
|
+
# Stub any request to the publishing API
|
178
176
|
def stub_any_publishing_api_call
|
179
|
-
stub_request(:any, %r{\A#{
|
177
|
+
stub_request(:any, %r{\A#{PUBLISHING_API_ENDPOINT}})
|
180
178
|
end
|
181
179
|
|
182
|
-
# Stub any
|
180
|
+
# Stub any request to the publishing API to return a 404 response
|
183
181
|
def stub_any_publishing_api_call_to_return_not_found
|
184
|
-
stub_request(:any, %r{\A#{
|
182
|
+
stub_request(:any, %r{\A#{PUBLISHING_API_ENDPOINT}})
|
185
183
|
.to_return(status: 404, headers: { "Content-Type" => "application/json; charset=utf-8" })
|
186
184
|
end
|
187
185
|
|
188
|
-
# Stub any
|
186
|
+
# Stub any request to the publishing API to return a 503 response
|
189
187
|
def stub_publishing_api_isnt_available
|
190
|
-
stub_request(:any, /#{PUBLISHING_API_V2_ENDPOINT}\/.*/).to_return(status: 503)
|
191
188
|
stub_request(:any, /#{PUBLISHING_API_ENDPOINT}\/.*/).to_return(status: 503)
|
192
189
|
end
|
193
190
|
|
@@ -267,11 +264,11 @@ module GdsApi
|
|
267
264
|
# @param attributes_or_matcher [Object]
|
268
265
|
# @param times [Integer]
|
269
266
|
def assert_publishing_api(verb, url, attributes_or_matcher = nil, times = 1)
|
270
|
-
if attributes_or_matcher.is_a?(Hash)
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
267
|
+
matcher = if attributes_or_matcher.is_a?(Hash)
|
268
|
+
request_json_matches(attributes_or_matcher)
|
269
|
+
else
|
270
|
+
attributes_or_matcher
|
271
|
+
end
|
275
272
|
|
276
273
|
if matcher
|
277
274
|
assert_requested(verb, url, times: times, &matcher)
|
@@ -282,16 +279,16 @@ module GdsApi
|
|
282
279
|
|
283
280
|
# Get a request matcher that checks if a JSON request includes a set of attributes
|
284
281
|
def request_json_includes(required_attributes)
|
285
|
-
|
282
|
+
lambda do |request|
|
286
283
|
data = JSON.parse(request.body)
|
287
|
-
deep_stringify_keys(required_attributes)
|
288
|
-
to_a.all? { |key, value| data[key] == value }
|
284
|
+
deep_stringify_keys(required_attributes)
|
285
|
+
.to_a.all? { |key, value| data[key] == value }
|
289
286
|
end
|
290
287
|
end
|
291
288
|
|
292
289
|
# Get a request matcher that checks if a JSON request matches a hash
|
293
290
|
def request_json_matches(required_attributes)
|
294
|
-
|
291
|
+
lambda do |request|
|
295
292
|
data = JSON.parse(request.body)
|
296
293
|
deep_stringify_keys(required_attributes) == data
|
297
294
|
end
|
@@ -346,13 +343,13 @@ module GdsApi
|
|
346
343
|
# This method has been refactored into publishing_api_has_content (above)
|
347
344
|
# publishing_api_has_content allows for flexible passing in of arguments, please use instead
|
348
345
|
def stub_publishing_api_has_fields_for_document(document_type, items, fields)
|
349
|
-
body = Array(items).map
|
346
|
+
body = Array(items).map do |item|
|
350
347
|
deep_stringify_keys(item).slice(*fields)
|
351
|
-
|
348
|
+
end
|
352
349
|
|
353
|
-
query_params = fields.map
|
350
|
+
query_params = fields.map do |f|
|
354
351
|
"&fields%5B%5D=#{f}"
|
355
|
-
|
352
|
+
end
|
356
353
|
|
357
354
|
url = PUBLISHING_API_V2_ENDPOINT + "/content?document_type=#{document_type}#{query_params.join('')}"
|
358
355
|
|
@@ -495,7 +492,7 @@ module GdsApi
|
|
495
492
|
def stub_publishing_api_has_expanded_links(links, with_drafts: true, generate: false)
|
496
493
|
links = deep_transform_keys(links, &:to_sym)
|
497
494
|
request_params = {}
|
498
|
-
request_params["with_drafts"] = false
|
495
|
+
request_params["with_drafts"] = false unless with_drafts
|
499
496
|
request_params["generate"] = true if generate
|
500
497
|
|
501
498
|
url = PUBLISHING_API_V2_ENDPOINT + "/expanded-links/" + links[:content_id]
|
@@ -577,7 +574,7 @@ module GdsApi
|
|
577
574
|
def stub_publishing_api_has_linked_items(items, params = {})
|
578
575
|
content_id = params.fetch(:content_id)
|
579
576
|
link_type = params.fetch(:link_type)
|
580
|
-
fields = params.fetch(:fields, %w
|
577
|
+
fields = params.fetch(:fields, %w[base_path content_id document_type title])
|
581
578
|
|
582
579
|
url = PUBLISHING_API_V2_ENDPOINT + "/linked/#{content_id}"
|
583
580
|
|
@@ -641,6 +638,10 @@ module GdsApi
|
|
641
638
|
stub_publishing_api_unreserve_path_with_code(base_path, publishing_app, 422)
|
642
639
|
end
|
643
640
|
|
641
|
+
def stub_any_publishing_api_unreserve_path
|
642
|
+
stub_request(:delete, %r{\A#{PUBLISHING_API_ENDPOINT}/paths/})
|
643
|
+
end
|
644
|
+
|
644
645
|
# Stub a PUT /publish-intent/:base_path request with the given base_path
|
645
646
|
# and request body.
|
646
647
|
#
|
@@ -681,11 +682,11 @@ module GdsApi
|
|
681
682
|
end
|
682
683
|
|
683
684
|
def assert_publishing_api_put(url, attributes_or_matcher = {}, times = 1)
|
684
|
-
if attributes_or_matcher.is_a?(Hash)
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
685
|
+
matcher = if attributes_or_matcher.is_a?(Hash)
|
686
|
+
attributes_or_matcher.empty? ? nil : request_json_matching(attributes_or_matcher)
|
687
|
+
else
|
688
|
+
attributes_or_matcher
|
689
|
+
end
|
689
690
|
|
690
691
|
if matcher
|
691
692
|
assert_requested(:put, url, times: times, &matcher)
|
@@ -695,14 +696,14 @@ module GdsApi
|
|
695
696
|
end
|
696
697
|
|
697
698
|
def request_json_matching(required_attributes)
|
698
|
-
|
699
|
+
lambda do |request|
|
699
700
|
data = JSON.parse(request.body)
|
700
701
|
required_attributes.to_a.all? { |key, value| data[key.to_s] == value }
|
701
702
|
end
|
702
703
|
end
|
703
704
|
|
704
705
|
def request_json_including(required_attributes)
|
705
|
-
|
706
|
+
lambda do |request|
|
706
707
|
data = JSON.parse(request.body)
|
707
708
|
values_match_recursively(required_attributes, data)
|
708
709
|
end
|
@@ -736,7 +737,7 @@ module GdsApi
|
|
736
737
|
# @example
|
737
738
|
# stub_any_publishing_api_path_reservation
|
738
739
|
def stub_any_publishing_api_path_reservation
|
739
|
-
stub_request(:put, %r
|
740
|
+
stub_request(:put, %r{\A#{PUBLISHING_API_ENDPOINT}/paths/}).to_return do |request|
|
740
741
|
base_path = request.uri.path.sub(%r{\A/paths}, "")
|
741
742
|
body = JSON.parse(request.body).merge(base_path: base_path)
|
742
743
|
{
|
@@ -762,16 +763,16 @@ module GdsApi
|
|
762
763
|
message: "Base path #{message}",
|
763
764
|
fields: { base_path: [message] } }
|
764
765
|
|
765
|
-
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}")
|
766
|
-
to_return(status: 422,
|
767
|
-
|
768
|
-
|
766
|
+
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}")
|
767
|
+
.to_return(status: 422,
|
768
|
+
headers: { content_type: "application/json" },
|
769
|
+
body: { error: error }.to_json)
|
769
770
|
|
770
|
-
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}")
|
771
|
-
with(body: { "publishing_app" => publishing_app })
|
772
|
-
to_return(status: 200,
|
773
|
-
|
774
|
-
|
771
|
+
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}")
|
772
|
+
.with(body: { "publishing_app" => publishing_app })
|
773
|
+
.to_return(status: 200,
|
774
|
+
headers: { content_type: "application/json" },
|
775
|
+
body: { publishing_app: publishing_app, base_path: path }.to_json)
|
775
776
|
end
|
776
777
|
|
777
778
|
# Stub a PUT /paths/:base_path request for a particular publishing
|
@@ -794,30 +795,11 @@ module GdsApi
|
|
794
795
|
|
795
796
|
error = { code: 422, message: message, fields: error_fields }
|
796
797
|
|
797
|
-
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{base_path}")
|
798
|
-
to_return(status: 422,
|
799
|
-
|
800
|
-
|
801
|
-
end
|
802
|
-
|
803
|
-
alias_deprecated :publishing_api_isnt_available, :stub_publishing_api_isnt_available
|
804
|
-
alias_deprecated :publishing_api_has_content, :stub_publishing_api_has_content
|
805
|
-
alias_deprecated :publishing_api_has_fields_for_document, :stub_publishing_api_has_fields_for_document
|
806
|
-
alias_deprecated :publishing_api_has_linkables, :stub_publishing_api_has_linkables
|
807
|
-
alias_deprecated :publishing_api_has_item, :stub_publishing_api_has_item
|
808
|
-
alias_deprecated :publishing_api_has_item_in_sequence, :stub_publishing_api_has_item_in_sequence
|
809
|
-
alias_deprecated :publishing_api_does_not_have_item, :stub_publishing_api_does_not_have_item
|
810
|
-
alias_deprecated :publishing_api_has_links, :stub_publishing_api_has_links
|
811
|
-
alias_deprecated :publishing_api_has_expanded_links, :stub_publishing_api_has_expanded_links
|
812
|
-
alias_deprecated :publishing_api_has_links_for_content_ids, :stub_publishing_api_has_links_for_content_ids
|
813
|
-
alias_deprecated :publishing_api_does_not_have_links, :stub_publishing_api_does_not_have_links
|
814
|
-
alias_deprecated :publishing_api_has_lookups, :stub_publishing_api_has_lookups
|
815
|
-
alias_deprecated :publishing_api_has_linked_items, :stub_publishing_api_has_linked_items
|
816
|
-
alias_deprecated :publishing_api_get_editions, :stub_publishing_api_get_editions
|
817
|
-
alias_deprecated :publishing_api_has_path_reservation_for, :stub_publishing_api_has_path_reservation_for
|
818
|
-
alias_deprecated :publishing_api_returns_path_reservation_validation_error_for, :stub_publishing_api_returns_path_reservation_validation_error_for
|
819
|
-
alias_deprecated :stub_default_publishing_api_path_reservation, :stub_any_publishing_api_path_reservation
|
820
|
-
alias_deprecated :stub_default_publishing_api_put_intent, :stub_any_publishing_api_put_intent
|
798
|
+
stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{base_path}")
|
799
|
+
.to_return(status: 422,
|
800
|
+
headers: { content_type: "application/json" },
|
801
|
+
body: { error: error }.to_json)
|
802
|
+
end
|
821
803
|
|
822
804
|
private
|
823
805
|
|
@@ -885,7 +867,7 @@ module GdsApi
|
|
885
867
|
return false unless actual_value.is_a?(Hash)
|
886
868
|
|
887
869
|
expected_value.all? do |expected_sub_key, expected_sub_value|
|
888
|
-
actual_value.
|
870
|
+
actual_value.key?(expected_sub_key.to_s) &&
|
889
871
|
values_match_recursively(expected_sub_value, actual_value[expected_sub_key.to_s])
|
890
872
|
end
|
891
873
|
when Array
|
@@ -17,11 +17,11 @@ module GdsApi
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def assert_search_posted_item(attributes, index: nil, **options)
|
20
|
-
if index
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
url = if index
|
21
|
+
SEARCH_ENDPOINT + "/#{index}/documents"
|
22
|
+
else
|
23
|
+
SEARCH_ENDPOINT + "/documents"
|
24
|
+
end
|
25
25
|
|
26
26
|
assert_requested(:post, url, **options) do |req|
|
27
27
|
data = JSON.parse(req.body)
|
@@ -1,9 +1,6 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
|
-
|
3
1
|
module GdsApi
|
4
2
|
module TestHelpers
|
5
3
|
module Support
|
6
|
-
extend AliasDeprecated
|
7
4
|
SUPPORT_ENDPOINT = Plek.current.find("support")
|
8
5
|
|
9
6
|
def stub_support_foi_request_creation(request_details = nil)
|
@@ -21,8 +18,6 @@ module GdsApi
|
|
21
18
|
def stub_support_isnt_available
|
22
19
|
stub_request(:post, /#{SUPPORT_ENDPOINT}\/.*/).to_return(status: 503)
|
23
20
|
end
|
24
|
-
|
25
|
-
alias_deprecated :support_isnt_available, :stub_support_isnt_available
|
26
21
|
end
|
27
22
|
end
|
28
23
|
end
|
@@ -1,11 +1,9 @@
|
|
1
|
-
require "gds_api/test_helpers/alias_deprecated"
|
2
1
|
require "cgi"
|
3
2
|
require "plek"
|
4
3
|
|
5
4
|
module GdsApi
|
6
5
|
module TestHelpers
|
7
6
|
module SupportApi
|
8
|
-
extend AliasDeprecated
|
9
7
|
SUPPORT_API_ENDPOINT = Plek.current.find("support-api")
|
10
8
|
|
11
9
|
def stub_support_api_problem_report_creation(request_details = nil)
|
@@ -65,9 +63,9 @@ module GdsApi
|
|
65
63
|
end
|
66
64
|
|
67
65
|
def stub_support_api_problem_reports(params, response_body = {})
|
68
|
-
stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/problem-reports")
|
69
|
-
with(query: params)
|
70
|
-
to_return(status: 200, body: response_body.to_json)
|
66
|
+
stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/problem-reports")
|
67
|
+
.with(query: params)
|
68
|
+
.to_return(status: 200, body: response_body.to_json)
|
71
69
|
end
|
72
70
|
|
73
71
|
def stub_support_api_mark_reviewed_for_spam(request_details = nil, response_body = {})
|
@@ -89,8 +87,8 @@ module GdsApi
|
|
89
87
|
def stub_support_api_anonymous_feedback_organisation_summary(slug, ordering = nil, response_body = {})
|
90
88
|
uri = "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/organisations/#{slug}"
|
91
89
|
uri << "?ordering=#{ordering}" if ordering
|
92
|
-
stub_http_request(:get, uri)
|
93
|
-
to_return(status: 200, body: response_body.to_json)
|
90
|
+
stub_http_request(:get, uri)
|
91
|
+
.to_return(status: 200, body: response_body.to_json)
|
94
92
|
end
|
95
93
|
|
96
94
|
def stub_support_api_organisations_list(response_body = nil)
|
@@ -111,8 +109,8 @@ module GdsApi
|
|
111
109
|
},
|
112
110
|
]
|
113
111
|
|
114
|
-
stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/organisations")
|
115
|
-
to_return(status: 200, body: response_body.to_json)
|
112
|
+
stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/organisations")
|
113
|
+
.to_return(status: 200, body: response_body.to_json)
|
116
114
|
end
|
117
115
|
|
118
116
|
def stub_support_api_organisation(slug = "cabinet-office", response_body = nil)
|
@@ -124,22 +122,22 @@ module GdsApi
|
|
124
122
|
govuk_status: "live",
|
125
123
|
}
|
126
124
|
|
127
|
-
stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/organisations/#{slug}")
|
128
|
-
to_return(status: 200, body: response_body.to_json)
|
125
|
+
stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/organisations/#{slug}")
|
126
|
+
.to_return(status: 200, body: response_body.to_json)
|
129
127
|
end
|
130
128
|
|
131
129
|
def stub_support_api_document_type_list(response_body = nil)
|
132
|
-
response_body ||= %w
|
130
|
+
response_body ||= %w[case_study detailed_guide smart_answer]
|
133
131
|
|
134
|
-
stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/document-types")
|
135
|
-
to_return(status: 200, body: response_body.to_json)
|
132
|
+
stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/document-types")
|
133
|
+
.to_return(status: 200, body: response_body.to_json)
|
136
134
|
end
|
137
135
|
|
138
136
|
def stub_support_api_anonymous_feedback_doc_type_summary(document_type, ordering = nil, response_body = nil)
|
139
137
|
uri = "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/document-types/#{document_type}"
|
140
138
|
uri << "?ordering=#{ordering}" if ordering
|
141
|
-
stub_http_request(:get, uri)
|
142
|
-
to_return(status: 200, body: response_body.to_json)
|
139
|
+
stub_http_request(:get, uri)
|
140
|
+
.to_return(status: 200, body: response_body.to_json)
|
143
141
|
end
|
144
142
|
|
145
143
|
def stub_support_api_feedback_export_request(id, response_body = nil)
|
@@ -148,15 +146,13 @@ module GdsApi
|
|
148
146
|
ready: true,
|
149
147
|
}
|
150
148
|
|
151
|
-
stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/export-requests/#{id}")
|
152
|
-
to_return(status: 200, body: response_body.to_json)
|
149
|
+
stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/export-requests/#{id}")
|
150
|
+
.to_return(status: 200, body: response_body.to_json)
|
153
151
|
end
|
154
152
|
|
155
153
|
def stub_any_support_api_call
|
156
154
|
stub_request(:any, %r{\A#{SUPPORT_API_ENDPOINT}})
|
157
155
|
end
|
158
|
-
|
159
|
-
alias_deprecated :support_api_isnt_available, :stub_support_api_isnt_available
|
160
156
|
end
|
161
157
|
end
|
162
158
|
end
|
@@ -1,14 +1,12 @@
|
|
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
|
|
5
4
|
module GdsApi
|
6
5
|
module TestHelpers
|
7
6
|
module Worldwide
|
8
|
-
extend AliasDeprecated
|
9
7
|
include GdsApi::TestHelpers::CommonResponses
|
10
8
|
|
11
|
-
WORLDWIDE_API_ENDPOINT = Plek.
|
9
|
+
WORLDWIDE_API_ENDPOINT = Plek.new.website_root
|
12
10
|
|
13
11
|
# Sets up the index endpoints for the given country slugs
|
14
12
|
# The stubs are setup to paginate in chunks of 20
|
@@ -23,12 +21,14 @@ module GdsApi
|
|
23
21
|
end
|
24
22
|
|
25
23
|
pages.each_with_index do |page, i|
|
26
|
-
page_details = plural_response_base.merge(
|
24
|
+
page_details = plural_response_base.merge(
|
25
|
+
"results" => page,
|
27
26
|
"total" => location_slugs.size,
|
28
27
|
"pages" => pages.size,
|
29
28
|
"current_page" => i + 1,
|
30
29
|
"page_size" => 20,
|
31
|
-
"start_index" => i * 20 + 1
|
30
|
+
"start_index" => i * 20 + 1,
|
31
|
+
)
|
32
32
|
|
33
33
|
links = { self: "#{WORLDWIDE_API_ENDPOINT}/api/world-locations?page=#{i + 1}" }
|
34
34
|
links[:next] = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations?page=#{i + 2}" if pages[i + 1]
|
@@ -40,32 +40,59 @@ module GdsApi
|
|
40
40
|
link_headers << "<#{href}>; rel=\"#{rel}\""
|
41
41
|
end
|
42
42
|
|
43
|
-
stub_request(:get, links[:self])
|
44
|
-
to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
|
43
|
+
stub_request(:get, links[:self])
|
44
|
+
.to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
next unless i.zero?
|
47
|
+
|
48
|
+
# First page exists at URL with and without page param
|
49
|
+
stub_request(:get, links[:self].sub(/\?page=1/, ""))
|
50
|
+
.to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
def stub_worldwide_api_has_selection_of_locations
|
55
|
-
stub_worldwide_api_has_locations %w
|
56
|
-
afghanistan
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
stub_worldwide_api_has_locations %w[
|
56
|
+
afghanistan
|
57
|
+
angola
|
58
|
+
australia
|
59
|
+
bahamas
|
60
|
+
belarus
|
61
|
+
brazil
|
62
|
+
brunei
|
63
|
+
cambodia
|
64
|
+
chad
|
65
|
+
croatia
|
66
|
+
denmark
|
67
|
+
eritrea
|
68
|
+
france
|
69
|
+
ghana
|
70
|
+
iceland
|
71
|
+
japan
|
72
|
+
laos
|
73
|
+
luxembourg
|
74
|
+
malta
|
75
|
+
micronesia
|
76
|
+
mozambique
|
77
|
+
nicaragua
|
78
|
+
panama
|
79
|
+
portugal
|
80
|
+
sao-tome-and-principe
|
81
|
+
singapore
|
82
|
+
south-korea
|
83
|
+
sri-lanka
|
84
|
+
uk-delegation-to-council-of-europe
|
60
85
|
uk-delegation-to-organization-for-security-and-co-operation-in-europe
|
61
|
-
united-kingdom
|
62
|
-
|
86
|
+
united-kingdom
|
87
|
+
venezuela
|
88
|
+
vietnam
|
89
|
+
]
|
63
90
|
end
|
64
91
|
|
65
92
|
def stub_worldwide_api_has_location(location_slug, details = nil)
|
66
93
|
details ||= world_location_for_slug(location_slug)
|
67
|
-
stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}")
|
68
|
-
to_return(status: 200, body: details.to_json)
|
94
|
+
stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}")
|
95
|
+
.to_return(status: 200, body: details.to_json)
|
69
96
|
end
|
70
97
|
|
71
98
|
def stub_worldwide_api_does_not_have_location(location_slug)
|
@@ -75,15 +102,15 @@ module GdsApi
|
|
75
102
|
def stub_worldwide_api_has_organisations_for_location(location_slug, json_or_hash)
|
76
103
|
json = json_or_hash.is_a?(Hash) ? json_or_hash.to_json : json_or_hash
|
77
104
|
url = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}/organisations"
|
78
|
-
stub_request(:get, url)
|
79
|
-
to_return(status: 200, body: json, headers: { "Link" => "<#{url}; rel\"self\"" })
|
105
|
+
stub_request(:get, url)
|
106
|
+
.to_return(status: 200, body: json, headers: { "Link" => "<#{url}; rel\"self\"" })
|
80
107
|
end
|
81
108
|
|
82
109
|
def stub_worldwide_api_has_no_organisations_for_location(location_slug)
|
83
110
|
details = { "results" => [], "total" => 0, "_response_info" => { "status" => "ok" } }
|
84
111
|
url = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}/organisations"
|
85
|
-
stub_request(:get, url)
|
86
|
-
to_return(status: 200, body: details.to_json, headers: { "Link" => "<#{url}; rel\"self\"" })
|
112
|
+
stub_request(:get, url)
|
113
|
+
.to_return(status: 200, body: details.to_json, headers: { "Link" => "<#{url}; rel\"self\"" })
|
87
114
|
end
|
88
115
|
|
89
116
|
def world_location_for_slug(slug)
|
@@ -112,13 +139,6 @@ module GdsApi
|
|
112
139
|
"content_id" => "content_id_for_#{slug}",
|
113
140
|
}
|
114
141
|
end
|
115
|
-
|
116
|
-
alias_deprecated :worldwide_api_has_locations, :stub_worldwide_api_has_locations
|
117
|
-
alias_deprecated :worldwide_api_has_selection_of_locations, :stub_worldwide_api_has_selection_of_locations
|
118
|
-
alias_deprecated :worldwide_api_has_location, :stub_worldwide_api_has_location
|
119
|
-
alias_deprecated :worldwide_api_has_does_not_have_location, :stub_worldwide_api_does_not_have_location
|
120
|
-
alias_deprecated :worldwide_api_has_organisations_for_location, :stub_worldwide_api_has_organisations_for_location
|
121
|
-
alias_deprecated :worldwide_api_has_no_organisations_for_location, :stub_worldwide_api_has_no_organisations_for_location
|
122
142
|
end
|
123
143
|
end
|
124
144
|
end
|