gds-api-adapters 63.6.0 → 67.2.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.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -1
  3. data/Rakefile +3 -4
  4. data/lib/gds_api.rb +2 -14
  5. data/lib/gds_api/asset_manager.rb +1 -1
  6. data/lib/gds_api/base.rb +8 -3
  7. data/lib/gds_api/email_alert_api.rb +12 -13
  8. data/lib/gds_api/imminence.rb +3 -3
  9. data/lib/gds_api/json_client.rb +6 -6
  10. data/lib/gds_api/list_response.rb +6 -6
  11. data/lib/gds_api/performance_platform/data_out.rb +21 -21
  12. data/lib/gds_api/publishing_api.rb +2 -2
  13. data/lib/gds_api/publishing_api/special_route_publisher.rb +1 -1
  14. data/lib/gds_api/response.rb +80 -6
  15. data/lib/gds_api/test_helpers/asset_manager.rb +0 -17
  16. data/lib/gds_api/test_helpers/calendars.rb +0 -9
  17. data/lib/gds_api/test_helpers/content_store.rb +0 -9
  18. data/lib/gds_api/test_helpers/email_alert_api.rb +28 -39
  19. data/lib/gds_api/test_helpers/imminence.rb +11 -14
  20. data/lib/gds_api/test_helpers/licence_application.rb +8 -16
  21. data/lib/gds_api/test_helpers/link_checker_api.rb +0 -8
  22. data/lib/gds_api/test_helpers/local_links_manager.rb +0 -13
  23. data/lib/gds_api/test_helpers/mapit.rb +15 -26
  24. data/lib/gds_api/test_helpers/organisations.rb +13 -18
  25. data/lib/gds_api/test_helpers/performance_platform/data_out.rb +34 -34
  26. data/lib/gds_api/test_helpers/publishing_api.rb +32 -51
  27. data/lib/gds_api/test_helpers/support.rb +0 -5
  28. data/lib/gds_api/test_helpers/support_api.rb +16 -20
  29. data/lib/gds_api/test_helpers/worldwide.rb +51 -31
  30. data/lib/gds_api/version.rb +1 -1
  31. metadata +14 -31
  32. data/lib/gds_api/publishing_api_v2.rb +0 -14
  33. data/lib/gds_api/test_helpers/alias_deprecated.rb +0 -13
  34. data/lib/gds_api/test_helpers/publishing_api_v2.rb +0 -13
@@ -1,10 +1,6 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
-
3
1
  module GdsApi
4
2
  module TestHelpers
5
3
  module AssetManager
6
- extend AliasDeprecated
7
-
8
4
  ASSET_MANAGER_ENDPOINT = Plek.current.find("asset-manager")
9
5
 
10
6
  def stub_any_asset_manager_call
@@ -107,19 +103,6 @@ module GdsApi
107
103
  def stub_asset_manager_delete_asset_failure(asset_id)
108
104
  stub_request(:delete, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}").to_return(status: 500)
109
105
  end
110
-
111
- alias_deprecated :asset_manager_updates_any_asset, :stub_asset_manager_updates_any_asset
112
- alias_deprecated :asset_manager_deletes_any_asset, :stub_asset_manager_deletes_any_asset
113
- alias_deprecated :asset_manager_has_an_asset, :stub_asset_manager_has_an_asset
114
- alias_deprecated :asset_manager_has_a_whitehall_asset, :stub_asset_manager_has_a_whitehall_asset
115
- alias_deprecated :asset_manager_does_not_have_an_asset, :stub_asset_manager_does_not_have_an_asset
116
- alias_deprecated :asset_manager_does_not_have_a_whitehall_asset, :stub_asset_manager_does_not_have_a_whitehall_asset
117
- alias_deprecated :asset_manager_receives_an_asset, :stub_asset_manager_receives_an_asset
118
- alias_deprecated :asset_manager_upload_failure, :stub_asset_manager_upload_failure
119
- alias_deprecated :asset_manager_update_asset, :stub_asset_manager_update_asset
120
- alias_deprecated :asset_manager_update_failure, :stub_asset_manager_update_asset_failure
121
- alias_deprecated :asset_manager_delete_asset, :stub_asset_manager_delete_asset
122
- alias_deprecated :asset_manager_delete_failure, :stub_asset_manager_delete_asset_failure
123
106
  end
124
107
  end
125
108
  end
@@ -1,10 +1,6 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
-
3
1
  module GdsApi
4
2
  module TestHelpers
5
3
  module Calendars
6
- extend AliasDeprecated
7
-
8
4
  def calendars_endpoint(in_division: nil)
9
5
  endpoint = "#{Plek.new.website_root}/bank-holidays"
10
6
  endpoint += "/#{in_division}" unless in_division.nil?
@@ -55,11 +51,6 @@ module GdsApi
55
51
  def stub_calendars_has_a_bank_holiday_on(date, in_division: nil)
56
52
  stub_calendars_has_bank_holidays_on([date], in_division: in_division)
57
53
  end
58
-
59
- # Aliases for DEPRECATED methods
60
- alias_deprecated :calendars_has_no_bank_holidays, :stub_calendars_has_no_bank_holidays
61
- alias_deprecated :calendars_has_bank_holidays_on, :stub_calendars_has_bank_holidays_on
62
- alias_deprecated :calendars_has_a_bank_holiday_on, :stub_calendars_has_a_bank_holiday_on
63
54
  end
64
55
  end
65
56
  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"
@@ -6,7 +5,6 @@ require "json"
6
5
  module GdsApi
7
6
  module TestHelpers
8
7
  module ContentStore
9
- extend AliasDeprecated
10
8
  include ContentItemHelpers
11
9
 
12
10
  def content_store_endpoint(draft = false)
@@ -93,13 +91,6 @@ module GdsApi
93
91
 
94
92
  stub_request(:get, url).to_return(body: body)
95
93
  end
96
-
97
- # Aliases for DEPRECATED methods
98
- alias_deprecated :content_store_has_item, :stub_content_store_has_item
99
- alias_deprecated :content_store_does_not_have_item, :stub_content_store_does_not_have_item
100
- alias_deprecated :content_store_has_gone_item, :stub_content_store_has_gone_item
101
- alias_deprecated :content_store_isnt_available, :stub_content_store_isnt_available
102
- alias_deprecated :content_store_has_incoming_links, :stub_content_store_has_incoming_links
103
94
  end
104
95
  end
105
96
  end
@@ -83,12 +83,12 @@ module GdsApi
83
83
  # stub_email_alert_api_has_subscriptions([
84
84
  # {
85
85
  # id: 'id-of-my-subscriber-list',
86
- #  frequency: 'weekly',
86
+ # frequency: 'weekly',
87
87
  # ended: true,
88
88
  # },
89
89
  # {
90
90
  # id: 'id-of-my-subscriber-list',
91
- #  frequency: 'daily',
91
+ # frequency: 'daily',
92
92
  # },
93
93
  # ])
94
94
  #
@@ -98,9 +98,9 @@ module GdsApi
98
98
  subscriptions.each do |id, params|
99
99
  latest_id, latest_params = get_latest_matching(params, subscriptions)
100
100
  stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/#{id}")
101
- .to_return(status: 200, body: get_subscription_response(id, params).to_json)
101
+ .to_return(status: 200, body: get_subscription_response(id, **params).to_json)
102
102
  stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/#{id}/latest")
103
- .to_return(status: 200, body: get_subscription_response(latest_id, latest_params).to_json)
103
+ .to_return(status: 200, body: get_subscription_response(latest_id, **latest_params).to_json)
104
104
  end
105
105
  end
106
106
 
@@ -176,7 +176,7 @@ module GdsApi
176
176
 
177
177
  def assert_email_alert_api_content_change_created(attributes = nil)
178
178
  if attributes
179
- matcher = ->(request) do
179
+ matcher = lambda do |request|
180
180
  payload = JSON.parse(request.body)
181
181
  payload.select { |k, _| attributes.key?(k) } == attributes
182
182
  end
@@ -187,7 +187,7 @@ module GdsApi
187
187
 
188
188
  def assert_email_alert_api_message_created(attributes = nil)
189
189
  if attributes
190
- matcher = ->(request) do
190
+ matcher = lambda do |request|
191
191
  payload = JSON.parse(request.body)
192
192
  payload.select { |k, _| attributes.key?(k) } == attributes
193
193
  end
@@ -218,25 +218,38 @@ module GdsApi
218
218
  .to_return(status: 404)
219
219
  end
220
220
 
221
- def stub_email_alert_api_creates_a_subscription(subscriber_list_id, address, frequency, returned_subscription_id)
221
+ def stub_email_alert_api_creates_a_subscription(subscriber_list_id, address, frequency, returned_subscription_id, skip_confirmation_email: false)
222
222
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
223
223
  .with(
224
- body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json,
225
- ).to_return(status: 201, body: { subscription_id: returned_subscription_id }.to_json)
224
+ body: {
225
+ subscriber_list_id: subscriber_list_id,
226
+ address: address,
227
+ frequency: frequency,
228
+ skip_confirmation_email: skip_confirmation_email,
229
+ }.to_json,
230
+ ).to_return(status: 201, body: { id: returned_subscription_id }.to_json)
226
231
  end
227
232
 
228
233
  def stub_email_alert_api_creates_an_existing_subscription(subscriber_list_id, address, frequency, returned_subscription_id)
229
234
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
230
235
  .with(
231
- body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json,
232
- ).to_return(status: 200, body: { subscription_id: returned_subscription_id }.to_json)
236
+ body: hash_including(
237
+ subscriber_list_id: subscriber_list_id,
238
+ address: address,
239
+ frequency: frequency,
240
+ ),
241
+ ).to_return(status: 200, body: { id: returned_subscription_id }.to_json)
233
242
  end
234
243
 
235
244
  def stub_email_alert_api_refuses_to_create_subscription(subscriber_list_id, address, frequency)
236
245
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
237
246
  .with(
238
- body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json,
239
- ).to_return(status: 422)
247
+ body: hash_including(
248
+ subscriber_list_id: subscriber_list_id,
249
+ address: address,
250
+ frequency: frequency,
251
+ ),
252
+ ).to_return(status: 422)
240
253
  end
241
254
 
242
255
  def stub_email_alert_api_sends_subscription_verification_email(address, frequency, topic_id)
@@ -292,7 +305,7 @@ module GdsApi
292
305
  body: {
293
306
  subscriber_list: returned_attributes,
294
307
  }.to_json,
295
- )
308
+ )
296
309
  end
297
310
 
298
311
  def stub_email_alert_api_does_not_have_subscriber_list_by_slug(slug:)
@@ -300,30 +313,6 @@ module GdsApi
300
313
  .to_return(status: 404)
301
314
  end
302
315
 
303
- # Aliases for DEPRECATED methods
304
- alias_method :email_alert_api_has_updated_subscriber, :stub_email_alert_api_has_updated_subscriber
305
- alias_method :email_alert_api_does_not_have_updated_subscriber, :stub_email_alert_api_does_not_have_updated_subscriber
306
- alias_method :email_alert_api_has_updated_subscription, :stub_email_alert_api_has_updated_subscription
307
- alias_method :email_alert_api_does_not_have_updated_subscription, :stub_email_alert_api_does_not_have_updated_subscription
308
- alias_method :email_alert_api_has_subscriber_subscriptions, :stub_email_alert_api_has_subscriber_subscriptions
309
- alias_method :email_alert_api_does_not_have_subscriber_subscriptions, :stub_email_alert_api_does_not_have_subscriber_subscriptions
310
- alias_method :email_alert_api_has_subscription, :stub_email_alert_api_has_subscription
311
- alias_method :email_alert_api_has_subscriptions, :stub_email_alert_api_has_subscriptions
312
- alias_method :email_alert_api_has_subscriber_list, :stub_email_alert_api_has_subscriber_list
313
- alias_method :email_alert_api_does_not_have_subscriber_list, :stub_email_alert_api_does_not_have_subscriber_list
314
- alias_method :email_alert_api_creates_subscriber_list, :stub_email_alert_api_creates_subscriber_list
315
- alias_method :email_alert_api_refuses_to_create_subscriber_list, :stub_email_alert_api_refuses_to_create_subscriber_list
316
- alias_method :email_alert_api_accepts_unpublishing_message, :stub_email_alert_api_accepts_unpublishing_message
317
- alias_method :email_alert_api_unsubscribes_a_subscription, :stub_email_alert_api_unsubscribes_a_subscription
318
- alias_method :email_alert_api_has_no_subscription_for_uuid, :stub_email_alert_api_has_no_subscription_for_uuid
319
- alias_method :email_alert_api_unsubscribes_a_subscriber, :stub_email_alert_api_unsubscribes_a_subscriber
320
- alias_method :email_alert_api_has_no_subscriber, :stub_email_alert_api_has_no_subscriber
321
- alias_method :email_alert_api_creates_a_subscription, :stub_email_alert_api_creates_a_subscription
322
- alias_method :email_alert_api_creates_an_existing_subscription, :stub_email_alert_api_creates_an_existing_subscription
323
- alias_method :email_alert_api_refuses_to_create_subscription, :stub_email_alert_api_refuses_to_create_subscription
324
- alias_method :email_alert_api_has_subscriber_list_by_slug, :stub_email_alert_api_has_subscriber_list_by_slug
325
- alias_method :email_alert_api_does_not_have_subscriber_list_by_slug, :stub_email_alert_api_does_not_have_subscriber_list_by_slug
326
-
327
316
  private
328
317
 
329
318
  def get_subscriber_response(id, address)
@@ -348,7 +337,7 @@ module GdsApi
348
337
  "id" => id,
349
338
  "frequency" => frequency,
350
339
  "source" => "user_signed_up",
351
- "ended_at" => ended ? Time.now.to_datetime.rfc3339 : nil,
340
+ "ended_at" => ended ? Time.now.iso8601 : nil,
352
341
  "ended_reason" => ended ? "unsubscribed" : nil,
353
342
  "subscriber" => {
354
343
  "id" => subscriber_id,
@@ -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