gds-api-adapters 63.6.0 → 67.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,8 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
1
  require "gds_api/test_helpers/json_client_helper"
3
2
 
4
3
  module GdsApi
5
4
  module TestHelpers
6
5
  module Imminence
7
- extend AliasDeprecated
8
-
9
6
  # Generally true. If you are initializing the client differently,
10
7
  # you could redefine/override the constant or stub directly.
11
8
  IMMINENCE_API_ENDPOINT = Plek.current.find("imminence")
@@ -18,12 +15,16 @@ module GdsApi
18
15
  def stub_imminence_has_areas_for_postcode(postcode, areas)
19
16
  results = {
20
17
  "_response_info" => { "status" => "ok" },
21
- "total" => areas.size, "startIndex" => 1, "pageSize" => areas.size,
22
- "currentPage" => 1, "pages" => 1, "results" => areas
18
+ "total" => areas.size,
19
+ "startIndex" => 1,
20
+ "pageSize" => areas.size,
21
+ "currentPage" => 1,
22
+ "pages" => 1,
23
+ "results" => areas,
23
24
  }
24
25
 
25
- stub_request(:get, %r{\A#{IMMINENCE_API_ENDPOINT}/areas/#{postcode}\.json}).
26
- to_return(body: results.to_json)
26
+ stub_request(:get, %r{\A#{IMMINENCE_API_ENDPOINT}/areas/#{postcode}\.json})
27
+ .to_return(body: results.to_json)
27
28
  end
28
29
 
29
30
  def stub_imminence_has_places_for_postcode(places, slug, postcode, limit)
@@ -32,14 +33,10 @@ module GdsApi
32
33
  end
33
34
 
34
35
  def stub_imminence_places_request(slug, query_hash, return_data, status_code = 200)
35
- stub_request(:get, "#{IMMINENCE_API_ENDPOINT}/places/#{slug}.json").
36
- with(query: query_hash).
37
- to_return(status: status_code, body: return_data.to_json, headers: {})
36
+ stub_request(:get, "#{IMMINENCE_API_ENDPOINT}/places/#{slug}.json")
37
+ .with(query: query_hash)
38
+ .to_return(status: status_code, body: return_data.to_json, headers: {})
38
39
  end
39
-
40
- alias_deprecated :imminence_has_places, :stub_imminence_has_places
41
- alias_deprecated :imminence_has_areas_for_postcode, :stub_imminence_has_areas_for_postcode
42
- alias_deprecated :imminence_has_places_for_postcode, :stub_imminence_has_places_for_postcode
43
40
  end
44
41
  end
45
42
  end
@@ -1,28 +1,25 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
1
  require "gds_api/test_helpers/json_client_helper"
3
2
 
4
3
  module GdsApi
5
4
  module TestHelpers
6
5
  module LicenceApplication
7
- extend AliasDeprecated
8
-
9
6
  # Generally true. If you are initializing the client differently,
10
7
  # you could redefine/override the constant or stub directly.
11
8
  LICENCE_APPLICATION_ENDPOINT = Plek.current.find("licensify")
12
9
 
13
10
  def stub_licence_exists(identifier, licence)
14
11
  licence = licence.to_json unless licence.is_a?(String)
15
- stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").
16
- with(headers: GdsApi::JsonClient.default_request_headers).
17
- to_return(status: 200,
18
- body: licence)
12
+ stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}")
13
+ .with(headers: GdsApi::JsonClient.default_request_headers)
14
+ .to_return(status: 200,
15
+ body: licence)
19
16
  end
20
17
 
21
18
  def stub_licence_does_not_exist(identifier)
22
- stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").
23
- with(headers: GdsApi::JsonClient.default_request_headers).
24
- to_return(status: 404,
25
- body: "{\"error\": [\"Unrecognised Licence Id: #{identifier}\"]}")
19
+ stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}")
20
+ .with(headers: GdsApi::JsonClient.default_request_headers)
21
+ .to_return(status: 404,
22
+ body: "{\"error\": [\"Unrecognised Licence Id: #{identifier}\"]}")
26
23
  end
27
24
 
28
25
  def stub_licence_times_out(identifier)
@@ -32,11 +29,6 @@ module GdsApi
32
29
  def stub_licence_returns_error(identifier)
33
30
  stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").to_return(status: 500)
34
31
  end
35
-
36
- alias_deprecated :licence_exists, :stub_licence_exists
37
- alias_deprecated :licence_does_not_exist, :stub_licence_does_not_exist
38
- alias_deprecated :licence_times_out, :stub_licence_times_out
39
- alias_deprecated :licence_returns_error, :stub_licence_returns_error
40
32
  end
41
33
  end
42
34
  end
@@ -1,10 +1,8 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
1
  require "gds_api/test_helpers/json_client_helper"
3
2
 
4
3
  module GdsApi
5
4
  module TestHelpers
6
5
  module LinkCheckerApi
7
- extend AliasDeprecated
8
6
  LINK_CHECKER_API_ENDPOINT = Plek.current.find("link-checker-api")
9
7
 
10
8
  def link_checker_api_link_report_hash(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil)
@@ -91,12 +89,6 @@ module GdsApi
91
89
  headers: { "Content-Type" => "application/json" },
92
90
  )
93
91
  end
94
-
95
- # Aliases for DEPRECATED methods
96
- alias_deprecated :link_checker_api_check, :stub_link_checker_api_check
97
- alias_deprecated :link_checker_api_get_batch, :stub_link_checker_api_get_batch
98
- alias_deprecated :link_checker_api_create_batch, :stub_link_checker_api_create_batch
99
- alias_deprecated :link_checker_api_upsert_resource_monitor, :stub_link_checker_api_upsert_resource_monitor
100
92
  end
101
93
  end
102
94
  end
@@ -1,10 +1,8 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
1
  require "gds_api/test_helpers/json_client_helper"
3
2
 
4
3
  module GdsApi
5
4
  module TestHelpers
6
5
  module LocalLinksManager
7
- extend AliasDeprecated
8
6
  LOCAL_LINKS_MANAGER_ENDPOINT = Plek.current.find("local-links-manager")
9
7
 
10
8
  def stub_local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:)
@@ -142,17 +140,6 @@ module GdsApi
142
140
  .with(query: { authority_slug: authority_slug })
143
141
  .to_return(body: response.to_json, status: 200)
144
142
  end
145
-
146
- alias_deprecated :local_links_manager_has_a_link, :stub_local_links_manager_has_a_link
147
- alias_deprecated :local_links_manager_has_no_link, :stub_local_links_manager_has_no_link
148
- alias_deprecated :local_links_manager_has_no_link_and_no_homepage_url, :stub_local_links_manager_has_no_link_and_no_homepage_url
149
- alias_deprecated :local_links_manager_request_with_missing_parameters, :stub_local_links_manager_request_with_missing_parameters
150
- alias_deprecated :local_links_manager_does_not_have_required_objects, :stub_local_links_manager_does_not_have_required_objects
151
- alias_deprecated :local_links_manager_has_a_local_authority, :stub_local_links_manager_has_a_local_authority
152
- alias_deprecated :local_links_manager_has_a_district_and_county_local_authority, :stub_local_links_manager_has_a_district_and_county_local_authority
153
- alias_deprecated :local_links_manager_request_without_local_authority_slug, :stub_local_links_manager_request_without_local_authority_slug
154
- alias_deprecated :local_links_manager_does_not_have_an_authority, :stub_local_links_manager_does_not_have_an_authority
155
- alias_deprecated :local_links_manager_has_a_local_authority_without_homepage, :stub_local_links_manager_has_a_local_authority_without_homepage
156
143
  end
157
144
  end
158
145
  end
@@ -1,16 +1,13 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
-
3
1
  module GdsApi
4
2
  module TestHelpers
5
3
  module Mapit
6
- extend AliasDeprecated
7
4
  MAPIT_ENDPOINT = Plek.current.find("mapit")
8
5
 
9
6
  def stub_mapit_has_a_postcode(postcode, coords)
10
7
  response = {
11
8
  "wgs84_lat" => coords.first,
12
9
  "wgs84_lon" => coords.last,
13
- "postcode" => 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" => postcode,
23
+ "postcode" => postcode,
27
24
  }
28
25
 
29
- area_response = Hash[areas.map.with_index { |area, i|
30
- [i, {
31
- "codes" => {
32
- "ons" => area["ons"],
33
- "gss" => area["gss"],
34
- "govuk_slug" => area["govuk_slug"],
35
- },
36
- "name" => area["name"],
37
- "type" => area["type"],
38
- "country_name" => area["country_name"],
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("results" => page,
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
- if i.zero?
59
- # First page exists at URL with and without page param
60
- stub_request(:get, links[:self].sub(/\?page=1/, "")).
61
- to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
62
- end
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
- slug: slug,
24
- transaction: "search-terms",
25
- group_by: "searchKeyword",
26
- collect: "searchUniques:sum",
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
- slug: slug,
34
- transaction: "search-terms",
35
- group_by: "pagePath",
36
- collect: "searchUniques:sum",
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
- slug: slug,
44
- transaction: "page-statistics",
45
- group_by: "pagePath",
46
- collect: "uniquePageviews:sum",
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
- slug: slug,
54
- transaction: "page-contacts",
55
- group_by: "pagePath",
56
- collect: "total:sum",
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
- group_by: options[:group_by],
64
- collect: options[:collect],
65
- duration: 42,
66
- period: "day",
67
- end_at: Date.today.to_time.getutc.iso8601,
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"
@@ -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
- ->(request) do
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
- ->(request) do
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 { |item|
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 { |f|
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
 
@@ -494,7 +492,7 @@ module GdsApi
494
492
  def stub_publishing_api_has_expanded_links(links, with_drafts: true, generate: false)
495
493
  links = deep_transform_keys(links, &:to_sym)
496
494
  request_params = {}
497
- request_params["with_drafts"] = false if !with_drafts
495
+ request_params["with_drafts"] = false unless with_drafts
498
496
  request_params["generate"] = true if generate
499
497
 
500
498
  url = PUBLISHING_API_V2_ENDPOINT + "/expanded-links/" + links[:content_id]
@@ -576,7 +574,7 @@ module GdsApi
576
574
  def stub_publishing_api_has_linked_items(items, params = {})
577
575
  content_id = params.fetch(:content_id)
578
576
  link_type = params.fetch(:link_type)
579
- fields = params.fetch(:fields, %w(base_path content_id document_type title))
577
+ fields = params.fetch(:fields, %w[base_path content_id document_type title])
580
578
 
581
579
  url = PUBLISHING_API_V2_ENDPOINT + "/linked/#{content_id}"
582
580
 
@@ -698,14 +696,14 @@ module GdsApi
698
696
  end
699
697
 
700
698
  def request_json_matching(required_attributes)
701
- ->(request) do
699
+ lambda do |request|
702
700
  data = JSON.parse(request.body)
703
701
  required_attributes.to_a.all? { |key, value| data[key.to_s] == value }
704
702
  end
705
703
  end
706
704
 
707
705
  def request_json_including(required_attributes)
708
- ->(request) do
706
+ lambda do |request|
709
707
  data = JSON.parse(request.body)
710
708
  values_match_recursively(required_attributes, data)
711
709
  end
@@ -739,7 +737,7 @@ module GdsApi
739
737
  # @example
740
738
  # stub_any_publishing_api_path_reservation
741
739
  def stub_any_publishing_api_path_reservation
742
- stub_request(:put, %r[\A#{PUBLISHING_API_ENDPOINT}/paths/]).to_return do |request|
740
+ stub_request(:put, %r{\A#{PUBLISHING_API_ENDPOINT}/paths/}).to_return do |request|
743
741
  base_path = request.uri.path.sub(%r{\A/paths}, "")
744
742
  body = JSON.parse(request.body).merge(base_path: base_path)
745
743
  {
@@ -765,16 +763,16 @@ module GdsApi
765
763
  message: "Base path #{message}",
766
764
  fields: { base_path: [message] } }
767
765
 
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)
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)
772
770
 
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)
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)
778
776
  end
779
777
 
780
778
  # Stub a PUT /paths/:base_path request for a particular publishing
@@ -797,30 +795,11 @@ module GdsApi
797
795
 
798
796
  error = { code: 422, message: message, fields: error_fields }
799
797
 
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
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
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
824
803
 
825
804
  private
826
805
 
@@ -888,7 +867,7 @@ module GdsApi
888
867
  return false unless actual_value.is_a?(Hash)
889
868
 
890
869
  expected_value.all? do |expected_sub_key, expected_sub_value|
891
- actual_value.has_key?(expected_sub_key.to_s) &&
870
+ actual_value.key?(expected_sub_key.to_s) &&
892
871
  values_match_recursively(expected_sub_value, actual_value[expected_sub_key.to_s])
893
872
  end
894
873
  when Array