gds-api-adapters 38.0.0 → 38.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +5 -5
- data/lib/gds_api/asset_manager.rb +7 -7
- data/lib/gds_api/base.rb +13 -11
- data/lib/gds_api/business_support_api.rb +3 -4
- data/lib/gds_api/content_api.rb +31 -44
- data/lib/gds_api/content_store.rb +2 -3
- data/lib/gds_api/email_alert_api.rb +6 -7
- data/lib/gds_api/exceptions.rb +4 -1
- data/lib/gds_api/gov_uk_delivery.rb +9 -8
- data/lib/gds_api/govuk_headers.rb +1 -1
- data/lib/gds_api/imminence.rb +9 -10
- data/lib/gds_api/json_client.rb +21 -34
- data/lib/gds_api/licence_application.rb +2 -2
- data/lib/gds_api/list_response.rb +7 -10
- data/lib/gds_api/local_links_manager.rb +1 -1
- data/lib/gds_api/mapit.rb +5 -6
- data/lib/gds_api/middleware/govuk_header_sniffer.rb +1 -1
- data/lib/gds_api/need_api.rb +7 -8
- data/lib/gds_api/null_cache.rb +2 -2
- data/lib/gds_api/organisations.rb +2 -2
- data/lib/gds_api/panopticon.rb +11 -11
- data/lib/gds_api/performance_platform/data_in.rb +4 -4
- data/lib/gds_api/performance_platform/data_out.rb +1 -1
- data/lib/gds_api/publishing_api.rb +4 -5
- data/lib/gds_api/publishing_api/special_route_publisher.rb +5 -3
- data/lib/gds_api/publishing_api_v2.rb +8 -16
- data/lib/gds_api/response.rb +2 -5
- data/lib/gds_api/router.rb +18 -9
- data/lib/gds_api/rummager.rb +6 -7
- data/lib/gds_api/support.rb +7 -6
- data/lib/gds_api/support_api.rb +14 -14
- data/lib/gds_api/test_helpers/asset_manager.rb +3 -6
- data/lib/gds_api/test_helpers/business_support_api.rb +4 -4
- data/lib/gds_api/test_helpers/business_support_helper.rb +9 -8
- data/lib/gds_api/test_helpers/common_responses.rb +10 -12
- data/lib/gds_api/test_helpers/content_api.rb +23 -23
- data/lib/gds_api/test_helpers/content_api/artefact_stub.rb +13 -12
- data/lib/gds_api/test_helpers/content_item_helpers.rb +4 -4
- data/lib/gds_api/test_helpers/content_store.rb +3 -3
- data/lib/gds_api/test_helpers/email_alert_api.rb +8 -10
- data/lib/gds_api/test_helpers/gov_uk_delivery.rb +0 -1
- data/lib/gds_api/test_helpers/imminence.rb +4 -4
- data/lib/gds_api/test_helpers/intent_helpers.rb +0 -2
- data/lib/gds_api/test_helpers/local_links_manager.rb +12 -13
- data/lib/gds_api/test_helpers/mapit.rb +14 -15
- data/lib/gds_api/test_helpers/need_api.rb +4 -4
- data/lib/gds_api/test_helpers/organisations.rb +13 -15
- data/lib/gds_api/test_helpers/panopticon.rb +6 -6
- data/lib/gds_api/test_helpers/performance_platform/data_in.rb +8 -8
- data/lib/gds_api/test_helpers/publishing_api.rb +19 -20
- data/lib/gds_api/test_helpers/publishing_api_v2.rb +13 -13
- data/lib/gds_api/test_helpers/router.rb +5 -5
- data/lib/gds_api/test_helpers/rummager.rb +5 -4
- data/lib/gds_api/test_helpers/support.rb +11 -11
- data/lib/gds_api/test_helpers/support_api.rb +14 -14
- data/lib/gds_api/test_helpers/whitehall_admin_api.rb +1 -1
- data/lib/gds_api/test_helpers/worldwide.rb +16 -19
- data/lib/gds_api/version.rb +1 -1
- data/lib/gds_api/worldwide.rb +4 -4
- data/test/asset_manager_test.rb +6 -6
- data/test/business_support_api_test.rb +9 -10
- data/test/content_api_test.rb +81 -83
- data/test/email_alert_api_test.rb +3 -5
- data/test/gds_api_base_test.rb +9 -10
- data/test/gov_uk_delivery_test.rb +4 -6
- data/test/imminence_api_test.rb +7 -9
- data/test/json_client_test.rb +71 -64
- data/test/licence_application_api_test.rb +5 -7
- data/test/list_response_test.rb +27 -32
- data/test/mapit_test.rb +7 -9
- data/test/middleware/govuk_header_sniffer_test.rb +1 -1
- data/test/need_api_test.rb +8 -8
- data/test/organisations_api_test.rb +2 -2
- data/test/panopticon_registerer_test.rb +10 -10
- data/test/panopticon_test.rb +5 -5
- data/test/pp_data_in_test.rb +3 -3
- data/test/publishing_api_test.rb +2 -6
- data/test/publishing_api_v2_test.rb +40 -50
- data/test/response_test.rb +21 -22
- data/test/router_test.rb +78 -80
- data/test/rummager_test.rb +14 -14
- data/test/support_api_test.rb +13 -13
- data/test/support_test.rb +15 -16
- data/test/test_helper.rb +1 -1
- data/test/test_helpers/email_alert_api_test.rb +3 -3
- data/test/test_helpers/pact_helper.rb +1 -1
- data/test/test_helpers/panopticon_test.rb +1 -1
- data/test/test_helpers/publishing_api_test.rb +7 -7
- data/test/test_helpers/publishing_api_v2_test.rb +5 -9
- data/test/worldwide_api_test.rb +3 -3
- metadata +2 -3
- data/lib/gds_api/core-ext/openstruct.rb +0 -5
@@ -13,11 +13,11 @@ module GdsApi
|
|
13
13
|
setup_business_support_stubs(BUSINESS_SUPPORT_API_ENDPOINT, 'business-support-schemes')
|
14
14
|
end
|
15
15
|
|
16
|
-
def business_support_api_has_scheme(scheme, facets={})
|
16
|
+
def business_support_api_has_scheme(scheme, facets = {})
|
17
17
|
api_has_business_support(scheme, facets)
|
18
18
|
end
|
19
19
|
|
20
|
-
def business_support_api_has_schemes(schemes, facets={})
|
20
|
+
def business_support_api_has_schemes(schemes, facets = {})
|
21
21
|
schemes.each do |scheme|
|
22
22
|
business_support_api_has_scheme(scheme, facets)
|
23
23
|
end
|
@@ -25,8 +25,8 @@ module GdsApi
|
|
25
25
|
|
26
26
|
def business_support_api_has_a_scheme(slug, scheme)
|
27
27
|
title = scheme.delete(:title)
|
28
|
-
stub_request(:get, %r{\A#{BUSINESS_SUPPORT_API_ENDPOINT}/business-support-schemes/#{slug}\.json}).to_return do |
|
29
|
-
{:
|
28
|
+
stub_request(:get, %r{\A#{BUSINESS_SUPPORT_API_ENDPOINT}/business-support-schemes/#{slug}\.json}).to_return do |_request|
|
29
|
+
{ body: response_base.merge(format: 'business_support', title: title, details: scheme).to_json }
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -15,28 +15,29 @@ module GdsApi
|
|
15
15
|
else
|
16
16
|
results = @stubbed_business_supports
|
17
17
|
end
|
18
|
-
{:
|
18
|
+
{ body: plural_response_base.merge("results" => results, "total" => results.size).to_json }
|
19
19
|
end
|
20
|
-
|
21
20
|
end
|
22
21
|
|
23
|
-
def api_has_business_support(business_support, facets={})
|
22
|
+
def api_has_business_support(business_support, facets = {})
|
24
23
|
facets = sanitise_facets(facets)
|
24
|
+
|
25
25
|
if business_support.is_a?(Symbol)
|
26
|
-
bs_with_facets = facets.merge(:
|
26
|
+
bs_with_facets = facets.merge(title: business_support)
|
27
27
|
else
|
28
28
|
bs_with_facets = facets.merge(business_support)
|
29
29
|
end
|
30
|
+
|
30
31
|
@stubbed_business_supports << bs_with_facets unless @stubbed_business_supports.include?(bs_with_facets)
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
|
+
private
|
34
35
|
|
35
36
|
def stubs_for_facets(facets)
|
36
37
|
@stubbed_business_supports.select do |bs|
|
37
38
|
facet_matches = 0
|
38
|
-
facets.each do |k,v|
|
39
|
-
if bs[k]
|
39
|
+
facets.each do |k, v|
|
40
|
+
if bs[k] && (v & bs[k]).any?
|
40
41
|
facet_matches += 1
|
41
42
|
end
|
42
43
|
end
|
@@ -45,7 +46,7 @@ module GdsApi
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def sanitise_facets(facets)
|
48
|
-
Hash[facets.map{ |k, v|
|
49
|
+
Hash[facets.map { |k, v|
|
49
50
|
v = v.split(',') if v.is_a?(String)
|
50
51
|
[k.to_sym, v]
|
51
52
|
}]
|
@@ -3,16 +3,16 @@ module GdsApi
|
|
3
3
|
module CommonResponses
|
4
4
|
def titleize_slug(slug, options = {})
|
5
5
|
if options[:title_case]
|
6
|
-
slug.
|
6
|
+
slug.tr("-", " ").gsub(/\b./, &:upcase)
|
7
7
|
else
|
8
|
-
slug.
|
8
|
+
slug.tr("-", " ").capitalize
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
# expects a slug like "ministry-of-funk"
|
13
13
|
# returns an acronym like "MOF"
|
14
14
|
def acronymize_slug(slug)
|
15
|
-
initials = slug.gsub(/\b\w+/) {|m| m[0] }.
|
15
|
+
initials = slug.gsub(/\b\w+/) { |m| m[0] }.delete("-")
|
16
16
|
initials.upcase
|
17
17
|
end
|
18
18
|
|
@@ -27,15 +27,13 @@ module GdsApi
|
|
27
27
|
|
28
28
|
def plural_response_base
|
29
29
|
response_base.merge(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
"results" => []
|
38
|
-
}
|
30
|
+
"description" => "Tags!",
|
31
|
+
"total" => 100,
|
32
|
+
"start_index" => 1,
|
33
|
+
"page_size" => 100,
|
34
|
+
"current_page" => 1,
|
35
|
+
"pages" => 1,
|
36
|
+
"results" => []
|
39
37
|
)
|
40
38
|
end
|
41
39
|
end
|
@@ -21,7 +21,7 @@ module GdsApi
|
|
21
21
|
content_api_has_root_tags("section", slugs_or_sections)
|
22
22
|
end
|
23
23
|
|
24
|
-
def content_api_has_section(slug_or_hash, parent_slug=nil)
|
24
|
+
def content_api_has_section(slug_or_hash, parent_slug = nil)
|
25
25
|
content_api_has_tag("section", slug_or_hash, parent_slug)
|
26
26
|
end
|
27
27
|
|
@@ -51,7 +51,7 @@ module GdsApi
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def content_api_has_tag(tag_type, slug_or_hash, parent_tag_id=nil)
|
54
|
+
def content_api_has_tag(tag_type, slug_or_hash, parent_tag_id = nil)
|
55
55
|
tag = tag_hash(slug_or_hash, tag_type).merge(parent: parent_tag_id)
|
56
56
|
body = tag_result(tag)
|
57
57
|
|
@@ -83,16 +83,16 @@ module GdsApi
|
|
83
83
|
|
84
84
|
body = plural_response_base.merge("results" => live_tags)
|
85
85
|
stub_request(:get, "#{CONTENT_API_ENDPOINT}/tags.json")
|
86
|
-
.with(query: hash_including(
|
86
|
+
.with(query: hash_including("type" => type))
|
87
87
|
.to_return(status: 200, body: body.to_json, headers: {})
|
88
88
|
|
89
89
|
body = plural_response_base.merge("results" => (live_tags + draft_tags))
|
90
90
|
stub_request(:get, "#{CONTENT_API_ENDPOINT}/tags.json")
|
91
|
-
.with(query: hash_including(
|
91
|
+
.with(query: hash_including("type" => type, "draft" => "true"))
|
92
92
|
.to_return(status: 200, body: body.to_json, headers: {})
|
93
93
|
end
|
94
94
|
|
95
|
-
def content_api_does_not_have_tags(tag_type,
|
95
|
+
def content_api_does_not_have_tags(tag_type, _slugs)
|
96
96
|
body = {
|
97
97
|
"_response_info" => {
|
98
98
|
"status" => "not found"
|
@@ -100,7 +100,7 @@ module GdsApi
|
|
100
100
|
}
|
101
101
|
|
102
102
|
stub_request(:get, "#{CONTENT_API_ENDPOINT}/tags.json")
|
103
|
-
.with(query: hash_including(
|
103
|
+
.with(query: hash_including("type" => tag_type))
|
104
104
|
.to_return(status: 404, body: body.to_json, headers: {})
|
105
105
|
end
|
106
106
|
|
@@ -110,7 +110,7 @@ module GdsApi
|
|
110
110
|
)
|
111
111
|
|
112
112
|
stub_request(:get, "#{CONTENT_API_ENDPOINT}/tags.json")
|
113
|
-
.with(query: hash_including(
|
113
|
+
.with(query: hash_including("type" => tag_type))
|
114
114
|
.to_return(status: 200, body: body.to_json, headers: {})
|
115
115
|
end
|
116
116
|
|
@@ -120,7 +120,7 @@ module GdsApi
|
|
120
120
|
)
|
121
121
|
|
122
122
|
stub_request(:get, "#{CONTENT_API_ENDPOINT}/tags.json")
|
123
|
-
.with(query: hash_including(
|
123
|
+
.with(query: hash_including("type" => tag_type, "sort" => sort_order))
|
124
124
|
.to_return(status: 200, body: body.to_json, headers: {})
|
125
125
|
end
|
126
126
|
|
@@ -196,7 +196,7 @@ module GdsApi
|
|
196
196
|
def stub_content_api_default_artefact
|
197
197
|
stub_request(:get, %r{\A#{CONTENT_API_ENDPOINT}/[a-z0-9-]+\.json}).to_return { |request|
|
198
198
|
slug = request.uri.path.split('/').last.chomp('.json')
|
199
|
-
{:
|
199
|
+
{ body: artefact_for_slug(slug).to_json }
|
200
200
|
}
|
201
201
|
end
|
202
202
|
|
@@ -257,14 +257,14 @@ module GdsApi
|
|
257
257
|
child_tag_id.split('/').inject(nil) do |parent_tag, child_tag|
|
258
258
|
child_tag = [parent_tag, child_tag].join('/') if parent_tag
|
259
259
|
next_level_tag = tag_for_slug(child_tag, tag_type)
|
260
|
-
if tag_tree
|
260
|
+
tag_tree = if tag_tree
|
261
261
|
# Because tags are nested within one another, this makes
|
262
262
|
# the current part the top, and the rest we've seen the
|
263
263
|
# ancestors
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
264
|
+
next_level_tag.merge("parent" => tag_tree)
|
265
|
+
else
|
266
|
+
next_level_tag
|
267
|
+
end
|
268
268
|
|
269
269
|
# This becomes the parent tag in the next iteration of the block
|
270
270
|
child_tag
|
@@ -288,9 +288,9 @@ module GdsApi
|
|
288
288
|
artefact
|
289
289
|
end
|
290
290
|
|
291
|
-
def tag_for_slug(slug, tag_type, parent_slug=nil)
|
292
|
-
|
293
|
-
tag_for_slug(parent_slug, tag_type)
|
291
|
+
def tag_for_slug(slug, tag_type, parent_slug = nil)
|
292
|
+
if parent_slug
|
293
|
+
parent = tag_for_slug(parent_slug, tag_type)
|
294
294
|
end
|
295
295
|
|
296
296
|
tag_result(slug: slug, type: tag_type, parent: parent)
|
@@ -353,14 +353,14 @@ module GdsApi
|
|
353
353
|
|
354
354
|
def content_api_has_default_business_support_schemes
|
355
355
|
empty_results = {
|
356
|
-
"_response_info" => {"status" => "ok"},
|
356
|
+
"_response_info" => { "status" => "ok" },
|
357
357
|
"description" => "Business Support Schemes!",
|
358
358
|
"total" => 0, "startIndex" => 1, "pageSize" => 0, "currentPage" => 1, "pages" => 1,
|
359
359
|
"results" => []
|
360
360
|
}
|
361
361
|
|
362
362
|
stub_request(:get, %r{\A#{CONTENT_API_ENDPOINT}/business_support_schemes\.json}).
|
363
|
-
to_return(:
|
363
|
+
to_return(body: empty_results.to_json)
|
364
364
|
end
|
365
365
|
|
366
366
|
def content_api_licence_hash(licence_identifier, options = {})
|
@@ -374,7 +374,7 @@ module GdsApi
|
|
374
374
|
{
|
375
375
|
"title" => details[:title],
|
376
376
|
"id" => "http://example.org/#{details[:slug]}.json",
|
377
|
-
"web_url" =>
|
377
|
+
"web_url" => "http://www.test.gov.uk/#{details[:slug]}",
|
378
378
|
"format" => "licence",
|
379
379
|
"details" => {
|
380
380
|
"need_ids" => [],
|
@@ -396,18 +396,18 @@ module GdsApi
|
|
396
396
|
def setup_content_api_licences_stubs
|
397
397
|
@stubbed_content_api_licences = []
|
398
398
|
stub_request(:get, %r{\A#{CONTENT_API_ENDPOINT}/licences}).to_return do |request|
|
399
|
-
if request.uri.query_values
|
399
|
+
if request.uri.query_values && request.uri.query_values["ids"]
|
400
400
|
ids = request.uri.query_values["ids"].split(',')
|
401
401
|
valid_licences = @stubbed_content_api_licences.select { |l| ids.include? l[:licence_identifier] }
|
402
402
|
{
|
403
|
-
:
|
403
|
+
body: {
|
404
404
|
'results' => valid_licences.map { |licence|
|
405
405
|
content_api_licence_hash(licence[:licence_identifier], licence)
|
406
406
|
}
|
407
407
|
}.to_json
|
408
408
|
}
|
409
409
|
else
|
410
|
-
{:
|
410
|
+
{ body: { 'results' => [] }.to_json }
|
411
411
|
end
|
412
412
|
end
|
413
413
|
end
|
@@ -16,7 +16,7 @@ module GdsApi
|
|
16
16
|
@response_body = artefact_for_slug(slug)
|
17
17
|
@response_status = 200
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def with_query_parameters(hash)
|
21
21
|
@query_parameters = hash
|
22
22
|
self
|
@@ -38,19 +38,20 @@ module GdsApi
|
|
38
38
|
.with(query: hash_including(comparable_query_params))
|
39
39
|
.to_return(status: @response_status, body: @response_body.to_json)
|
40
40
|
end
|
41
|
-
|
42
|
-
private
|
43
|
-
def url_without_query
|
44
|
-
"#{CONTENT_API_ENDPOINT}/#{CGI.escape(slug)}.json"
|
45
|
-
end
|
46
41
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
42
|
+
private
|
43
|
+
|
44
|
+
def url_without_query
|
45
|
+
"#{CONTENT_API_ENDPOINT}/#{CGI.escape(slug)}.json"
|
46
|
+
end
|
47
|
+
|
48
|
+
# Ensure that all keys and values are strings
|
49
|
+
# because Webmock doesn't handle symbols
|
50
|
+
def comparable_query_params
|
51
|
+
@query_parameters.each_with_object({}) do |(k, v), hash|
|
52
|
+
hash[k.to_s] = v.nil? ? v : v.to_s
|
53
53
|
end
|
54
|
+
end
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
@@ -2,12 +2,12 @@
|
|
2
2
|
module GdsApi
|
3
3
|
module TestHelpers
|
4
4
|
module ContentItemHelpers
|
5
|
-
|
6
5
|
def content_item_for_base_path(base_path)
|
7
6
|
{
|
8
7
|
"title" => titleize_base_path(base_path),
|
9
8
|
"description" => "Description for #{base_path}",
|
10
|
-
"
|
9
|
+
"schema_name" => "guide",
|
10
|
+
"document_type" => "guide",
|
11
11
|
"need_ids" => ["100001"],
|
12
12
|
"public_updated_at" => "2014-05-06T12:01:00+00:00",
|
13
13
|
# base_path is added in as necessary (ie for content-store GET responses)
|
@@ -22,7 +22,7 @@ module GdsApi
|
|
22
22
|
{
|
23
23
|
"title" => nil,
|
24
24
|
"description" => nil,
|
25
|
-
"
|
25
|
+
"document_type" => "gone",
|
26
26
|
"schema_name" => "gone",
|
27
27
|
"public_updated_at" => nil,
|
28
28
|
"base_path" => base_path,
|
@@ -33,7 +33,7 @@ module GdsApi
|
|
33
33
|
|
34
34
|
def titleize_base_path(base_path, options = {})
|
35
35
|
if options[:title_case]
|
36
|
-
base_path.
|
36
|
+
base_path.tr("-", " ").gsub(/\b./, &:upcase)
|
37
37
|
else
|
38
38
|
base_path.gsub(%r{[-/]}, " ").strip.capitalize
|
39
39
|
end
|
@@ -15,7 +15,7 @@ module GdsApi
|
|
15
15
|
# will include "public"
|
16
16
|
# :draft will point to the draft content store if set to true
|
17
17
|
|
18
|
-
def content_store_endpoint(draft=false)
|
18
|
+
def content_store_endpoint(draft = false)
|
19
19
|
draft ? Plek.current.find('draft-content-store') : Plek.current.find('content-store')
|
20
20
|
end
|
21
21
|
|
@@ -79,11 +79,11 @@ module GdsApi
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def content_store_isnt_available
|
82
|
-
stub_request(:any, /#{content_store_endpoint}\/.*/).to_return(:
|
82
|
+
stub_request(:any, /#{content_store_endpoint}\/.*/).to_return(status: 503)
|
83
83
|
end
|
84
84
|
|
85
85
|
def content_item_for_base_path(base_path)
|
86
|
-
super.merge(
|
86
|
+
super.merge("base_path" => base_path)
|
87
87
|
end
|
88
88
|
|
89
89
|
def content_store_has_incoming_links(base_path, links)
|
@@ -9,8 +9,8 @@ module GdsApi
|
|
9
9
|
def email_alert_api_has_subscriber_list(attributes)
|
10
10
|
stub_request(:get, subscriber_lists_url(attributes))
|
11
11
|
.to_return(
|
12
|
-
:
|
13
|
-
:
|
12
|
+
status: 200,
|
13
|
+
body: get_subscriber_list_response(attributes).to_json,
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
@@ -22,15 +22,15 @@ module GdsApi
|
|
22
22
|
def email_alert_api_creates_subscriber_list(attributes)
|
23
23
|
stub_request(:post, subscriber_lists_url)
|
24
24
|
.to_return(
|
25
|
-
:
|
26
|
-
:
|
25
|
+
status: 201,
|
26
|
+
body: get_subscriber_list_response(attributes).to_json,
|
27
27
|
)
|
28
28
|
end
|
29
29
|
|
30
30
|
def email_alert_api_refuses_to_create_subscriber_list
|
31
31
|
stub_request(:post, subscriber_lists_url)
|
32
32
|
.to_return(
|
33
|
-
:
|
33
|
+
status: 422,
|
34
34
|
)
|
35
35
|
end
|
36
36
|
|
@@ -48,8 +48,8 @@ module GdsApi
|
|
48
48
|
def email_alert_api_accepts_alert
|
49
49
|
stub_request(:post, notifications_url)
|
50
50
|
.to_return(
|
51
|
-
:
|
52
|
-
:
|
51
|
+
status: 202,
|
52
|
+
body: {}.to_json,
|
53
53
|
)
|
54
54
|
end
|
55
55
|
|
@@ -67,14 +67,12 @@ module GdsApi
|
|
67
67
|
payload = JSON.parse(request.body)
|
68
68
|
payload.select { |k, _| attributes.key?(k) } == attributes
|
69
69
|
end
|
70
|
-
else
|
71
|
-
matcher = nil
|
72
70
|
end
|
73
71
|
|
74
72
|
assert_requested(:post, notifications_url, times: 1, &matcher)
|
75
73
|
end
|
76
74
|
|
77
|
-
def email_alert_api_has_notifications(notifications, start_at=nil)
|
75
|
+
def email_alert_api_has_notifications(notifications, start_at = nil)
|
78
76
|
url = notifications_url
|
79
77
|
url += "?start_at=#{start_at}" if start_at
|
80
78
|
url_regexp = Regexp.new("^#{Regexp.escape(url)}$")
|
@@ -14,13 +14,13 @@ module GdsApi
|
|
14
14
|
|
15
15
|
def imminence_has_areas_for_postcode(postcode, areas)
|
16
16
|
results = {
|
17
|
-
"_response_info" => {"status" => "ok"},
|
17
|
+
"_response_info" => { "status" => "ok" },
|
18
18
|
"total" => areas.size, "startIndex" => 1, "pageSize" => areas.size,
|
19
19
|
"currentPage" => 1, "pages" => 1, "results" => areas
|
20
20
|
}
|
21
21
|
|
22
22
|
stub_request(:get, %r{\A#{IMMINENCE_API_ENDPOINT}/areas/#{postcode}\.json}).
|
23
|
-
to_return(:
|
23
|
+
to_return(body: results.to_json)
|
24
24
|
end
|
25
25
|
|
26
26
|
def imminence_has_places_for_postcode(places, slug, postcode, limit)
|
@@ -30,8 +30,8 @@ module GdsApi
|
|
30
30
|
|
31
31
|
def stub_imminence_places_request(slug, query_hash, return_data, status_code = 200)
|
32
32
|
stub_request(:get, "#{IMMINENCE_API_ENDPOINT}/places/#{slug}.json").
|
33
|
-
with(:
|
34
|
-
to_return(:
|
33
|
+
with(query: query_hash).
|
34
|
+
to_return(status: status_code, body: return_data.to_json, headers: {})
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|