gds-api-adapters 57.1.0 → 57.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: f5b774a41ffa2ba2ebf1192733d6b6fb6ee5e7cc321ce5b8f40d91656b3dc802
4
- data.tar.gz: a421fa1606c3965dd757fd34145f10ed49ca966e497a91994b3ea386256b2e83
3
+ metadata.gz: eee9acad1b82f0c97b918339d7b46752fce7775d3014463b2286b6cd57699487
4
+ data.tar.gz: 7b64a6cde3b3b3bc927b9c1289b3e15806c5cdbcdcdfe9e05c4b1115b52d1fe9
5
5
  SHA512:
6
- metadata.gz: f61caafa9f196b62616ff46e3596eea89b96581c37da97a8e709181939f1fe581aa25a6b75f8be306deca21a2627cc43d66c7a58728564a2f023941fba54a793
7
- data.tar.gz: 51c7fec99a993745e797c5cc1bffb31a14eb40cd8541bf3b56e1d483ea235763346264de9199966f89c2e73911c059c45155e853a049bcc63fa06b34958f9a54
6
+ metadata.gz: 6892f67fad0b240cfe536a341321f137047be6f2dd463a0aba61545060763cf5f574fa219347cbd57fd7e3029466a70672b31404b48362684e260ee787ec3df6
7
+ data.tar.gz: cb47e2660fca2477ba2e673bad8ee024512dc81e3cb3fc20ba316758deb51b3b39c75a89441156519e9bef7de5343872a133bb3cd9e4afdcc8c90e2fba9dc407
@@ -7,35 +7,35 @@ module GdsApi
7
7
  stub_request(:any, %r{\A#{ASSET_MANAGER_ENDPOINT}}).to_return(status: 200)
8
8
  end
9
9
 
10
- def asset_manager_is_down
10
+ def stub_asset_manager_is_down
11
11
  stub_request(:any, %r{\A#{ASSET_MANAGER_ENDPOINT}}).to_return(status: 503)
12
12
  end
13
13
 
14
- def asset_manager_updates_any_asset(body = {})
14
+ def stub_asset_manager_updates_any_asset(body = {})
15
15
  stub_request(:put, %r{\A#{ASSET_MANAGER_ENDPOINT}/assets})
16
16
  .to_return(body: body.to_json, status: 200)
17
17
  end
18
18
 
19
- def asset_manager_deletes_any_asset(body = {})
19
+ def stub_asset_manager_deletes_any_asset(body = {})
20
20
  stub_request(:delete, %r{\A#{ASSET_MANAGER_ENDPOINT}/assets})
21
21
  .to_return(body: body.to_json, status: 200)
22
22
  end
23
23
 
24
- def asset_manager_has_an_asset(id, atts)
24
+ def stub_asset_manager_has_an_asset(id, atts)
25
25
  response = atts.merge("_response_info" => { "status" => "ok" })
26
26
 
27
27
  stub_request(:get, "#{ASSET_MANAGER_ENDPOINT}/assets/#{id}")
28
28
  .to_return(body: response.to_json, status: 200)
29
29
  end
30
30
 
31
- def asset_manager_has_a_whitehall_asset(legacy_url_path, atts)
31
+ def stub_asset_manager_has_a_whitehall_asset(legacy_url_path, atts)
32
32
  response = atts.merge("_response_info" => { "status" => "ok" })
33
33
 
34
34
  stub_request(:get, "#{ASSET_MANAGER_ENDPOINT}/whitehall_assets/#{legacy_url_path}")
35
35
  .to_return(body: response.to_json, status: 200)
36
36
  end
37
37
 
38
- def asset_manager_does_not_have_an_asset(id)
38
+ def stub_asset_manager_does_not_have_an_asset(id)
39
39
  response = {
40
40
  "_response_info" => { "status" => "not found" }
41
41
  }
@@ -44,7 +44,7 @@ module GdsApi
44
44
  .to_return(body: response.to_json, status: 404)
45
45
  end
46
46
 
47
- def asset_manager_does_not_have_a_whitehall_asset(legacy_url_path)
47
+ def stub_asset_manager_does_not_have_a_whitehall_asset(legacy_url_path)
48
48
  response = {
49
49
  "_response_info" => { "status" => "not found" }
50
50
  }
@@ -56,17 +56,17 @@ module GdsApi
56
56
  # This can take a string of an exact url or a hash of options
57
57
  #
58
58
  # with a string:
59
- # `asset_manager_receives_an_asset("https://asset-manager/media/619ce797-b415-42e5-b2b1-2ffa0df52302/file.jpg")`
59
+ # `stub_asset_manager_receives_an_asset("https://asset-manager/media/619ce797-b415-42e5-b2b1-2ffa0df52302/file.jpg")`
60
60
  #
61
61
  # with a hash:
62
- # `asset_manager_receives_an_asset(id: "20d04259-e3ae-4f71-8157-e6c843096e96", filename: "file.jpg")`
62
+ # `stub_asset_manager_receives_an_asset(id: "20d04259-e3ae-4f71-8157-e6c843096e96", filename: "file.jpg")`
63
63
  # which would return a file url of "https://asset-manager/media/20d04259-e3ae-4f71-8157-e6c843096e96/file.jpg"
64
64
  #
65
65
  # with no argument
66
66
  #
67
- # `asset_manager_receives_an_asset`
67
+ # `stub_asset_manager_receives_an_asset`
68
68
  # which would return a file url of "https://asset-manager/media/0053adbf-0737-4923-9d8a-8180f2c723af/0d19136c4a94f07"
69
- def asset_manager_receives_an_asset(response_url = {})
69
+ def stub_asset_manager_receives_an_asset(response_url = {})
70
70
  stub_request(:post, "#{ASSET_MANAGER_ENDPOINT}/assets").to_return do
71
71
  unless response_url.is_a?(String)
72
72
  options = {
@@ -80,27 +80,41 @@ module GdsApi
80
80
  end
81
81
  end
82
82
 
83
- def asset_manager_upload_failure
83
+ def stub_asset_manager_upload_failure
84
84
  stub_request(:post, "#{ASSET_MANAGER_ENDPOINT}/assets").to_return(status: 500)
85
85
  end
86
86
 
87
- def asset_manager_update_asset(asset_id, body = {})
87
+ def stub_asset_manager_update_asset(asset_id, body = {})
88
88
  stub_request(:put, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}")
89
89
  .to_return(body: body.to_json, status: 200)
90
90
  end
91
91
 
92
- def asset_manager_update_failure(asset_id)
92
+ def stub_asset_manager_update_asset_failure(asset_id)
93
93
  stub_request(:put, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}").to_return(status: 500)
94
94
  end
95
95
 
96
- def asset_manager_delete_asset(asset_id, body = {})
96
+ def stub_asset_manager_delete_asset(asset_id, body = {})
97
97
  stub_request(:delete, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}")
98
98
  .to_return(body: body.to_json, status: 200)
99
99
  end
100
100
 
101
- def asset_manager_delete_asset_failure(asset_id)
101
+ def stub_asset_manager_delete_asset_failure(asset_id)
102
102
  stub_request(:delete, "#{ASSET_MANAGER_ENDPOINT}/assets/#{asset_id}").to_return(status: 500)
103
103
  end
104
+
105
+ # Aliases for DEPRECATED methods
106
+ alias_method :asset_manager_is_down, :stub_asset_manager_is_down
107
+ alias_method :asset_manager_updates_any_asset, :stub_asset_manager_updates_any_asset
108
+ alias_method :asset_manager_deletes_any_asset, :stub_asset_manager_deletes_any_asset
109
+ alias_method :asset_manager_has_an_asset, :stub_asset_manager_has_an_asset
110
+ alias_method :asset_manager_has_a_whitehall_asset, :stub_asset_manager_has_a_whitehall_asset
111
+ alias_method :asset_manager_does_not_have_an_asset, :stub_asset_manager_does_not_have_an_asset
112
+ alias_method :asset_manager_does_not_have_a_whitehall_asset, :stub_asset_manager_does_not_have_a_whitehall_asset
113
+ alias_method :asset_manager_receives_an_asset, :stub_asset_manager_receives_an_asset
114
+ alias_method :asset_manager_update_asset, :stub_asset_manager_update_asset
115
+ alias_method :asset_manager_update_failure, :stub_asset_manager_update_asset_failure
116
+ alias_method :asset_manager_delete_asset, :stub_asset_manager_delete_asset
117
+ alias_method :asset_manager_delete_failure, :stub_asset_manager_delete_asset_failure
104
118
  end
105
119
  end
106
120
  end
@@ -3,17 +3,18 @@ module GdsApi
3
3
  module Calendars
4
4
  CALENDARS_ENDPOINT = Plek.current.find('calendars')
5
5
 
6
- def calendars_endpoint(in_division: nil)
6
+
7
+ def stub_calendars_endpoint(in_division: nil)
7
8
  endpoint = "#{CALENDARS_ENDPOINT}/bank-holidays"
8
9
  endpoint += "/#{in_division}" unless in_division.nil?
9
10
  endpoint + '.json'
10
11
  end
11
12
 
12
- def calendars_has_no_bank_holidays(in_division: nil)
13
+ def stub_calendars_has_no_bank_holidays(in_division: nil)
13
14
  calendars_has_bank_holidays_on([], in_division: in_division)
14
15
  end
15
16
 
16
- def calendars_has_bank_holidays_on(dates, in_division: nil)
17
+ def stub_calendars_has_bank_holidays_on(dates, in_division: nil)
17
18
  events = dates.map.with_index do |date, idx|
18
19
  {
19
20
  title: "Caturday #{idx}!",
@@ -50,9 +51,15 @@ module GdsApi
50
51
  .to_return(body: response.to_json, status: 200)
51
52
  end
52
53
 
53
- def calendars_has_a_bank_holiday_on(date, in_division: nil)
54
+ def stub_calendars_has_a_bank_holiday_on(date, in_division: nil)
54
55
  calendars_has_bank_holidays_on([date], in_division: in_division)
55
56
  end
57
+
58
+ # Aliases for DEPRECATED methods
59
+ alias_method :calendars_endpoint, :stub_calendars_endpoint
60
+ alias_method :calendars_has_no_bank_holidays, :stub_calendars_has_no_bank_holidays
61
+ alias_method :calendars_has_bank_holidays_on, :stub_calendars_has_bank_holidays_on
62
+ alias_method :calendars_has_a_bank_holiday_on, :stub_calendars_has_a_bank_holiday_on
56
63
  end
57
64
  end
58
65
  end
@@ -14,15 +14,14 @@ module GdsApi
14
14
  # :private if true, the Cache-Control header will include the "private" directive. By default it
15
15
  # will include "public"
16
16
  # :draft will point to the draft content store if set to true
17
-
18
- def content_store_endpoint(draft = false)
17
+ def stub_content_store_endpoint(draft = false)
19
18
  draft ? Plek.current.find('draft-content-store') : Plek.current.find('content-store')
20
19
  end
21
20
 
22
- def content_store_has_item(base_path, body = content_item_for_base_path(base_path), options = {})
21
+ def stub_content_store_has_item(base_path, body = content_item_for_base_path(base_path), options = {})
23
22
  max_age = options.fetch(:max_age, 900)
24
23
  visibility = options[:private] ? "private" : "public"
25
- url = content_store_endpoint(options[:draft]) + "/content" + base_path
24
+ url = stub_content_store_endpoint(options[:draft]) + "/content" + base_path
26
25
  body = body.to_json unless body.is_a?(String)
27
26
 
28
27
  stub_request(:get, url).to_return(
@@ -35,11 +34,11 @@ module GdsApi
35
34
  )
36
35
  end
37
36
 
38
- def content_store_does_not_have_item(base_path, options = {})
39
- url = content_store_endpoint(options[:draft]) + "/content" + base_path
37
+ def stub_content_store_does_not_have_item(base_path, options = {})
38
+ url = stub_content_store_endpoint(options[:draft]) + "/content" + base_path
40
39
  stub_request(:get, url).to_return(status: 404, headers: {})
41
40
 
42
- url = content_store_endpoint(options[:draft]) + "/incoming-links" + base_path
41
+ url = stub_content_store_endpoint(options[:draft]) + "/incoming-links" + base_path
43
42
  stub_request(:get, url).to_return(status: 404, headers: {})
44
43
  end
45
44
 
@@ -54,7 +53,7 @@ module GdsApi
54
53
  #
55
54
  # @example
56
55
  #
57
- # content_store.content_store_has_gone_item('/sample-slug')
56
+ # stub_content_store.stub_content_store_has_gone_item('/sample-slug')
58
57
  #
59
58
  # # Will return HTTP Status Code 410 and the following response body:
60
59
  # {
@@ -67,8 +66,8 @@ module GdsApi
67
66
  # "withdrawn_notice" => {},
68
67
  # "details" => {}
69
68
  # }
70
- def content_store_has_gone_item(base_path, body = gone_content_item_for_base_path(base_path), options = {})
71
- url = content_store_endpoint(options[:draft]) + "/content" + base_path
69
+ 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
71
  body = body.to_json unless body.is_a?(String)
73
72
 
74
73
  stub_request(:get, url).to_return(
@@ -78,20 +77,28 @@ module GdsApi
78
77
  )
79
78
  end
80
79
 
81
- def content_store_isnt_available
82
- stub_request(:any, /#{content_store_endpoint}\/.*/).to_return(status: 503)
80
+ def stub_content_store_isnt_available
81
+ stub_request(:any, /#{stub_content_store_endpoint}\/.*/).to_return(status: 503)
83
82
  end
84
83
 
85
84
  def content_item_for_base_path(base_path)
86
85
  super.merge("base_path" => base_path)
87
86
  end
88
87
 
89
- def content_store_has_incoming_links(base_path, links)
90
- url = content_store_endpoint + "/incoming-links" + base_path
88
+ def stub_content_store_has_incoming_links(base_path, links)
89
+ url = stub_content_store_endpoint + "/incoming-links" + base_path
91
90
  body = links.to_json
92
91
 
93
92
  stub_request(:get, url).to_return(body: body)
94
93
  end
94
+
95
+ # 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
95
102
  end
96
103
  end
97
104
  end
@@ -6,7 +6,7 @@ module GdsApi
6
6
  module EmailAlertApi
7
7
  EMAIL_ALERT_API_ENDPOINT = Plek.find("email-alert-api")
8
8
 
9
- def email_alert_api_has_updated_subscriber(id, new_address)
9
+ def stub_email_alert_api_has_updated_subscriber(id, new_address)
10
10
  stub_request(:patch, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/#{id}")
11
11
  .to_return(
12
12
  status: 200,
@@ -14,12 +14,12 @@ module GdsApi
14
14
  )
15
15
  end
16
16
 
17
- def email_alert_api_does_not_have_updated_subscriber(id)
17
+ def stub_email_alert_api_does_not_have_updated_subscriber(id)
18
18
  stub_request(:patch, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/#{id}")
19
19
  .to_return(status: 404)
20
20
  end
21
21
 
22
- def email_alert_api_has_updated_subscription(subscription_id, frequency)
22
+ def stub_email_alert_api_has_updated_subscription(subscription_id, frequency)
23
23
  stub_request(:patch, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/#{subscription_id}")
24
24
  .to_return(
25
25
  status: 200,
@@ -27,12 +27,12 @@ module GdsApi
27
27
  )
28
28
  end
29
29
 
30
- def email_alert_api_does_not_have_updated_subscription(subscription_id)
30
+ def stub_email_alert_api_does_not_have_updated_subscription(subscription_id)
31
31
  stub_request(:patch, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/#{subscription_id}")
32
32
  .to_return(status: 404)
33
33
  end
34
34
 
35
- def email_alert_api_has_subscriber_subscriptions(id, address)
35
+ def stub_email_alert_api_has_subscriber_subscriptions(id, address)
36
36
  stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/#{id}/subscriptions")
37
37
  .to_return(
38
38
  status: 200,
@@ -40,12 +40,12 @@ module GdsApi
40
40
  )
41
41
  end
42
42
 
43
- def email_alert_api_does_not_have_subscriber_subscriptions(id)
43
+ def stub_email_alert_api_does_not_have_subscriber_subscriptions(id)
44
44
  stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/#{id}/subscriptions")
45
45
  .to_return(status: 404)
46
46
  end
47
47
 
48
- def email_alert_api_has_subscription(
48
+ def stub_email_alert_api_has_subscription(
49
49
  id,
50
50
  frequency,
51
51
  title: "Some title",
@@ -67,7 +67,7 @@ module GdsApi
67
67
  )
68
68
  end
69
69
 
70
- def email_alert_api_has_subscriber_list(attributes)
70
+ def stub_email_alert_api_has_subscriber_list(attributes)
71
71
  stub_request(:get, build_subscriber_lists_url(attributes))
72
72
  .to_return(
73
73
  status: 200,
@@ -75,12 +75,12 @@ module GdsApi
75
75
  )
76
76
  end
77
77
 
78
- def email_alert_api_does_not_have_subscriber_list(attributes)
78
+ def stub_email_alert_api_does_not_have_subscriber_list(attributes)
79
79
  stub_request(:get, build_subscriber_lists_url(attributes))
80
80
  .to_return(status: 404)
81
81
  end
82
82
 
83
- def email_alert_api_creates_subscriber_list(attributes)
83
+ def stub_email_alert_api_creates_subscriber_list(attributes)
84
84
  stub_request(:post, build_subscriber_lists_url)
85
85
  .to_return(
86
86
  status: 201,
@@ -88,17 +88,17 @@ module GdsApi
88
88
  )
89
89
  end
90
90
 
91
- def email_alert_api_refuses_to_create_subscriber_list
91
+ def stub_email_alert_api_refuses_to_create_subscriber_list
92
92
  stub_request(:post, build_subscriber_lists_url)
93
93
  .to_return(status: 422)
94
94
  end
95
95
 
96
- def email_alert_api_accepts_unpublishing_message
96
+ def stub_email_alert_api_accepts_unpublishing_message
97
97
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/unpublish-messages")
98
98
  .to_return(status: 202, body: {}.to_json)
99
99
  end
100
100
 
101
- def email_alert_api_accepts_alert
101
+ def stub_email_alert_api_accepts_alert
102
102
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/notifications")
103
103
  .to_return(status: 202, body: {}.to_json)
104
104
  end
@@ -118,7 +118,7 @@ module GdsApi
118
118
  assert_requested(:post, "#{EMAIL_ALERT_API_ENDPOINT}/notifications", times: 1, &matcher)
119
119
  end
120
120
 
121
- def email_alert_api_has_notifications(notifications, start_at = nil)
121
+ def stub_email_alert_api_has_notifications(notifications, start_at = nil)
122
122
  url = "#{EMAIL_ALERT_API_ENDPOINT}/notifications"
123
123
  url += "?start_at=#{start_at}" if start_at
124
124
  url_regexp = Regexp.new("^#{Regexp.escape(url)}$")
@@ -130,7 +130,7 @@ module GdsApi
130
130
  )
131
131
  end
132
132
 
133
- def email_alert_api_has_notification(notification)
133
+ def stub_email_alert_api_has_notification(notification)
134
134
  url = "#{EMAIL_ALERT_API_ENDPOINT}/notifications/#{notification['web_service_bulletin']['to_param']}"
135
135
 
136
136
  stub_request(:get, url).to_return(
@@ -139,50 +139,50 @@ module GdsApi
139
139
  )
140
140
  end
141
141
 
142
- def email_alert_api_unsubscribes_a_subscription(uuid)
142
+ def stub_email_alert_api_unsubscribes_a_subscription(uuid)
143
143
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/unsubscribe/#{uuid}")
144
144
  .with(body: "{}")
145
145
  .to_return(status: 204)
146
146
  end
147
147
 
148
- def email_alert_api_has_no_subscription_for_uuid(uuid)
148
+ def stub_email_alert_api_has_no_subscription_for_uuid(uuid)
149
149
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/unsubscribe/#{uuid}")
150
150
  .with(body: "{}")
151
151
  .to_return(status: 404)
152
152
  end
153
153
 
154
- def email_alert_api_unsubscribes_a_subscriber(subscriber_id)
154
+ def stub_email_alert_api_unsubscribes_a_subscriber(subscriber_id)
155
155
  stub_request(:delete, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/#{subscriber_id}")
156
156
  .to_return(status: 204)
157
157
  end
158
158
 
159
- def email_alert_api_has_no_subscriber(subscriber_id)
159
+ def stub_email_alert_api_has_no_subscriber(subscriber_id)
160
160
  stub_request(:delete, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/#{subscriber_id}")
161
161
  .to_return(status: 404)
162
162
  end
163
163
 
164
- def email_alert_api_creates_a_subscription(subscribable_id, address, frequency, returned_subscription_id)
164
+ def stub_email_alert_api_creates_a_subscription(subscribable_id, address, frequency, returned_subscription_id)
165
165
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
166
166
  .with(
167
167
  body: { subscribable_id: subscribable_id, address: address, frequency: frequency }.to_json
168
168
  ).to_return(status: 201, body: { subscription_id: returned_subscription_id }.to_json)
169
169
  end
170
170
 
171
- def email_alert_api_creates_an_existing_subscription(subscribable_id, address, frequency, returned_subscription_id)
171
+ def stub_email_alert_api_creates_an_existing_subscription(subscribable_id, address, frequency, returned_subscription_id)
172
172
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
173
173
  .with(
174
174
  body: { subscribable_id: subscribable_id, address: address, frequency: frequency }.to_json
175
175
  ).to_return(status: 200, body: { subscription_id: returned_subscription_id }.to_json)
176
176
  end
177
177
 
178
- def email_alert_api_refuses_to_create_subscription(subscribable_id, address, frequency)
178
+ def stub_email_alert_api_refuses_to_create_subscription(subscribable_id, address, frequency)
179
179
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
180
180
  .with(
181
181
  body: { subscribable_id: subscribable_id, address: address, frequency: frequency }.to_json
182
182
  ).to_return(status: 422)
183
183
  end
184
184
 
185
- def email_alert_api_creates_an_auth_token(subscriber_id, address)
185
+ def stub_email_alert_api_creates_an_auth_token(subscriber_id, address)
186
186
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/auth-token")
187
187
  .to_return(
188
188
  status: 201,
@@ -204,7 +204,7 @@ module GdsApi
204
204
  end
205
205
  end
206
206
 
207
- def email_alert_api_has_subscribable(reference:, returned_attributes:)
207
+ def stub_email_alert_api_has_subscribable(reference:, returned_attributes:)
208
208
  stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscribables/#{reference}")
209
209
  .to_return(
210
210
  status: 200,
@@ -214,11 +214,38 @@ module GdsApi
214
214
  )
215
215
  end
216
216
 
217
- def email_alert_api_does_not_have_subscribable(reference:)
217
+ def stub_email_alert_api_does_not_have_subscribable(reference:)
218
218
  stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscribables/#{reference}")
219
219
  .to_return(status: 404)
220
220
  end
221
221
 
222
+ # Aliases for DEPRECATED methods
223
+ alias_method :email_alert_api_has_updated_subscriber, :stub_email_alert_api_has_updated_subscriber
224
+ alias_method :email_alert_api_does_not_have_updated_subscriber, :stub_email_alert_api_does_not_have_updated_subscriber
225
+ alias_method :email_alert_api_has_updated_subscription, :stub_email_alert_api_has_updated_subscription
226
+ alias_method :email_alert_api_does_not_have_updated_subscription, :stub_email_alert_api_does_not_have_updated_subscription
227
+ alias_method :email_alert_api_has_subscriber_subscriptions, :stub_email_alert_api_has_subscriber_subscriptions
228
+ alias_method :email_alert_api_does_not_have_subscriber_subscriptions, :stub_email_alert_api_does_not_have_subscriber_subscriptions
229
+ alias_method :email_alert_api_has_subscription, :stub_email_alert_api_has_subscription
230
+ alias_method :email_alert_api_has_subscriber_list, :stub_email_alert_api_has_subscriber_list
231
+ alias_method :email_alert_api_does_not_have_subscriber_list, :stub_email_alert_api_does_not_have_subscriber_list
232
+ alias_method :email_alert_api_creates_subscriber_list, :stub_email_alert_api_creates_subscriber_list
233
+ alias_method :email_alert_api_refuses_to_create_subscriber_list, :stub_email_alert_api_refuses_to_create_subscriber_list
234
+ alias_method :email_alert_api_accepts_unpublishing_message, :stub_email_alert_api_accepts_unpublishing_message
235
+ alias_method :email_alert_api_accepts_alert, :stub_email_alert_api_accepts_alert
236
+ alias_method :email_alert_api_has_notifications, :stub_email_alert_api_has_notifications
237
+ alias_method :email_alert_api_has_notification, :stub_email_alert_api_has_notification
238
+ alias_method :email_alert_api_unsubscribes_a_subscription, :stub_email_alert_api_unsubscribes_a_subscription
239
+ alias_method :email_alert_api_has_no_subscription_for_uuid, :stub_email_alert_api_has_no_subscription_for_uuid
240
+ alias_method :email_alert_api_unsubscribes_a_subscriber, :stub_email_alert_api_unsubscribes_a_subscriber
241
+ alias_method :email_alert_api_has_no_subscriber, :stub_email_alert_api_has_no_subscriber
242
+ alias_method :email_alert_api_creates_a_subscription, :stub_email_alert_api_creates_a_subscription
243
+ alias_method :email_alert_api_creates_an_existing_subscription, :stub_email_alert_api_creates_an_existing_subscription
244
+ alias_method :email_alert_api_refuses_to_create_subscription, :stub_email_alert_api_refuses_to_create_subscription
245
+ alias_method :email_alert_api_creates_an_auth_token, :stub_email_alert_api_creates_an_auth_token
246
+ alias_method :email_alert_api_has_subscribable, :stub_email_alert_api_has_subscribable
247
+ alias_method :email_alert_api_does_not_have_subscribable, :stub_email_alert_api_does_not_have_subscribable
248
+
222
249
  private
223
250
 
224
251
  def get_subscriber_response(id, address)
@@ -7,12 +7,12 @@ module GdsApi
7
7
  # you could redefine/override the constant or stub directly.
8
8
  IMMINENCE_API_ENDPOINT = Plek.current.find('imminence')
9
9
 
10
- def imminence_has_places(latitude, longitude, details)
10
+ def stub_imminence_has_places(latitude, longitude, details)
11
11
  query_hash = { "lat" => latitude, "lng" => longitude, "limit" => "5" }
12
12
  stub_imminence_places_request(details['slug'], query_hash, details['details'])
13
13
  end
14
14
 
15
- def imminence_has_areas_for_postcode(postcode, areas)
15
+ def stub_imminence_has_areas_for_postcode(postcode, areas)
16
16
  results = {
17
17
  "_response_info" => { "status" => "ok" },
18
18
  "total" => areas.size, "startIndex" => 1, "pageSize" => areas.size,
@@ -23,7 +23,7 @@ module GdsApi
23
23
  to_return(body: results.to_json)
24
24
  end
25
25
 
26
- def imminence_has_places_for_postcode(places, slug, postcode, limit)
26
+ def stub_imminence_has_places_for_postcode(places, slug, postcode, limit)
27
27
  query_hash = { "postcode" => postcode, "limit" => limit }
28
28
  stub_imminence_places_request(slug, query_hash, places)
29
29
  end
@@ -33,6 +33,11 @@ module GdsApi
33
33
  with(query: query_hash).
34
34
  to_return(status: status_code, body: return_data.to_json, headers: {})
35
35
  end
36
+
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
36
41
  end
37
42
  end
38
43
  end
@@ -7,7 +7,7 @@ module GdsApi
7
7
  # you could redefine/override the constant or stub directly.
8
8
  LICENCE_APPLICATION_ENDPOINT = Plek.current.find("licensify")
9
9
 
10
- def licence_exists(identifier, licence)
10
+ def stub_licence_exists(identifier, licence)
11
11
  licence = licence.to_json unless licence.is_a?(String)
12
12
  stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").
13
13
  with(headers: GdsApi::JsonClient.default_request_headers).
@@ -15,20 +15,26 @@ module GdsApi
15
15
  body: licence)
16
16
  end
17
17
 
18
- def licence_does_not_exist(identifier)
18
+ def stub_licence_does_not_exist(identifier)
19
19
  stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").
20
20
  with(headers: GdsApi::JsonClient.default_request_headers).
21
21
  to_return(status: 404,
22
22
  body: "{\"error\": [\"Unrecognised Licence Id: #{identifier}\"]}")
23
23
  end
24
24
 
25
- def licence_times_out(identifier)
25
+ def stub_licence_times_out(identifier)
26
26
  stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").to_timeout
27
27
  end
28
28
 
29
- def licence_returns_error(identifier)
29
+ def stub_licence_returns_error(identifier)
30
30
  stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").to_return(status: 500)
31
31
  end
32
+
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
32
38
  end
33
39
  end
34
40
  end
@@ -5,7 +5,7 @@ module GdsApi
5
5
  module LinkCheckerApi
6
6
  LINK_CHECKER_API_ENDPOINT = Plek.current.find("link-checker-api")
7
7
 
8
- def link_checker_api_link_report_hash(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil)
8
+ def stub_link_checker_api_link_report_hash(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil)
9
9
  {
10
10
  uri: uri,
11
11
  status: status,
@@ -17,18 +17,18 @@ module GdsApi
17
17
  }
18
18
  end
19
19
 
20
- def link_checker_api_batch_report_hash(id:, status: :completed, links: [], totals: {}, completed_at: nil)
20
+ def stub_link_checker_api_batch_report_hash(id:, status: :completed, links: [], totals: {}, completed_at: nil)
21
21
  {
22
22
  id: id,
23
23
  status: status,
24
- links: links.map { |hash| link_checker_api_link_report_hash(**hash) },
24
+ links: links.map { |hash| stub_link_checker_api_link_report_hash(**hash) },
25
25
  totals: totals,
26
26
  completed_at: completed_at || Time.now.iso8601,
27
27
  }
28
28
  end
29
29
 
30
- def link_checker_api_check(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil)
31
- body = link_checker_api_link_report_hash(
30
+ 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(
32
32
  uri: uri, status: status, checked: checked, errors: errors, warnings: warnings, problem_summary: problem_summary, suggested_fix: suggested_fix,
33
33
  ).to_json
34
34
 
@@ -37,8 +37,8 @@ module GdsApi
37
37
  .to_return(body: body, status: 200, headers: { "Content-Type" => "application/json" })
38
38
  end
39
39
 
40
- def link_checker_api_get_batch(id:, status: :completed, links: [], totals: {}, completed_at: nil)
41
- body = link_checker_api_batch_report_hash(
40
+ def stub_link_checker_api_get_batch(id:, status: :completed, links: [], totals: {}, completed_at: nil)
41
+ body = stub_link_checker_api_batch_report_hash(
42
42
  id: id, status: status, links: links, totals: totals, completed_at: completed_at
43
43
  ).to_json
44
44
 
@@ -46,10 +46,10 @@ module GdsApi
46
46
  .to_return(body: body, status: 200, headers: { "Content-Type" => "application/json" })
47
47
  end
48
48
 
49
- def 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)
49
+ 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
50
  links = uris.map { |uri| { uri: uri } } if links.nil?
51
51
 
52
- response_body = link_checker_api_batch_report_hash(
52
+ response_body = stub_link_checker_api_batch_report_hash(
53
53
  id: id,
54
54
  status: status,
55
55
  links: links,
@@ -73,7 +73,7 @@ module GdsApi
73
73
  )
74
74
  end
75
75
 
76
- def link_checker_api_upsert_resource_monitor(app:, reference:, links:)
76
+ def stub_link_checker_api_upsert_resource_monitor(app:, reference:, links:)
77
77
  response_body = { id: 1 }.to_json
78
78
 
79
79
  request_body = {
@@ -89,6 +89,14 @@ module GdsApi
89
89
  headers: { "Content-Type" => "application/json" }
90
90
  )
91
91
  end
92
+
93
+ # Aliases for DEPRECATED methods
94
+ alias_method :link_link_checker_api_link_report_hash, :stub_link_checker_api_link_report_hash
95
+ alias_method :link_link_checker_api_batch_report_hash, :stub_link_checker_api_batch_report_hash
96
+ alias_method :link_link_checker_api_check, :stub_link_checker_api_check
97
+ alias_method :link_link_checker_api_get_batch, :stub_link_checker_api_get_batch
98
+ alias_method :link_link_checker_api_create_batch, :stub_link_checker_api_create_batch
99
+ alias_method :link_link_checker_api_upsert_resource_monitor, :stub_link_checker_api_upsert_resource_monitor
92
100
  end
93
101
  end
94
102
  end
@@ -5,7 +5,7 @@ module GdsApi
5
5
  module LocalLinksManager
6
6
  LOCAL_LINKS_MANAGER_ENDPOINT = Plek.current.find('local-links-manager')
7
7
 
8
- def local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:)
8
+ def stub_local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:)
9
9
  response = {
10
10
  "local_authority" => {
11
11
  "name" => authority_slug.capitalize,
@@ -25,7 +25,7 @@ module GdsApi
25
25
  .to_return(body: response.to_json, status: 200)
26
26
  end
27
27
 
28
- def local_links_manager_has_no_link(authority_slug:, lgsl:, lgil:)
28
+ def stub_local_links_manager_has_no_link(authority_slug:, lgsl:, lgil:)
29
29
  response = {
30
30
  "local_authority" => {
31
31
  "name" => authority_slug.capitalize,
@@ -40,7 +40,7 @@ module GdsApi
40
40
  .to_return(body: response.to_json, status: 200)
41
41
  end
42
42
 
43
- def local_links_manager_has_no_link_and_no_homepage_url(authority_slug:, lgsl:, lgil:)
43
+ def stub_local_links_manager_has_no_link_and_no_homepage_url(authority_slug:, lgsl:, lgil:)
44
44
  response = {
45
45
  "local_authority" => {
46
46
  "name" => authority_slug.capitalize,
@@ -55,7 +55,7 @@ module GdsApi
55
55
  .to_return(body: response.to_json, status: 200)
56
56
  end
57
57
 
58
- def local_links_manager_request_with_missing_parameters(authority_slug, lgsl, lgil)
58
+ def stub_local_links_manager_request_with_missing_parameters(authority_slug, lgsl, lgil)
59
59
  # convert nil to an empty string, otherwise query param is not expressed correctly
60
60
  params = {
61
61
  authority_slug: authority_slug || "",
@@ -68,7 +68,7 @@ module GdsApi
68
68
  .to_return(body: {}.to_json, status: 400)
69
69
  end
70
70
 
71
- def local_links_manager_does_not_have_required_objects(authority_slug, lgsl, lgil)
71
+ def stub_local_links_manager_does_not_have_required_objects(authority_slug, lgsl, lgil)
72
72
  params = { authority_slug: authority_slug, lgsl: lgsl, lgil: lgil }
73
73
 
74
74
  stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link")
@@ -76,7 +76,7 @@ module GdsApi
76
76
  .to_return(body: {}.to_json, status: 404)
77
77
  end
78
78
 
79
- def local_links_manager_has_a_local_authority(authority_slug)
79
+ def stub_local_links_manager_has_a_local_authority(authority_slug)
80
80
  response = {
81
81
  "local_authorities" => [
82
82
  {
@@ -92,7 +92,7 @@ module GdsApi
92
92
  .to_return(body: response.to_json, status: 200)
93
93
  end
94
94
 
95
- def local_links_manager_has_a_district_and_county_local_authority(district_slug, county_slug)
95
+ def stub_local_links_manager_has_a_district_and_county_local_authority(district_slug, county_slug)
96
96
  response = {
97
97
  "local_authorities" => [
98
98
  {
@@ -113,19 +113,19 @@ module GdsApi
113
113
  .to_return(body: response.to_json, status: 200)
114
114
  end
115
115
 
116
- def local_links_manager_request_without_local_authority_slug
116
+ def stub_local_links_manager_request_without_local_authority_slug
117
117
  stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
118
118
  .with(query: { authority_slug: '' })
119
119
  .to_return(body: {}.to_json, status: 400)
120
120
  end
121
121
 
122
- def local_links_manager_does_not_have_an_authority(authority_slug)
122
+ def stub_local_links_manager_does_not_have_an_authority(authority_slug)
123
123
  stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority")
124
124
  .with(query: { authority_slug: authority_slug })
125
125
  .to_return(body: {}.to_json, status: 404)
126
126
  end
127
127
 
128
- def local_links_manager_has_a_local_authority_without_homepage(authority_slug)
128
+ def stub_local_links_manager_has_a_local_authority_without_homepage(authority_slug)
129
129
  response = {
130
130
  "local_authorities" => [
131
131
  {
@@ -140,6 +140,18 @@ module GdsApi
140
140
  .with(query: { authority_slug: authority_slug })
141
141
  .to_return(body: response.to_json, status: 200)
142
142
  end
143
+
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
143
155
  end
144
156
  end
145
157
  end
@@ -3,7 +3,7 @@ module GdsApi
3
3
  module Mapit
4
4
  MAPIT_ENDPOINT = Plek.current.find('mapit')
5
5
 
6
- def mapit_has_a_postcode(postcode, coords)
6
+ def stub_mapit_has_a_postcode(postcode, coords)
7
7
  response = {
8
8
  "wgs84_lat" => coords.first,
9
9
  "wgs84_lon" => coords.last,
@@ -16,7 +16,7 @@ module GdsApi
16
16
  .to_return(body: response.to_json, status: 200)
17
17
  end
18
18
 
19
- def mapit_has_a_postcode_and_areas(postcode, coords, areas)
19
+ def stub_mapit_has_a_postcode_and_areas(postcode, coords, areas)
20
20
  response = {
21
21
  "wgs84_lat" => coords.first,
22
22
  "wgs84_lon" => coords.last,
@@ -42,35 +42,45 @@ module GdsApi
42
42
  .to_return(body: response.to_json, status: 200)
43
43
  end
44
44
 
45
- def mapit_does_not_have_a_postcode(postcode)
45
+ def stub_mapit_does_not_have_a_postcode(postcode)
46
46
  stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/" + postcode.tr(' ', '+') + ".json")
47
47
  .to_return(body: { "code" => 404, "error" => "No Postcode matches the given query." }.to_json, status: 404)
48
48
  end
49
49
 
50
- def mapit_does_not_have_a_bad_postcode(postcode)
50
+ def stub_mapit_does_not_have_a_bad_postcode(postcode)
51
51
  stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/" + postcode.tr(' ', '+') + ".json")
52
52
  .to_return(body: { "code" => 400, "error" => "Postcode '#{postcode}' is not valid." }.to_json, status: 400)
53
53
  end
54
54
 
55
- def mapit_has_areas(area_type, areas)
55
+ def stub_mapit_has_areas(area_type, areas)
56
56
  stub_request(:get, "#{MAPIT_ENDPOINT}/areas/" + area_type + ".json")
57
57
  .to_return(body: areas.to_json, status: 200)
58
58
  end
59
59
 
60
- def mapit_does_not_have_areas(area_type)
60
+ def stub_mapit_does_not_have_areas(area_type)
61
61
  stub_request(:get, "#{MAPIT_ENDPOINT}/areas/" + area_type + ".json")
62
62
  .to_return(body: [].to_json, status: 200)
63
63
  end
64
64
 
65
- def mapit_has_area_for_code(code_type, code, area)
65
+ def stub_mapit_has_area_for_code(code_type, code, area)
66
66
  stub_request(:get, "#{MAPIT_ENDPOINT}/code/#{code_type}/#{code}.json")
67
67
  .to_return(body: area.to_json, status: 200)
68
68
  end
69
69
 
70
- def mapit_does_not_have_area_for_code(code_type, code)
70
+ def stub_mapit_does_not_have_area_for_code(code_type, code)
71
71
  stub_request(:get, "#{MAPIT_ENDPOINT}/code/#{code_type}/#{code}.json")
72
72
  .to_return(body: { "code" => 404, "error" => "No areas were found that matched code #{code_type} = #{code}." }.to_json, status: 404)
73
73
  end
74
+
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
74
84
  end
75
85
  end
76
86
  end
@@ -10,7 +10,7 @@ module GdsApi
10
10
 
11
11
  WEBSITE_ROOT = Plek.new.website_root
12
12
 
13
- def organisations_api_has_organisations(organisation_slugs)
13
+ def stub_organisations_api_has_organisations(organisation_slugs)
14
14
  bodies = organisation_slugs.map { |slug| organisation_for_slug(slug) }
15
15
  organisations_api_has_organisations_with_bodies(bodies)
16
16
  end
@@ -20,7 +20,7 @@ module GdsApi
20
20
  #
21
21
  # This also sets up the individual endpoints for each slug
22
22
  # by calling organisations_api_has_organisation below
23
- def organisations_api_has_organisations_with_bodies(organisation_bodies)
23
+ def stub_organisations_api_has_organisations_with_bodies(organisation_bodies)
24
24
  # Stub API call to the endpoint for an individual organisation
25
25
  organisation_bodies.each do |body|
26
26
  slug = body["details"]["slug"]
@@ -65,13 +65,13 @@ module GdsApi
65
65
  end
66
66
  end
67
67
 
68
- def organisations_api_has_organisation(organisation_slug, details = nil)
68
+ def stub_organisations_api_has_organisation(organisation_slug, details = nil)
69
69
  details ||= organisation_for_slug(organisation_slug)
70
70
  stub_request(:get, "#{WEBSITE_ROOT}/api/organisations/#{organisation_slug}").
71
71
  to_return(status: 200, body: details.to_json)
72
72
  end
73
73
 
74
- def organisations_api_does_not_have_organisation(organisation_slug)
74
+ def stub_organisations_api_does_not_have_organisation(organisation_slug)
75
75
  stub_request(:get, "#{WEBSITE_ROOT}/api/organisations/#{organisation_slug}").to_return(status: 404)
76
76
  end
77
77
 
@@ -114,6 +114,12 @@ module GdsApi
114
114
  ],
115
115
  }
116
116
  end
117
+
118
+ # Aliases for DEPRECATED methods
119
+ alias_method :organisations_api_has_organisations, :stub_organisations_api_has_organisations
120
+ alias_method :organisations_api_has_organisations_with_bodies, :stub_organisations_api_has_organisations_with_bodies
121
+ alias_method :organisations_api_has_organisation, :stub_organisations_api_has_organisation
122
+ alias_method :organisations_api_does_not_have_organisation, :stub_organisations_api_does_not_have_organisation
117
123
  end
118
124
  end
119
125
  end
@@ -59,7 +59,7 @@ module GdsApi
59
59
  end
60
60
  end
61
61
 
62
- def publishing_api_isnt_available
62
+ def stub_publishing_api_isnt_available
63
63
  stub_request(:any, /#{PUBLISHING_API_ENDPOINT}\/.*/).to_return(status: 503)
64
64
  end
65
65
 
@@ -71,7 +71,7 @@ module GdsApi
71
71
  }
72
72
  end
73
73
 
74
- def publishing_api_has_path_reservation_for(path, publishing_app)
74
+ def stub_publishing_api_has_path_reservation_for(path, publishing_app)
75
75
  data = publishing_api_path_data_for(path, "publishing_app" => publishing_app)
76
76
  error_data = data.merge("errors" => { "path" => ["is already reserved by the #{publishing_app} application"] })
77
77
 
@@ -86,7 +86,7 @@ module GdsApi
86
86
  body: data.to_json)
87
87
  end
88
88
 
89
- def publishing_api_returns_path_reservation_validation_error_for(path, error_details = nil)
89
+ def stub_publishing_api_returns_path_reservation_validation_error_for(path, error_details = nil)
90
90
  error_details ||= { "base" => ["computer says no"] }
91
91
  error_data = publishing_api_path_data_for(path).merge("errors" => error_details)
92
92
 
@@ -94,6 +94,11 @@ module GdsApi
94
94
  to_return(status: 422, body: error_data.to_json, headers: { content_type: "application/json" })
95
95
  end
96
96
 
97
+ # Aliases for DEPRECATED methods
98
+ alias_method :publishing_api_isnt_available, :stub_publishing_api_isnt_available
99
+ alias_method :publishing_api_has_path_reservation_for, :stub_publishing_api_has_path_reservation_for
100
+ alias_method :publishing_api_returns_path_reservation_validation_error_for, :stub_publishing_api_returns_path_reservation_validation_error_for
101
+
97
102
  private
98
103
 
99
104
  def values_match_recursively(expected_value, actual_value)
@@ -165,7 +165,7 @@ module GdsApi
165
165
  end
166
166
 
167
167
  # Stub any version 2 request to the publishing API to return a 503 response
168
- def publishing_api_isnt_available
168
+ def stub_publishing_api_isnt_available
169
169
  stub_request(:any, /#{PUBLISHING_API_V2_ENDPOINT}\/.*/).to_return(status: 503)
170
170
  stub_request(:any, /#{PUBLISHING_API_ENDPOINT}\/.*/).to_return(status: 503)
171
171
  end
@@ -280,7 +280,7 @@ module GdsApi
280
280
  #
281
281
  # @example
282
282
  #
283
- # publishing_api_has_content(
283
+ # stub_publishing_api_has_content(
284
284
  # vehicle_recalls_and_faults, # this is a variable containing an array of content items
285
285
  # document_type: described_class.publishing_api_document_type, #example of a document_type: "vehicle_recalls_and_faults_alert"
286
286
  # fields: fields, #example: let(:fields) { %i[base_path content_id public_updated_at title publication_state] }
@@ -289,7 +289,7 @@ module GdsApi
289
289
  # )
290
290
  # @param items [Array]
291
291
  # @param params [Hash]
292
- def publishing_api_has_content(items, params = {})
292
+ def stub_publishing_api_has_content(items, params = {})
293
293
  url = PUBLISHING_API_V2_ENDPOINT + "/content"
294
294
 
295
295
  if params.respond_to? :fetch
@@ -324,7 +324,7 @@ module GdsApi
324
324
 
325
325
  # This method has been refactored into publishing_api_has_content (above)
326
326
  # publishing_api_has_content allows for flexible passing in of arguments, please use instead
327
- def publishing_api_has_fields_for_document(document_type, items, fields)
327
+ def stub_publishing_api_has_fields_for_document(document_type, items, fields)
328
328
  body = Array(items).map { |item|
329
329
  deep_stringify_keys(item).slice(*fields)
330
330
  }
@@ -341,7 +341,7 @@ module GdsApi
341
341
  # Stub GET /v2/linkables to return a set of content items with a specific document type
342
342
  #
343
343
  # @param linkables [Array]
344
- def publishing_api_has_linkables(linkables, document_type:)
344
+ def stub_publishing_api_has_linkables(linkables, document_type:)
345
345
  url = PUBLISHING_API_V2_ENDPOINT + "/linkables?document_type=#{document_type}"
346
346
  stub_request(:get, url).to_return(status: 200, body: linkables.to_json, headers: {})
347
347
  end
@@ -349,7 +349,7 @@ module GdsApi
349
349
  # Stub GET /v2/content/:content_id to return a specific content item hash
350
350
  #
351
351
  # @param item [Hash]
352
- def publishing_api_has_item(item, params = {})
352
+ def stub_publishing_api_has_item(item, params = {})
353
353
  item = deep_transform_keys(item, &:to_sym)
354
354
  url = PUBLISHING_API_V2_ENDPOINT + "/content/" + item[:content_id]
355
355
  stub_request(:get, url)
@@ -360,7 +360,7 @@ module GdsApi
360
360
  # Stub GET /v2/content/:content_id to progress through a series of responses.
361
361
  #
362
362
  # @param items [Array]
363
- def publishing_api_has_item_in_sequence(content_id, items)
363
+ def stub_publishing_api_has_item_in_sequence(content_id, items)
364
364
  items = items.each { |item| deep_transform_keys(item, &:to_sym) }
365
365
  url = PUBLISHING_API_V2_ENDPOINT + "/content/" + content_id
366
366
  calls = -1
@@ -376,7 +376,7 @@ module GdsApi
376
376
  # Stub GET /v2/content/:content_id to return a 404 response
377
377
  #
378
378
  # @param content_id [UUID]
379
- def publishing_api_does_not_have_item(content_id)
379
+ def stub_publishing_api_does_not_have_item(content_id)
380
380
  url = PUBLISHING_API_V2_ENDPOINT + "/content/" + content_id
381
381
  stub_request(:get, url).to_return(status: 404, body: resource_not_found(content_id, "content item").to_json, headers: {})
382
382
  end
@@ -387,7 +387,7 @@ module GdsApi
387
387
  #
388
388
  # @example
389
389
  #
390
- # publishing_api_has_links(
390
+ # stub_publishing_api_has_links(
391
391
  # {
392
392
  # "content_id" => "64aadc14-9bca-40d9-abb6-4f21f9792a05",
393
393
  # "links" => {
@@ -411,7 +411,7 @@ module GdsApi
411
411
  # },
412
412
  # "version" => 6
413
413
  # }
414
- def publishing_api_has_links(links)
414
+ def stub_publishing_api_has_links(links)
415
415
  links = deep_transform_keys(links, &:to_sym)
416
416
  url = PUBLISHING_API_V2_ENDPOINT + "/links/" + links[:content_id]
417
417
  stub_request(:get, url).to_return(status: 200, body: links.to_json, headers: {})
@@ -422,7 +422,7 @@ module GdsApi
422
422
  # @param [Hash] links the structure of the links hash
423
423
  #
424
424
  # @example
425
- # publishing_api_has_expanded_links(
425
+ # stub_publishing_api_has_expanded_links(
426
426
  # {
427
427
  # "content_id" => "64aadc14-9bca-40d9-abb4-4f21f9792a05",
428
428
  # "expanded_links" => {
@@ -471,7 +471,7 @@ module GdsApi
471
471
  # ]
472
472
  # }
473
473
  # }
474
- def publishing_api_has_expanded_links(links, with_drafts: true, generate: false)
474
+ def stub_publishing_api_has_expanded_links(links, with_drafts: true, generate: false)
475
475
  links = deep_transform_keys(links, &:to_sym)
476
476
  request_params = {}
477
477
  request_params['with_drafts'] = false if !with_drafts
@@ -488,7 +488,7 @@ module GdsApi
488
488
  # @param [Hash] links the links for each content id
489
489
  #
490
490
  # @example
491
- # publishing_api_has_links_for_content_ids(
491
+ # stub_publishing_api_has_links_for_content_ids(
492
492
  # { "2878337b-bed9-4e7f-85b6-10ed2cbcd504" => {
493
493
  # "links" => { "taxons" => ["eb6965c7-3056-45d0-ae50-2f0a5e2e0854"] }
494
494
  # },
@@ -507,7 +507,7 @@ module GdsApi
507
507
  # ]
508
508
  # }
509
509
  # }
510
- def publishing_api_has_links_for_content_ids(links)
510
+ def stub_publishing_api_has_links_for_content_ids(links)
511
511
  url = PUBLISHING_API_V2_ENDPOINT + "/links/by-content-id"
512
512
  stub_request(:post, url).with(body: { content_ids: links.keys }).to_return(status: 200, body: links.to_json, headers: {})
513
513
  end
@@ -515,7 +515,7 @@ module GdsApi
515
515
  # Stub GET /v2/links/:content_id to return a 404 response
516
516
  #
517
517
  # @param content_id [UUID]
518
- def publishing_api_does_not_have_links(content_id)
518
+ def stub_publishing_api_does_not_have_links(content_id)
519
519
  url = PUBLISHING_API_V2_ENDPOINT + "/links/" + content_id
520
520
  stub_request(:get, url).to_return(status: 404, body: resource_not_found(content_id, "link set").to_json, headers: {})
521
521
  end
@@ -526,12 +526,12 @@ module GdsApi
526
526
  #
527
527
  # @example
528
528
  #
529
- # publishing_api_has_lookups({
529
+ # stub_publishing_api_has_lookups({
530
530
  # "/foo" => "51ac4247-fd92-470a-a207-6b852a97f2db",
531
531
  # "/bar" => "261bd281-f16c-48d5-82d2-9544019ad9ca"
532
532
  # })
533
533
  #
534
- def publishing_api_has_lookups(lookup_hash)
534
+ def stub_publishing_api_has_lookups(lookup_hash)
535
535
  url = Plek.current.find('publishing-api') + '/lookup-by-base-path'
536
536
  stub_request(:post, url).to_return(body: lookup_hash.to_json)
537
537
  end
@@ -544,7 +544,7 @@ module GdsApi
544
544
  #
545
545
  # @example
546
546
  #
547
- # publishing_api_has_linked_items(
547
+ # stub_publishing_api_has_linked_items(
548
548
  # [ item_1, item_2 ],
549
549
  # {
550
550
  # content_id: "51ac4247-fd92-470a-a207-6b852a97f2db",
@@ -553,7 +553,7 @@ module GdsApi
553
553
  # }
554
554
  # )
555
555
  #
556
- def publishing_api_has_linked_items(items, params = {})
556
+ def stub_publishing_api_has_linked_items(items, params = {})
557
557
  content_id = params.fetch(:content_id)
558
558
  link_type = params.fetch(:link_type)
559
559
  fields = params.fetch(:fields, %w(base_path content_id document_type title))
@@ -577,14 +577,14 @@ module GdsApi
577
577
  #
578
578
  # @example
579
579
  #
580
- # publishing_api_get_editions(
580
+ # stub_publishing_api_get_editions(
581
581
  # vehicle_recalls_and_faults, # this is a variable containing an array of editions
582
582
  # fields: fields, #example: let(:fields) { %i[base_path content_id public_updated_at title publication_state] }
583
583
  # per_page: 50
584
584
  # )
585
585
  # @param items [Array]
586
586
  # @param params [Hash]
587
- def publishing_api_get_editions(editions, params = {})
587
+ def stub_publishing_api_get_editions(editions, params = {})
588
588
  url = PUBLISHING_API_V2_ENDPOINT + "/editions"
589
589
 
590
590
  results = editions.map do |edition|
@@ -607,6 +607,22 @@ module GdsApi
607
607
  .to_return(status: 200, body: body.to_json, headers: {})
608
608
  end
609
609
 
610
+ # Aliases for DEPRECATED methods
611
+ alias_method :publishing_api_isnt_available, :stub_publishing_api_isnt_available
612
+ alias_method :pubishing_api_has_content, :stub_publishing_api_has_content
613
+ alias_method :pubishing_api_has_fields_for_document, :stub_publishing_api_has_fields_for_document
614
+ alias_method :pubishing_api_has_linkables, :stub_publishing_api_has_linkables
615
+ alias_method :pubishing_api_has_item, :stub_publishing_api_has_item
616
+ alias_method :pubishing_api_has_item_in_sequence, :stub_publishing_api_has_item_in_sequence
617
+ alias_method :pubishing_api_does_not_have_item, :stub_publishing_api_does_not_have_item
618
+ alias_method :pubishing_api_has_links, :stub_publishing_api_has_links
619
+ alias_method :pubishing_api_has_expanded_links, :stub_publishing_api_has_expanded_links
620
+ alias_method :pubishing_api_has_links_for_content_ids, :stub_publishing_api_has_links_for_content_ids
621
+ alias_method :pubishing_api_does_not_have_links, :stub_publishing_api_does_not_have_links
622
+ alias_method :pubishing_api_has_lookups, :stub_publishing_api_has_lookups
623
+ alias_method :pubishing_api_has_linked_items, :stub_publishing_api_has_linked_items
624
+ alias_method :pubishing_api_get_editions, :stub_publishing_api_get_editions
625
+
610
626
  private
611
627
 
612
628
  def stub_publishing_api_put(*args)
@@ -83,27 +83,27 @@ module GdsApi
83
83
  )
84
84
  end
85
85
 
86
- def rummager_has_services_and_info_data_for_organisation
86
+ def stub_rummager_has_services_and_info_data_for_organisation
87
87
  stub_request_for(search_results_found)
88
88
  run_example_query
89
89
  end
90
90
 
91
- def rummager_has_no_services_and_info_data_for_organisation
91
+ def stub_rummager_has_no_services_and_info_data_for_organisation
92
92
  stub_request_for(no_search_results_found)
93
93
  run_example_query
94
94
  end
95
95
 
96
- def rummager_has_specialist_sector_organisations(_sub_sector)
96
+ def stub_rummager_has_specialist_sector_organisations(_sub_sector)
97
97
  stub_request_for(sub_sector_organisations_results)
98
98
  run_example_query
99
99
  end
100
100
 
101
- def rummager_has_no_policies_for_any_type
101
+ def stub_rummager_has_no_policies_for_any_type
102
102
  stub_request(:get, %r{/search.json})
103
103
  .to_return(body: no_search_results_found)
104
104
  end
105
105
 
106
- def rummager_has_policies_for_every_type(options = {})
106
+ def stub_rummager_has_policies_for_every_type(options = {})
107
107
  if options[:count]
108
108
  stub_request(:get, %r{/search.json.*count=#{options[:count]}.*})
109
109
  .to_return(body: first_n_results(new_policies_results, n: options[:count]))
@@ -113,6 +113,13 @@ module GdsApi
113
113
  end
114
114
  end
115
115
 
116
+ # Aliases for DEPRECATED methods
117
+ alias_method :rummager_has_services_and_info_data_for_organisation, :stub_rummager_has_services_and_info_data_for_organisation
118
+ alias_method :rummager_has_no_services_and_info_data_for_organisation, :stub_rummager_has_no_services_and_info_data_for_organisation
119
+ alias_method :rummager_has_specialist_sector_organisations, :stub_rummager_has_specialist_sector_organisations
120
+ alias_method :rummager_has_no_policies_for_any_type, :stub_rummager_has_no_policies_for_any_type
121
+ alias_method :rummager_has_policies_for_every_type, :stub_rummager_has_policies_for_every_type
122
+
116
123
  private
117
124
 
118
125
  def stub_request_for(result_set)
@@ -15,9 +15,12 @@ module GdsApi
15
15
  post_stub.to_return(status: 201)
16
16
  end
17
17
 
18
- def support_isnt_available
18
+ def stub_support_isnt_available
19
19
  stub_request(:post, /#{SUPPORT_ENDPOINT}\/.*/).to_return(status: 503)
20
20
  end
21
+
22
+ # Aliases for DEPRECATED methods
23
+ alias_method :support_isnt_available, :stub_support_isnt_available
21
24
  end
22
25
  end
23
26
  end
@@ -68,7 +68,7 @@ module GdsApi
68
68
  post_stub.to_return(status: 200, body: response_body.to_json)
69
69
  end
70
70
 
71
- def support_api_isnt_available
71
+ def stub_support_api_isnt_available
72
72
  stub_request(:post, /#{SUPPORT_API_ENDPOINT}\/.*/).to_return(status: 503)
73
73
  end
74
74
 
@@ -147,6 +147,9 @@ module GdsApi
147
147
  def stub_any_support_api_call
148
148
  stub_request(:any, %r{\A#{SUPPORT_API_ENDPOINT}})
149
149
  end
150
+
151
+ # Aliases for DEPRECATED methods
152
+ alias_method :support_api_isnt_available, :stub_support_api_isnt_available
150
153
  end
151
154
  end
152
155
  end
@@ -12,9 +12,9 @@ module GdsApi
12
12
  # The stubs are setup to paginate in chunks of 20
13
13
  #
14
14
  # This also sets up the individual endpoints for each slug
15
- # by calling worldwide_api_has_location below
16
- def worldwide_api_has_locations(location_slugs)
17
- location_slugs.each { |s| worldwide_api_has_location(s) }
15
+ # by calling stub_worldwide_api_has_location below
16
+ def stub_worldwide_api_has_locations(location_slugs)
17
+ location_slugs.each { |s| stub_worldwide_api_has_location(s) }
18
18
  pages = []
19
19
  location_slugs.each_slice(20) do |slugs|
20
20
  pages << slugs.map { |s| world_location_details_for_slug(s) }
@@ -48,8 +48,8 @@ module GdsApi
48
48
  end
49
49
  end
50
50
 
51
- def worldwide_api_has_selection_of_locations
52
- worldwide_api_has_locations %w(
51
+ def stub_worldwide_api_has_selection_of_locations
52
+ stub_worldwide_api_has_locations %w(
53
53
  afghanistan angola australia bahamas belarus brazil brunei cambodia chad
54
54
  croatia denmark eritrea france ghana iceland japan laos luxembourg malta
55
55
  micronesia mozambique nicaragua panama portugal sao-tome-and-principe singapore
@@ -59,24 +59,24 @@ module GdsApi
59
59
  )
60
60
  end
61
61
 
62
- def worldwide_api_has_location(location_slug, details = nil)
62
+ def stub_worldwide_api_has_location(location_slug, details = nil)
63
63
  details ||= world_location_for_slug(location_slug)
64
64
  stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}").
65
65
  to_return(status: 200, body: details.to_json)
66
66
  end
67
67
 
68
- def worldwide_api_does_not_have_location(location_slug)
68
+ def stub_worldwide_api_does_not_have_location(location_slug)
69
69
  stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}").to_return(status: 404)
70
70
  end
71
71
 
72
- def worldwide_api_has_organisations_for_location(location_slug, json_or_hash)
72
+ def stub_worldwide_api_has_organisations_for_location(location_slug, json_or_hash)
73
73
  json = json_or_hash.is_a?(Hash) ? json_or_hash.to_json : json_or_hash
74
74
  url = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}/organisations"
75
75
  stub_request(:get, url).
76
76
  to_return(status: 200, body: json, headers: { "Link" => "<#{url}; rel\"self\"" })
77
77
  end
78
78
 
79
- def worldwide_api_has_no_organisations_for_location(location_slug)
79
+ def stub_worldwide_api_has_no_organisations_for_location(location_slug)
80
80
  details = { "results" => [], "total" => 0, "_response_info" => { "status" => "ok" } }
81
81
  url = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}/organisations"
82
82
  stub_request(:get, url).
@@ -108,6 +108,14 @@ module GdsApi
108
108
  },
109
109
  }
110
110
  end
111
+
112
+ # Aliases for DEPRECATED methods
113
+ alias_method :worldwide_api_has_locations, :stub_worldwide_api_has_locations
114
+ alias_method :worldwide_api_has_selection_of_locations, :stub_worldwide_api_has_selection_of_locations
115
+ alias_method :worldwide_api_has_location, :stub_worldwide_api_has_location
116
+ alias_method :worldwide_api_has_does_not_have_location, :stub_worldwide_api_does_not_have_location
117
+ alias_method :worldwide_api_has_organisations_for_location, :stub_worldwide_api_has_organisations_for_location
118
+ alias_method :worldwide_api_has_no_organisations_for_location, :stub_worldwide_api_has_no_organisations_for_location
111
119
  end
112
120
  end
113
121
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '57.1.0'.freeze
2
+ VERSION = '57.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: 57.1.0
4
+ version: 57.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-01-22 00:00:00.000000000 Z
11
+ date: 2019-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable