gds-api-adapters 63.1.1 → 63.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f01a6b60b867bcd614338616006fbbf13690f758329163ea9f17a184ba14f57
4
- data.tar.gz: 3c8e3370a84684dac3b71111519eb307a23efe99d59594ed731491f23978d7c5
3
+ metadata.gz: 6be83d400c0df3de1819b715246ae6436c5172bd871bdcb7a4e897acd5064739
4
+ data.tar.gz: b414936cc16230ad7522f1971679dc2f560823f2f3083970f11b5463f11ae316
5
5
  SHA512:
6
- metadata.gz: 65da05dda6a15ea79b6fb0e20d9af73819e26fb74f3a4ff4a4614f050e2f1037a340929933165668b7164df9180125da56742bafb5156dc3750c5fd5c9f6736b
7
- data.tar.gz: 9a50289c99fabff521bd9b81375efa56111a287fed2e33c1fc8eb8492fa7fc0bf6dde2e18b737a8bbfb7c095e5546cc1cb3a0af4a9e04902c5ece577d6fea543
6
+ metadata.gz: bc52a03e4ee75813e8d7d393660ca62d5e27bd7a4e9ac9accc3eeca71fdb68796fc14cdad6d532460df8a2666a75ea35de62b4612043981751f7f97b32239cdf
7
+ data.tar.gz: 04cab17475d2ca057813740f59f5e7ac59409d59406c74aa4762ef227dcccd91083df8b7b9ab5361df0e72b1a0013d6375f7ae168794dee91930b6e7715ab621
@@ -8,6 +8,8 @@ require_relative "exceptions"
8
8
  # @see https://github.com/alphagov/publishing-api/blob/master/doc/model.md
9
9
  # @api documented
10
10
  class GdsApi::PublishingApi < GdsApi::Base
11
+ class NoLiveVersion < GdsApi::BaseError; end
12
+
11
13
  # Put a content item
12
14
  #
13
15
  # @param content_id [UUID]
@@ -34,6 +36,29 @@ class GdsApi::PublishingApi < GdsApi::Base
34
36
  get_json(content_url(content_id, params))
35
37
  end
36
38
 
39
+ # Return a live content item, i.e. content that has a state of "published" or "unpublished"
40
+ #
41
+ # Raises exception if the item doesn't exist.
42
+ #
43
+ # @param content_id [UUID]
44
+ # @option locale [String] locale The language, defaults to 'en' in publishing-api.
45
+ #
46
+ # @return [GdsApi::Response] a content item
47
+ #
48
+ # @raise [NoLiveVersion] when the content item is not found
49
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2contentcontent_id
50
+ def get_live_content(content_id, locale = "en")
51
+ content_item = get_content(content_id, locale: locale)
52
+
53
+ live_states = %w[published unpublished]
54
+ return content_item if live_states.include?(content_item.to_h["publication_state"])
55
+
56
+ live_version_number = content_item["state_history"].find { |_, v| live_states.include?(v) }&.first
57
+ raise NoLiveVersion, "No live version exists for content_id: #{content_id}" unless live_version_number
58
+
59
+ get_content(content_id, locale: locale, version: live_version_number)
60
+ end
61
+
37
62
  # Find the content_ids for a list of base_paths.
38
63
  #
39
64
  # @param base_paths [Array]
@@ -0,0 +1,13 @@
1
+ module GdsApi
2
+ module TestHelpers
3
+ module AliasDeprecated
4
+ def alias_deprecated(deprecated_method, replacement_method)
5
+ class_name = self.name
6
+ define_method(deprecated_method) do |*args, &block|
7
+ warn "##{deprecated_method} is deprecated on #{class_name} and will be removed in a future version. Use ##{replacement_method} instead"
8
+ public_send(replacement_method, *args, &block)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,6 +1,10 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
2
+
1
3
  module GdsApi
2
4
  module TestHelpers
3
5
  module AssetManager
6
+ extend AliasDeprecated
7
+
4
8
  ASSET_MANAGER_ENDPOINT = Plek.current.find("asset-manager")
5
9
 
6
10
  def stub_any_asset_manager_call
@@ -104,19 +108,18 @@ module GdsApi
104
108
  stub_request(:delete, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}").to_return(status: 500)
105
109
  end
106
110
 
107
- # Aliases for DEPRECATED methods
108
- alias_method :asset_manager_updates_any_asset, :stub_asset_manager_updates_any_asset
109
- alias_method :asset_manager_deletes_any_asset, :stub_asset_manager_deletes_any_asset
110
- alias_method :asset_manager_has_an_asset, :stub_asset_manager_has_an_asset
111
- alias_method :asset_manager_has_a_whitehall_asset, :stub_asset_manager_has_a_whitehall_asset
112
- alias_method :asset_manager_does_not_have_an_asset, :stub_asset_manager_does_not_have_an_asset
113
- alias_method :asset_manager_does_not_have_a_whitehall_asset, :stub_asset_manager_does_not_have_a_whitehall_asset
114
- alias_method :asset_manager_receives_an_asset, :stub_asset_manager_receives_an_asset
115
- alias_method :asset_manager_upload_failure, :stub_asset_manager_upload_failure
116
- alias_method :asset_manager_update_asset, :stub_asset_manager_update_asset
117
- alias_method :asset_manager_update_failure, :stub_asset_manager_update_asset_failure
118
- alias_method :asset_manager_delete_asset, :stub_asset_manager_delete_asset
119
- alias_method :asset_manager_delete_failure, :stub_asset_manager_delete_asset_failure
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
120
123
  end
121
124
  end
122
125
  end
@@ -1,14 +1,18 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
2
+
1
3
  module GdsApi
2
4
  module TestHelpers
3
5
  module Calendars
4
- def stub_calendars_endpoint(in_division: nil)
6
+ extend AliasDeprecated
7
+
8
+ def calendars_endpoint(in_division: nil)
5
9
  endpoint = "#{Plek.new.website_root}/bank-holidays"
6
10
  endpoint += "/#{in_division}" unless in_division.nil?
7
11
  endpoint + ".json"
8
12
  end
9
13
 
10
14
  def stub_calendars_has_no_bank_holidays(in_division: nil)
11
- calendars_has_bank_holidays_on([], in_division: in_division)
15
+ stub_calendars_has_bank_holidays_on([], in_division: in_division)
12
16
  end
13
17
 
14
18
  def stub_calendars_has_bank_holidays_on(dates, in_division: nil)
@@ -49,14 +53,13 @@ module GdsApi
49
53
  end
50
54
 
51
55
  def stub_calendars_has_a_bank_holiday_on(date, in_division: nil)
52
- calendars_has_bank_holidays_on([date], in_division: in_division)
56
+ stub_calendars_has_bank_holidays_on([date], in_division: in_division)
53
57
  end
54
58
 
55
59
  # Aliases for DEPRECATED methods
56
- alias_method :calendars_endpoint, :stub_calendars_endpoint
57
- alias_method :calendars_has_no_bank_holidays, :stub_calendars_has_no_bank_holidays
58
- alias_method :calendars_has_bank_holidays_on, :stub_calendars_has_bank_holidays_on
59
- alias_method :calendars_has_a_bank_holiday_on, :stub_calendars_has_a_bank_holiday_on
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
60
63
  end
61
64
  end
62
65
  end
@@ -1,3 +1,4 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
1
2
  require "gds_api/test_helpers/json_client_helper"
2
3
  require "gds_api/test_helpers/content_item_helpers"
3
4
  require "json"
@@ -5,8 +6,13 @@ require "json"
5
6
  module GdsApi
6
7
  module TestHelpers
7
8
  module ContentStore
9
+ extend AliasDeprecated
8
10
  include ContentItemHelpers
9
11
 
12
+ def content_store_endpoint(draft = false)
13
+ draft ? Plek.current.find("draft-content-store") : Plek.current.find("content-store")
14
+ end
15
+
10
16
  # Stubs a content item in the content store.
11
17
  # The following options can be passed in:
12
18
  #
@@ -14,14 +20,10 @@ module GdsApi
14
20
  # :private if true, the Cache-Control header will include the "private" directive. By default it
15
21
  # will include "public"
16
22
  # :draft will point to the draft content store if set to true
17
- def stub_content_store_endpoint(draft = false)
18
- draft ? Plek.current.find("draft-content-store") : Plek.current.find("content-store")
19
- end
20
-
21
23
  def stub_content_store_has_item(base_path, body = content_item_for_base_path(base_path), options = {})
22
24
  max_age = options.fetch(:max_age, 900)
23
25
  visibility = options[:private] ? "private" : "public"
24
- url = stub_content_store_endpoint(options[:draft]) + "/content" + base_path
26
+ url = content_store_endpoint(options[:draft]) + "/content" + base_path
25
27
  body = body.to_json unless body.is_a?(String)
26
28
 
27
29
  stub_request(:get, url).to_return(
@@ -35,10 +37,10 @@ module GdsApi
35
37
  end
36
38
 
37
39
  def stub_content_store_does_not_have_item(base_path, options = {})
38
- url = stub_content_store_endpoint(options[:draft]) + "/content" + base_path
40
+ url = content_store_endpoint(options[:draft]) + "/content" + base_path
39
41
  stub_request(:get, url).to_return(status: 404, headers: {})
40
42
 
41
- url = stub_content_store_endpoint(options[:draft]) + "/incoming-links" + base_path
43
+ url = content_store_endpoint(options[:draft]) + "/incoming-links" + base_path
42
44
  stub_request(:get, url).to_return(status: 404, headers: {})
43
45
  end
44
46
 
@@ -67,7 +69,7 @@ module GdsApi
67
69
  # "details" => {}
68
70
  # }
69
71
  def stub_content_store_has_gone_item(base_path, body = gone_content_item_for_base_path(base_path), options = {})
70
- url = stub_content_store_endpoint(options[:draft]) + "/content" + base_path
72
+ url = content_store_endpoint(options[:draft]) + "/content" + base_path
71
73
  body = body.to_json unless body.is_a?(String)
72
74
 
73
75
  stub_request(:get, url).to_return(
@@ -78,7 +80,7 @@ module GdsApi
78
80
  end
79
81
 
80
82
  def stub_content_store_isnt_available
81
- stub_request(:any, /#{stub_content_store_endpoint}\/.*/).to_return(status: 503)
83
+ stub_request(:any, /#{content_store_endpoint}\/.*/).to_return(status: 503)
82
84
  end
83
85
 
84
86
  def content_item_for_base_path(base_path)
@@ -86,19 +88,18 @@ module GdsApi
86
88
  end
87
89
 
88
90
  def stub_content_store_has_incoming_links(base_path, links)
89
- url = stub_content_store_endpoint + "/incoming-links" + base_path
91
+ url = content_store_endpoint + "/incoming-links" + base_path
90
92
  body = links.to_json
91
93
 
92
94
  stub_request(:get, url).to_return(body: body)
93
95
  end
94
96
 
95
97
  # Aliases for DEPRECATED methods
96
- alias_method :content_store_endpoint, :stub_content_store_endpoint
97
- alias_method :content_store_has_item, :stub_content_store_has_item
98
- alias_method :content_store_does_not_have_item, :stub_content_store_does_not_have_item
99
- alias_method :content_store_has_gone_item, :stub_content_store_has_gone_item
100
- alias_method :content_store_isnt_available, :stub_content_store_isnt_available
101
- alias_method :content_store_has_incoming_links, :stub_content_store_has_incoming_links
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
102
103
  end
103
104
  end
104
105
  end
@@ -1,8 +1,11 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
1
2
  require "gds_api/test_helpers/json_client_helper"
2
3
 
3
4
  module GdsApi
4
5
  module TestHelpers
5
6
  module Imminence
7
+ extend AliasDeprecated
8
+
6
9
  # Generally true. If you are initializing the client differently,
7
10
  # you could redefine/override the constant or stub directly.
8
11
  IMMINENCE_API_ENDPOINT = Plek.current.find("imminence")
@@ -34,10 +37,9 @@ module GdsApi
34
37
  to_return(status: status_code, body: return_data.to_json, headers: {})
35
38
  end
36
39
 
37
- # Aliases for DEPRECATED methods
38
- alias_method :imminence_has_places, :stub_imminence_has_places
39
- alias_method :imminence_has_areas_for_postcode, :stub_imminence_has_areas_for_postcode
40
- alias_method :imminence_has_places_for_postcode, :stub_imminence_has_places_for_postcode
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
41
43
  end
42
44
  end
43
45
  end
@@ -1,8 +1,11 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
1
2
  require "gds_api/test_helpers/json_client_helper"
2
3
 
3
4
  module GdsApi
4
5
  module TestHelpers
5
6
  module LicenceApplication
7
+ extend AliasDeprecated
8
+
6
9
  # Generally true. If you are initializing the client differently,
7
10
  # you could redefine/override the constant or stub directly.
8
11
  LICENCE_APPLICATION_ENDPOINT = Plek.current.find("licensify")
@@ -30,11 +33,10 @@ module GdsApi
30
33
  stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").to_return(status: 500)
31
34
  end
32
35
 
33
- # Aliases for DEPRECATED methods
34
- alias_method :licence_exists, :stub_licence_exists
35
- alias_method :licence_does_not_exist, :stub_licence_does_not_exist
36
- alias_method :licence_times_out, :stub_licence_times_out
37
- alias_method :licence_returns_error, :stub_licence_returns_error
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
38
40
  end
39
41
  end
40
42
  end
@@ -1,11 +1,13 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
1
2
  require "gds_api/test_helpers/json_client_helper"
2
3
 
3
4
  module GdsApi
4
5
  module TestHelpers
5
6
  module LinkCheckerApi
7
+ extend AliasDeprecated
6
8
  LINK_CHECKER_API_ENDPOINT = Plek.current.find("link-checker-api")
7
9
 
8
- def stub_link_checker_api_link_report_hash(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil)
10
+ def link_checker_api_link_report_hash(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil)
9
11
  {
10
12
  uri: uri,
11
13
  status: status,
@@ -17,18 +19,18 @@ module GdsApi
17
19
  }
18
20
  end
19
21
 
20
- def stub_link_checker_api_batch_report_hash(id:, status: :completed, links: [], totals: {}, completed_at: nil)
22
+ def link_checker_api_batch_report_hash(id:, status: :completed, links: [], totals: {}, completed_at: nil)
21
23
  {
22
24
  id: id,
23
25
  status: status,
24
- links: links.map { |hash| stub_link_checker_api_link_report_hash(**hash) },
26
+ links: links.map { |hash| link_checker_api_link_report_hash(**hash) },
25
27
  totals: totals,
26
28
  completed_at: completed_at || Time.now.iso8601,
27
29
  }
28
30
  end
29
31
 
30
32
  def stub_link_checker_api_check(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil)
31
- body = stub_link_checker_api_link_report_hash(
33
+ body = link_checker_api_link_report_hash(
32
34
  uri: uri, status: status, checked: checked, errors: errors, warnings: warnings, problem_summary: problem_summary, suggested_fix: suggested_fix,
33
35
  ).to_json
34
36
 
@@ -38,7 +40,7 @@ module GdsApi
38
40
  end
39
41
 
40
42
  def stub_link_checker_api_get_batch(id:, status: :completed, links: [], totals: {}, completed_at: nil)
41
- body = stub_link_checker_api_batch_report_hash(
43
+ body = link_checker_api_batch_report_hash(
42
44
  id: id, status: status, links: links, totals: totals, completed_at: completed_at,
43
45
  ).to_json
44
46
 
@@ -49,7 +51,7 @@ module GdsApi
49
51
  def stub_link_checker_api_create_batch(uris:, checked_within: nil, webhook_uri: nil, webhook_secret_token: nil, id: 0, status: :in_progress, links: nil, totals: {}, completed_at: nil)
50
52
  links = uris.map { |uri| { uri: uri } } if links.nil?
51
53
 
52
- response_body = stub_link_checker_api_batch_report_hash(
54
+ response_body = link_checker_api_batch_report_hash(
53
55
  id: id,
54
56
  status: status,
55
57
  links: links,
@@ -91,12 +93,10 @@ module GdsApi
91
93
  end
92
94
 
93
95
  # Aliases for DEPRECATED methods
94
- alias_method :link_checker_api_link_report_hash, :stub_link_checker_api_link_report_hash
95
- alias_method :link_checker_api_batch_report_hash, :stub_link_checker_api_batch_report_hash
96
- alias_method :link_checker_api_check, :stub_link_checker_api_check
97
- alias_method :link_checker_api_get_batch, :stub_link_checker_api_get_batch
98
- alias_method :link_checker_api_create_batch, :stub_link_checker_api_create_batch
99
- alias_method :link_checker_api_upsert_resource_monitor, :stub_link_checker_api_upsert_resource_monitor
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
100
  end
101
101
  end
102
102
  end
@@ -1,8 +1,10 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
1
2
  require "gds_api/test_helpers/json_client_helper"
2
3
 
3
4
  module GdsApi
4
5
  module TestHelpers
5
6
  module LocalLinksManager
7
+ extend AliasDeprecated
6
8
  LOCAL_LINKS_MANAGER_ENDPOINT = Plek.current.find("local-links-manager")
7
9
 
8
10
  def stub_local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:)
@@ -115,14 +117,14 @@ module GdsApi
115
117
 
116
118
  def stub_local_links_manager_request_without_local_authority_slug
117
119
  stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
118
- .with(query: { authority_slug: "" })
119
- .to_return(body: {}.to_json, status: 400)
120
+ .with(query: { authority_slug: "" })
121
+ .to_return(body: {}.to_json, status: 400)
120
122
  end
121
123
 
122
124
  def stub_local_links_manager_does_not_have_an_authority(authority_slug)
123
125
  stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
124
- .with(query: { authority_slug: authority_slug })
125
- .to_return(body: {}.to_json, status: 404)
126
+ .with(query: { authority_slug: authority_slug })
127
+ .to_return(body: {}.to_json, status: 404)
126
128
  end
127
129
 
128
130
  def stub_local_links_manager_has_a_local_authority_without_homepage(authority_slug)
@@ -141,17 +143,16 @@ module GdsApi
141
143
  .to_return(body: response.to_json, status: 200)
142
144
  end
143
145
 
144
- # Aliases for DEPRECATED methods
145
- alias_method :local_links_manager_has_a_link, :stub_local_links_manager_has_a_link
146
- alias_method :local_links_manager_has_no_link, :stub_local_links_manager_has_no_link
147
- alias_method :local_links_manager_has_no_link_and_no_homepage_url, :stub_local_links_manager_has_no_link_and_no_homepage_url
148
- alias_method :local_links_manager_request_with_missing_parameters, :stub_local_links_manager_request_with_missing_parameters
149
- alias_method :local_links_manager_does_not_have_required_objects, :stub_local_links_manager_does_not_have_required_objects
150
- alias_method :local_links_manager_has_a_local_authority, :stub_local_links_manager_has_a_local_authority
151
- alias_method :local_links_manager_has_a_district_and_county_local_authority, :stub_local_links_manager_has_a_district_and_county_local_authority
152
- alias_method :local_links_manager_request_without_local_authority_slug, :stub_local_links_manager_request_without_local_authority_slug
153
- alias_method :local_links_manager_does_not_have_an_authority, :stub_local_links_manager_does_not_have_an_authority
154
- alias_method :local_links_manager_has_a_local_authority_without_homepage, :stub_local_links_manager_has_a_local_authority_without_homepage
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
155
156
  end
156
157
  end
157
158
  end
@@ -1,6 +1,9 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
2
+
1
3
  module GdsApi
2
4
  module TestHelpers
3
5
  module Mapit
6
+ extend AliasDeprecated
4
7
  MAPIT_ENDPOINT = Plek.current.find("mapit")
5
8
 
6
9
  def stub_mapit_has_a_postcode(postcode, coords)
@@ -72,15 +75,14 @@ module GdsApi
72
75
  .to_return(body: { "code" => 404, "error" => "No areas were found that matched code #{code_type} = #{code}." }.to_json, status: 404)
73
76
  end
74
77
 
75
- # Aliases for DEPRECATED methods
76
- alias_method :mapit_has_a_postcode, :stub_mapit_has_a_postcode
77
- alias_method :mapit_has_a_postcode_and_areas, :stub_mapit_has_a_postcode_and_areas
78
- alias_method :mapit_does_not_have_a_postcode, :stub_mapit_does_not_have_a_postcode
79
- alias_method :mapit_does_not_have_a_bad_postcode, :stub_mapit_does_not_have_a_bad_postcode
80
- alias_method :mapit_has_areas, :stub_mapit_has_areas
81
- alias_method :mapit_does_not_have_areas, :stub_mapit_does_not_have_areas
82
- alias_method :mapit_has_area_for_code, :stub_mapit_has_area_for_code
83
- alias_method :mapit_does_not_have_area_for_code, :stub_mapit_does_not_have_area_for_code
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
84
86
  end
85
87
  end
86
88
  end
@@ -1,3 +1,4 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
1
2
  require "gds_api/test_helpers/json_client_helper"
2
3
  require "gds_api/test_helpers/common_responses"
3
4
  require "plek"
@@ -6,13 +7,14 @@ require "securerandom"
6
7
  module GdsApi
7
8
  module TestHelpers
8
9
  module Organisations
10
+ extend AliasDeprecated
9
11
  include GdsApi::TestHelpers::CommonResponses
10
12
 
11
13
  WEBSITE_ROOT = Plek.new.website_root
12
14
 
13
15
  def stub_organisations_api_has_organisations(organisation_slugs)
14
16
  bodies = organisation_slugs.map { |slug| organisation_for_slug(slug) }
15
- organisations_api_has_organisations_with_bodies(bodies)
17
+ stub_organisations_api_has_organisations_with_bodies(bodies)
16
18
  end
17
19
 
18
20
  # Sets up the index endpoints for the given organisation slugs
@@ -24,7 +26,7 @@ module GdsApi
24
26
  # Stub API call to the endpoint for an individual organisation
25
27
  organisation_bodies.each do |body|
26
28
  slug = body["details"]["slug"]
27
- organisations_api_has_organisation(slug, body)
29
+ stub_organisations_api_has_organisation(slug, body)
28
30
  end
29
31
 
30
32
  pages = []
@@ -116,11 +118,10 @@ module GdsApi
116
118
  }
117
119
  end
118
120
 
119
- # Aliases for DEPRECATED methods
120
- alias_method :organisations_api_has_organisations, :stub_organisations_api_has_organisations
121
- alias_method :organisations_api_has_organisations_with_bodies, :stub_organisations_api_has_organisations_with_bodies
122
- alias_method :organisations_api_has_organisation, :stub_organisations_api_has_organisation
123
- alias_method :organisations_api_does_not_have_organisation, :stub_organisations_api_does_not_have_organisation
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
124
125
  end
125
126
  end
126
127
  end
@@ -1,14 +1,14 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
1
2
  require "gds_api/test_helpers/json_client_helper"
2
3
  require "gds_api/test_helpers/content_item_helpers"
3
- require "gds_api/test_helpers/intent_helpers"
4
4
  require "json"
5
5
 
6
6
  module GdsApi
7
7
  module TestHelpers
8
8
  # @api documented
9
9
  module PublishingApi
10
+ extend AliasDeprecated
10
11
  include ContentItemHelpers
11
- include IntentHelpers
12
12
 
13
13
  PUBLISHING_API_V2_ENDPOINT = Plek.current.find("publishing-api") + "/v2"
14
14
  PUBLISHING_API_ENDPOINT = Plek.current.find("publishing-api")
@@ -641,10 +641,29 @@ module GdsApi
641
641
  stub_publishing_api_unreserve_path_with_code(base_path, publishing_app, 422)
642
642
  end
643
643
 
644
- def stub_publishing_api_put_intent(base_path, body = intent_for_publishing_api(base_path))
645
- url = PUBLISHING_API_ENDPOINT + "/publish-intent" + base_path
646
- body = body.to_json unless body.is_a?(String)
647
- stub_request(:put, url).with(body: body).to_return(status: 200, body: "{}", headers: { "Content-Type" => "application/json; charset=utf-8" })
644
+ # Stub a PUT /publish-intent/:base_path request with the given base_path
645
+ # and request body.
646
+ #
647
+ # @example
648
+ # stub_publishing_api_put_intent(
649
+ # "/path/to/content",
650
+ # publishing_app: "publisher",
651
+ # rendering_app: "frontend",
652
+ # publish_time: "2019-11-11T17:56:17+00:00",
653
+ # )
654
+ #
655
+ # @param base_path [String]
656
+ # @param params [Hash]
657
+ def stub_publishing_api_put_intent(base_path, params = {})
658
+ url = PUBLISHING_API_ENDPOINT + "/publish-intent#{base_path}"
659
+ body = params.is_a?(String) ? params : params.to_json
660
+
661
+ response = {
662
+ status: 200,
663
+ headers: { content_type: "application/json" },
664
+ body: body,
665
+ }
666
+ stub_request(:put, url).with(body: params).to_return(response)
648
667
  end
649
668
 
650
669
  def stub_publishing_api_destroy_intent(base_path)
@@ -689,11 +708,12 @@ module GdsApi
689
708
  end
690
709
  end
691
710
 
692
- # Stub a PUT /paths/:base_path request with the given content id and request body.
711
+ # Stub a PUT /paths/:base_path request with the given base_path and
712
+ # request body.
693
713
  #
694
714
  # @example
695
715
  # stub_publishing_api_path_reservation(
696
- # my_content_id,
716
+ # "/path/to",
697
717
  # publishing_app: "content-publisher",
698
718
  # override_existing: true,
699
719
  # )
@@ -780,25 +800,24 @@ module GdsApi
780
800
  body: { error: error }.to_json)
781
801
  end
782
802
 
783
- # Aliases for DEPRECATED methods
784
- alias_method :publishing_api_isnt_available, :stub_publishing_api_isnt_available
785
- alias_method :publishing_api_has_content, :stub_publishing_api_has_content
786
- alias_method :publishing_api_has_fields_for_document, :stub_publishing_api_has_fields_for_document
787
- alias_method :publishing_api_has_linkables, :stub_publishing_api_has_linkables
788
- alias_method :publishing_api_has_item, :stub_publishing_api_has_item
789
- alias_method :publishing_api_has_item_in_sequence, :stub_publishing_api_has_item_in_sequence
790
- alias_method :publishing_api_does_not_have_item, :stub_publishing_api_does_not_have_item
791
- alias_method :publishing_api_has_links, :stub_publishing_api_has_links
792
- alias_method :publishing_api_has_expanded_links, :stub_publishing_api_has_expanded_links
793
- alias_method :publishing_api_has_links_for_content_ids, :stub_publishing_api_has_links_for_content_ids
794
- alias_method :publishing_api_does_not_have_links, :stub_publishing_api_does_not_have_links
795
- alias_method :publishing_api_has_lookups, :stub_publishing_api_has_lookups
796
- alias_method :publishing_api_has_linked_items, :stub_publishing_api_has_linked_items
797
- alias_method :publishing_api_get_editions, :stub_publishing_api_get_editions
798
- alias_method :publishing_api_has_path_reservation_for, :stub_publishing_api_has_path_reservation_for
799
- alias_method :publishing_api_returns_path_reservation_validation_error_for, :stub_publishing_api_returns_path_reservation_validation_error_for
800
- alias_method :stub_default_publishing_api_path_reservation, :stub_any_publishing_api_path_reservation
801
- alias_method :stub_default_publishing_api_put_intent, :stub_any_publishing_api_put_intent
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
802
821
 
803
822
  private
804
823
 
@@ -884,10 +903,6 @@ module GdsApi
884
903
  def content_item_for_publishing_api(base_path, publishing_app = "publisher")
885
904
  content_item_for_base_path(base_path).merge("publishing_app" => publishing_app)
886
905
  end
887
-
888
- def intent_for_publishing_api(base_path, publishing_app = "publisher")
889
- intent_for_base_path(base_path).merge("publishing_app" => publishing_app)
890
- end
891
906
  end
892
907
  end
893
908
  end
@@ -1,6 +1,9 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
2
+
1
3
  module GdsApi
2
4
  module TestHelpers
3
5
  module Support
6
+ extend AliasDeprecated
4
7
  SUPPORT_ENDPOINT = Plek.current.find("support")
5
8
 
6
9
  def stub_support_foi_request_creation(request_details = nil)
@@ -19,8 +22,7 @@ module GdsApi
19
22
  stub_request(:post, /#{SUPPORT_ENDPOINT}\/.*/).to_return(status: 503)
20
23
  end
21
24
 
22
- # Aliases for DEPRECATED methods
23
- alias_method :support_isnt_available, :stub_support_isnt_available
25
+ alias_deprecated :support_isnt_available, :stub_support_isnt_available
24
26
  end
25
27
  end
26
28
  end
@@ -1,9 +1,11 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
1
2
  require "cgi"
2
3
  require "plek"
3
4
 
4
5
  module GdsApi
5
6
  module TestHelpers
6
7
  module SupportApi
8
+ extend AliasDeprecated
7
9
  SUPPORT_API_ENDPOINT = Plek.current.find("support-api")
8
10
 
9
11
  def stub_support_api_problem_report_creation(request_details = nil)
@@ -154,8 +156,7 @@ module GdsApi
154
156
  stub_request(:any, %r{\A#{SUPPORT_API_ENDPOINT}})
155
157
  end
156
158
 
157
- # Aliases for DEPRECATED methods
158
- alias_method :support_api_isnt_available, :stub_support_api_isnt_available
159
+ alias_deprecated :support_api_isnt_available, :stub_support_api_isnt_available
159
160
  end
160
161
  end
161
162
  end
@@ -1,9 +1,11 @@
1
+ require "gds_api/test_helpers/alias_deprecated"
1
2
  require "gds_api/test_helpers/json_client_helper"
2
3
  require "gds_api/test_helpers/common_responses"
3
4
 
4
5
  module GdsApi
5
6
  module TestHelpers
6
7
  module Worldwide
8
+ extend AliasDeprecated
7
9
  include GdsApi::TestHelpers::CommonResponses
8
10
 
9
11
  WORLDWIDE_API_ENDPOINT = Plek.current.find("whitehall-admin")
@@ -111,13 +113,12 @@ module GdsApi
111
113
  }
112
114
  end
113
115
 
114
- # Aliases for DEPRECATED methods
115
- alias_method :worldwide_api_has_locations, :stub_worldwide_api_has_locations
116
- alias_method :worldwide_api_has_selection_of_locations, :stub_worldwide_api_has_selection_of_locations
117
- alias_method :worldwide_api_has_location, :stub_worldwide_api_has_location
118
- alias_method :worldwide_api_has_does_not_have_location, :stub_worldwide_api_does_not_have_location
119
- alias_method :worldwide_api_has_organisations_for_location, :stub_worldwide_api_has_organisations_for_location
120
- alias_method :worldwide_api_has_no_organisations_for_location, :stub_worldwide_api_has_no_organisations_for_location
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
121
122
  end
122
123
  end
123
124
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "63.1.1".freeze
2
+ VERSION = "63.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 63.1.1
4
+ version: 63.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-20 00:00:00.000000000 Z
11
+ date: 2020-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -413,6 +413,7 @@ files:
413
413
  - lib/gds_api/search.rb
414
414
  - lib/gds_api/support.rb
415
415
  - lib/gds_api/support_api.rb
416
+ - lib/gds_api/test_helpers/alias_deprecated.rb
416
417
  - lib/gds_api/test_helpers/asset_manager.rb
417
418
  - lib/gds_api/test_helpers/calendars.rb
418
419
  - lib/gds_api/test_helpers/common_responses.rb
@@ -420,7 +421,6 @@ files:
420
421
  - lib/gds_api/test_helpers/content_store.rb
421
422
  - lib/gds_api/test_helpers/email_alert_api.rb
422
423
  - lib/gds_api/test_helpers/imminence.rb
423
- - lib/gds_api/test_helpers/intent_helpers.rb
424
424
  - lib/gds_api/test_helpers/json_client_helper.rb
425
425
  - lib/gds_api/test_helpers/licence_application.rb
426
426
  - lib/gds_api/test_helpers/link_checker_api.rb
@@ -1,12 +0,0 @@
1
- module GdsApi
2
- module TestHelpers
3
- module IntentHelpers
4
- def intent_for_base_path(base_path)
5
- {
6
- "base_path" => base_path,
7
- "publish_time" => "2014-05-06T12:01:00+00:00",
8
- }
9
- end
10
- end
11
- end
12
- end