gds-api-adapters 63.6.0 → 67.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -1
  3. data/Rakefile +3 -4
  4. data/lib/gds_api.rb +2 -14
  5. data/lib/gds_api/asset_manager.rb +1 -1
  6. data/lib/gds_api/base.rb +8 -3
  7. data/lib/gds_api/email_alert_api.rb +12 -13
  8. data/lib/gds_api/imminence.rb +3 -3
  9. data/lib/gds_api/json_client.rb +6 -6
  10. data/lib/gds_api/list_response.rb +6 -6
  11. data/lib/gds_api/performance_platform/data_out.rb +21 -21
  12. data/lib/gds_api/publishing_api.rb +2 -2
  13. data/lib/gds_api/publishing_api/special_route_publisher.rb +1 -1
  14. data/lib/gds_api/response.rb +80 -6
  15. data/lib/gds_api/test_helpers/asset_manager.rb +0 -17
  16. data/lib/gds_api/test_helpers/calendars.rb +0 -9
  17. data/lib/gds_api/test_helpers/content_store.rb +0 -9
  18. data/lib/gds_api/test_helpers/email_alert_api.rb +28 -39
  19. data/lib/gds_api/test_helpers/imminence.rb +11 -14
  20. data/lib/gds_api/test_helpers/licence_application.rb +8 -16
  21. data/lib/gds_api/test_helpers/link_checker_api.rb +0 -8
  22. data/lib/gds_api/test_helpers/local_links_manager.rb +0 -13
  23. data/lib/gds_api/test_helpers/mapit.rb +15 -26
  24. data/lib/gds_api/test_helpers/organisations.rb +13 -18
  25. data/lib/gds_api/test_helpers/performance_platform/data_out.rb +34 -34
  26. data/lib/gds_api/test_helpers/publishing_api.rb +32 -51
  27. data/lib/gds_api/test_helpers/support.rb +0 -5
  28. data/lib/gds_api/test_helpers/support_api.rb +16 -20
  29. data/lib/gds_api/test_helpers/worldwide.rb +51 -31
  30. data/lib/gds_api/version.rb +1 -1
  31. metadata +14 -31
  32. data/lib/gds_api/publishing_api_v2.rb +0 -14
  33. data/lib/gds_api/test_helpers/alias_deprecated.rb +0 -13
  34. data/lib/gds_api/test_helpers/publishing_api_v2.rb +0 -13
@@ -5,13 +5,13 @@ module GdsApi
5
5
  PP_DATA_OUT_ENDPOINT = "https://www.performance.service.gov.uk".freeze
6
6
 
7
7
  def stub_service_feedback(slug, response_body = {})
8
- stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction").
9
- to_return(status: 200, body: response_body.to_json)
8
+ stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction")
9
+ .to_return(status: 200, body: response_body.to_json)
10
10
  end
11
11
 
12
12
  def stub_data_set_not_available(slug)
13
- stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction").
14
- to_return(status: 404)
13
+ stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction")
14
+ .to_return(status: 404)
15
15
  end
16
16
 
17
17
  def stub_service_not_available
@@ -20,51 +20,51 @@ module GdsApi
20
20
 
21
21
  def stub_search_terms(slug, response_body = {})
22
22
  options = {
23
- slug: slug,
24
- transaction: "search-terms",
25
- group_by: "searchKeyword",
26
- collect: "searchUniques:sum",
23
+ slug: slug,
24
+ transaction: "search-terms",
25
+ group_by: "searchKeyword",
26
+ collect: "searchUniques:sum",
27
27
  }
28
28
  stub_statistics(options, false, response_body)
29
29
  end
30
30
 
31
31
  def stub_searches(slug, is_multipart, response_body = {})
32
32
  options = {
33
- slug: slug,
34
- transaction: "search-terms",
35
- group_by: "pagePath",
36
- collect: "searchUniques:sum",
33
+ slug: slug,
34
+ transaction: "search-terms",
35
+ group_by: "pagePath",
36
+ collect: "searchUniques:sum",
37
37
  }
38
38
  stub_statistics(options, is_multipart, response_body)
39
39
  end
40
40
 
41
41
  def stub_page_views(slug, is_multipart, response_body = {})
42
42
  options = {
43
- slug: slug,
44
- transaction: "page-statistics",
45
- group_by: "pagePath",
46
- collect: "uniquePageviews:sum",
43
+ slug: slug,
44
+ transaction: "page-statistics",
45
+ group_by: "pagePath",
46
+ collect: "uniquePageviews:sum",
47
47
  }
48
48
  stub_statistics(options, is_multipart, response_body)
49
49
  end
50
50
 
51
51
  def stub_problem_reports(slug, is_multipart, response_body = {})
52
52
  options = {
53
- slug: slug,
54
- transaction: "page-contacts",
55
- group_by: "pagePath",
56
- collect: "total:sum",
53
+ slug: slug,
54
+ transaction: "page-contacts",
55
+ group_by: "pagePath",
56
+ collect: "total:sum",
57
57
  }
58
58
  stub_statistics(options, is_multipart, response_body)
59
59
  end
60
60
 
61
61
  def stub_statistics(options, is_multipart, response_body = {})
62
62
  params = {
63
- group_by: options[:group_by],
64
- collect: options[:collect],
65
- duration: 42,
66
- period: "day",
67
- end_at: Date.today.to_time.getutc.iso8601,
63
+ group_by: options[:group_by],
64
+ collect: options[:collect],
65
+ duration: 42,
66
+ period: "day",
67
+ end_at: Date.today.to_time.getutc.iso8601,
68
68
  }
69
69
 
70
70
  filter_param = is_multipart ? :filter_by_prefix : :filter_by
@@ -76,21 +76,21 @@ module GdsApi
76
76
  end
77
77
 
78
78
  def stub_search_404(slug)
79
- stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/search-terms").
80
- with(query: hash_including(filter_by: slug)).
81
- to_return(status: 404, headers: { content_type: "application/json" })
79
+ stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/search-terms")
80
+ .with(query: hash_including(filter_by: slug))
81
+ .to_return(status: 404, headers: { content_type: "application/json" })
82
82
  end
83
83
 
84
84
  def stub_page_views_404(slug)
85
- stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-statistics").
86
- with(query: hash_including(filter_by: slug)).
87
- to_return(status: 404, headers: { content_type: "application/json" })
85
+ stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-statistics")
86
+ .with(query: hash_including(filter_by: slug))
87
+ .to_return(status: 404, headers: { content_type: "application/json" })
88
88
  end
89
89
 
90
90
  def stub_problem_reports_404(slug)
91
- stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-contacts").
92
- with(query: hash_including(filter_by: slug)).
93
- to_return(status: 404, headers: { content_type: "application/json" })
91
+ stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-contacts")
92
+ .with(query: hash_including(filter_by: slug))
93
+ .to_return(status: 404, headers: { content_type: "application/json" })
94
94
  end
95
95
  end
96
96
  end
@@ -1,4 +1,3 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
1
  require "gds_api/test_helpers/json_client_helper"
3
2
  require "gds_api/test_helpers/content_item_helpers"
4
3
  require "json"
@@ -7,7 +6,6 @@ module GdsApi
7
6
  module TestHelpers
8
7
  # @api documented
9
8
  module PublishingApi
10
- extend AliasDeprecated
11
9
  include ContentItemHelpers
12
10
 
13
11
  PUBLISHING_API_V2_ENDPOINT = Plek.current.find("publishing-api") + "/v2"
@@ -281,16 +279,16 @@ module GdsApi
281
279
 
282
280
  # Get a request matcher that checks if a JSON request includes a set of attributes
283
281
  def request_json_includes(required_attributes)
284
- ->(request) do
282
+ lambda do |request|
285
283
  data = JSON.parse(request.body)
286
- deep_stringify_keys(required_attributes).
287
- to_a.all? { |key, value| data[key] == value }
284
+ deep_stringify_keys(required_attributes)
285
+ .to_a.all? { |key, value| data[key] == value }
288
286
  end
289
287
  end
290
288
 
291
289
  # Get a request matcher that checks if a JSON request matches a hash
292
290
  def request_json_matches(required_attributes)
293
- ->(request) do
291
+ lambda do |request|
294
292
  data = JSON.parse(request.body)
295
293
  deep_stringify_keys(required_attributes) == data
296
294
  end
@@ -345,13 +343,13 @@ module GdsApi
345
343
  # This method has been refactored into publishing_api_has_content (above)
346
344
  # publishing_api_has_content allows for flexible passing in of arguments, please use instead
347
345
  def stub_publishing_api_has_fields_for_document(document_type, items, fields)
348
- body = Array(items).map { |item|
346
+ body = Array(items).map do |item|
349
347
  deep_stringify_keys(item).slice(*fields)
350
- }
348
+ end
351
349
 
352
- query_params = fields.map { |f|
350
+ query_params = fields.map do |f|
353
351
  "&fields%5B%5D=#{f}"
354
- }
352
+ end
355
353
 
356
354
  url = PUBLISHING_API_V2_ENDPOINT + "/content?document_type=#{document_type}#{query_params.join('')}"
357
355
 
@@ -396,9 +394,11 @@ module GdsApi
396
394
  # Stub GET /v2/content/:content_id to return a 404 response
397
395
  #
398
396
  # @param content_id [UUID]
399
- def stub_publishing_api_does_not_have_item(content_id)
397
+ def stub_publishing_api_does_not_have_item(content_id, params = {})
400
398
  url = PUBLISHING_API_V2_ENDPOINT + "/content/" + content_id
401
- stub_request(:get, url).to_return(status: 404, body: resource_not_found(content_id, "content item").to_json, headers: {})
399
+ stub_request(:get, url)
400
+ .with(query: hash_including(params))
401
+ .to_return(status: 404, body: resource_not_found(content_id, "content item").to_json, headers: {})
402
402
  end
403
403
 
404
404
  # Stub a request to links endpoint
@@ -494,7 +494,7 @@ module GdsApi
494
494
  def stub_publishing_api_has_expanded_links(links, with_drafts: true, generate: false)
495
495
  links = deep_transform_keys(links, &:to_sym)
496
496
  request_params = {}
497
- request_params["with_drafts"] = false if !with_drafts
497
+ request_params["with_drafts"] = false unless with_drafts
498
498
  request_params["generate"] = true if generate
499
499
 
500
500
  url = PUBLISHING_API_V2_ENDPOINT + "/expanded-links/" + links[:content_id]
@@ -576,7 +576,7 @@ module GdsApi
576
576
  def stub_publishing_api_has_linked_items(items, params = {})
577
577
  content_id = params.fetch(:content_id)
578
578
  link_type = params.fetch(:link_type)
579
- fields = params.fetch(:fields, %w(base_path content_id document_type title))
579
+ fields = params.fetch(:fields, %w[base_path content_id document_type title])
580
580
 
581
581
  url = PUBLISHING_API_V2_ENDPOINT + "/linked/#{content_id}"
582
582
 
@@ -698,14 +698,14 @@ module GdsApi
698
698
  end
699
699
 
700
700
  def request_json_matching(required_attributes)
701
- ->(request) do
701
+ lambda do |request|
702
702
  data = JSON.parse(request.body)
703
703
  required_attributes.to_a.all? { |key, value| data[key.to_s] == value }
704
704
  end
705
705
  end
706
706
 
707
707
  def request_json_including(required_attributes)
708
- ->(request) do
708
+ lambda do |request|
709
709
  data = JSON.parse(request.body)
710
710
  values_match_recursively(required_attributes, data)
711
711
  end
@@ -739,7 +739,7 @@ module GdsApi
739
739
  # @example
740
740
  # stub_any_publishing_api_path_reservation
741
741
  def stub_any_publishing_api_path_reservation
742
- stub_request(:put, %r[\A#{PUBLISHING_API_ENDPOINT}/paths/]).to_return do |request|
742
+ stub_request(:put, %r{\A#{PUBLISHING_API_ENDPOINT}/paths/}).to_return do |request|
743
743
  base_path = request.uri.path.sub(%r{\A/paths}, "")
744
744
  body = JSON.parse(request.body).merge(base_path: base_path)
745
745
  {
@@ -765,16 +765,16 @@ module GdsApi
765
765
  message: "Base path #{message}",
766
766
  fields: { base_path: [message] } }
767
767
 
768
- stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}").
769
- to_return(status: 422,
770
- headers: { content_type: "application/json" },
771
- body: { error: error }.to_json)
768
+ stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}")
769
+ .to_return(status: 422,
770
+ headers: { content_type: "application/json" },
771
+ body: { error: error }.to_json)
772
772
 
773
- stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}").
774
- with(body: { "publishing_app" => publishing_app }).
775
- to_return(status: 200,
776
- headers: { content_type: "application/json" },
777
- body: { publishing_app: publishing_app, base_path: path }.to_json)
773
+ stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}")
774
+ .with(body: { "publishing_app" => publishing_app })
775
+ .to_return(status: 200,
776
+ headers: { content_type: "application/json" },
777
+ body: { publishing_app: publishing_app, base_path: path }.to_json)
778
778
  end
779
779
 
780
780
  # Stub a PUT /paths/:base_path request for a particular publishing
@@ -797,30 +797,11 @@ module GdsApi
797
797
 
798
798
  error = { code: 422, message: message, fields: error_fields }
799
799
 
800
- stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{base_path}").
801
- to_return(status: 422,
802
- headers: { content_type: "application/json" },
803
- body: { error: error }.to_json)
804
- end
805
-
806
- alias_deprecated :publishing_api_isnt_available, :stub_publishing_api_isnt_available
807
- alias_deprecated :publishing_api_has_content, :stub_publishing_api_has_content
808
- alias_deprecated :publishing_api_has_fields_for_document, :stub_publishing_api_has_fields_for_document
809
- alias_deprecated :publishing_api_has_linkables, :stub_publishing_api_has_linkables
810
- alias_deprecated :publishing_api_has_item, :stub_publishing_api_has_item
811
- alias_deprecated :publishing_api_has_item_in_sequence, :stub_publishing_api_has_item_in_sequence
812
- alias_deprecated :publishing_api_does_not_have_item, :stub_publishing_api_does_not_have_item
813
- alias_deprecated :publishing_api_has_links, :stub_publishing_api_has_links
814
- alias_deprecated :publishing_api_has_expanded_links, :stub_publishing_api_has_expanded_links
815
- alias_deprecated :publishing_api_has_links_for_content_ids, :stub_publishing_api_has_links_for_content_ids
816
- alias_deprecated :publishing_api_does_not_have_links, :stub_publishing_api_does_not_have_links
817
- alias_deprecated :publishing_api_has_lookups, :stub_publishing_api_has_lookups
818
- alias_deprecated :publishing_api_has_linked_items, :stub_publishing_api_has_linked_items
819
- alias_deprecated :publishing_api_get_editions, :stub_publishing_api_get_editions
820
- alias_deprecated :publishing_api_has_path_reservation_for, :stub_publishing_api_has_path_reservation_for
821
- alias_deprecated :publishing_api_returns_path_reservation_validation_error_for, :stub_publishing_api_returns_path_reservation_validation_error_for
822
- alias_deprecated :stub_default_publishing_api_path_reservation, :stub_any_publishing_api_path_reservation
823
- alias_deprecated :stub_default_publishing_api_put_intent, :stub_any_publishing_api_put_intent
800
+ stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{base_path}")
801
+ .to_return(status: 422,
802
+ headers: { content_type: "application/json" },
803
+ body: { error: error }.to_json)
804
+ end
824
805
 
825
806
  private
826
807
 
@@ -888,7 +869,7 @@ module GdsApi
888
869
  return false unless actual_value.is_a?(Hash)
889
870
 
890
871
  expected_value.all? do |expected_sub_key, expected_sub_value|
891
- actual_value.has_key?(expected_sub_key.to_s) &&
872
+ actual_value.key?(expected_sub_key.to_s) &&
892
873
  values_match_recursively(expected_sub_value, actual_value[expected_sub_key.to_s])
893
874
  end
894
875
  when Array
@@ -1,9 +1,6 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
-
3
1
  module GdsApi
4
2
  module TestHelpers
5
3
  module Support
6
- extend AliasDeprecated
7
4
  SUPPORT_ENDPOINT = Plek.current.find("support")
8
5
 
9
6
  def stub_support_foi_request_creation(request_details = nil)
@@ -21,8 +18,6 @@ module GdsApi
21
18
  def stub_support_isnt_available
22
19
  stub_request(:post, /#{SUPPORT_ENDPOINT}\/.*/).to_return(status: 503)
23
20
  end
24
-
25
- alias_deprecated :support_isnt_available, :stub_support_isnt_available
26
21
  end
27
22
  end
28
23
  end
@@ -1,11 +1,9 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
1
  require "cgi"
3
2
  require "plek"
4
3
 
5
4
  module GdsApi
6
5
  module TestHelpers
7
6
  module SupportApi
8
- extend AliasDeprecated
9
7
  SUPPORT_API_ENDPOINT = Plek.current.find("support-api")
10
8
 
11
9
  def stub_support_api_problem_report_creation(request_details = nil)
@@ -65,9 +63,9 @@ module GdsApi
65
63
  end
66
64
 
67
65
  def stub_support_api_problem_reports(params, response_body = {})
68
- stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/problem-reports").
69
- with(query: params).
70
- to_return(status: 200, body: response_body.to_json)
66
+ stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/problem-reports")
67
+ .with(query: params)
68
+ .to_return(status: 200, body: response_body.to_json)
71
69
  end
72
70
 
73
71
  def stub_support_api_mark_reviewed_for_spam(request_details = nil, response_body = {})
@@ -89,8 +87,8 @@ module GdsApi
89
87
  def stub_support_api_anonymous_feedback_organisation_summary(slug, ordering = nil, response_body = {})
90
88
  uri = "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/organisations/#{slug}"
91
89
  uri << "?ordering=#{ordering}" if ordering
92
- stub_http_request(:get, uri).
93
- to_return(status: 200, body: response_body.to_json)
90
+ stub_http_request(:get, uri)
91
+ .to_return(status: 200, body: response_body.to_json)
94
92
  end
95
93
 
96
94
  def stub_support_api_organisations_list(response_body = nil)
@@ -111,8 +109,8 @@ module GdsApi
111
109
  },
112
110
  ]
113
111
 
114
- stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/organisations").
115
- to_return(status: 200, body: response_body.to_json)
112
+ stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/organisations")
113
+ .to_return(status: 200, body: response_body.to_json)
116
114
  end
117
115
 
118
116
  def stub_support_api_organisation(slug = "cabinet-office", response_body = nil)
@@ -124,22 +122,22 @@ module GdsApi
124
122
  govuk_status: "live",
125
123
  }
126
124
 
127
- stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/organisations/#{slug}").
128
- to_return(status: 200, body: response_body.to_json)
125
+ stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/organisations/#{slug}")
126
+ .to_return(status: 200, body: response_body.to_json)
129
127
  end
130
128
 
131
129
  def stub_support_api_document_type_list(response_body = nil)
132
- response_body ||= %w(case_study detailed_guide smart_answer)
130
+ response_body ||= %w[case_study detailed_guide smart_answer]
133
131
 
134
- stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/document-types").
135
- to_return(status: 200, body: response_body.to_json)
132
+ stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/document-types")
133
+ .to_return(status: 200, body: response_body.to_json)
136
134
  end
137
135
 
138
136
  def stub_support_api_anonymous_feedback_doc_type_summary(document_type, ordering = nil, response_body = nil)
139
137
  uri = "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/document-types/#{document_type}"
140
138
  uri << "?ordering=#{ordering}" if ordering
141
- stub_http_request(:get, uri).
142
- to_return(status: 200, body: response_body.to_json)
139
+ stub_http_request(:get, uri)
140
+ .to_return(status: 200, body: response_body.to_json)
143
141
  end
144
142
 
145
143
  def stub_support_api_feedback_export_request(id, response_body = nil)
@@ -148,15 +146,13 @@ module GdsApi
148
146
  ready: true,
149
147
  }
150
148
 
151
- stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/export-requests/#{id}").
152
- to_return(status: 200, body: response_body.to_json)
149
+ stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/export-requests/#{id}")
150
+ .to_return(status: 200, body: response_body.to_json)
153
151
  end
154
152
 
155
153
  def stub_any_support_api_call
156
154
  stub_request(:any, %r{\A#{SUPPORT_API_ENDPOINT}})
157
155
  end
158
-
159
- alias_deprecated :support_api_isnt_available, :stub_support_api_isnt_available
160
156
  end
161
157
  end
162
158
  end
@@ -1,11 +1,9 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
1
  require "gds_api/test_helpers/json_client_helper"
3
2
  require "gds_api/test_helpers/common_responses"
4
3
 
5
4
  module GdsApi
6
5
  module TestHelpers
7
6
  module Worldwide
8
- extend AliasDeprecated
9
7
  include GdsApi::TestHelpers::CommonResponses
10
8
 
11
9
  WORLDWIDE_API_ENDPOINT = Plek.new.website_root
@@ -23,12 +21,14 @@ module GdsApi
23
21
  end
24
22
 
25
23
  pages.each_with_index do |page, i|
26
- page_details = plural_response_base.merge("results" => page,
24
+ page_details = plural_response_base.merge(
25
+ "results" => page,
27
26
  "total" => location_slugs.size,
28
27
  "pages" => pages.size,
29
28
  "current_page" => i + 1,
30
29
  "page_size" => 20,
31
- "start_index" => i * 20 + 1)
30
+ "start_index" => i * 20 + 1,
31
+ )
32
32
 
33
33
  links = { self: "#{WORLDWIDE_API_ENDPOINT}/api/world-locations?page=#{i + 1}" }
34
34
  links[:next] = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations?page=#{i + 2}" if pages[i + 1]
@@ -40,32 +40,59 @@ module GdsApi
40
40
  link_headers << "<#{href}>; rel=\"#{rel}\""
41
41
  end
42
42
 
43
- stub_request(:get, links[:self]).
44
- to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
43
+ stub_request(:get, links[:self])
44
+ .to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
45
45
 
46
- if i.zero?
47
- # First page exists at URL with and without page param
48
- stub_request(:get, links[:self].sub(/\?page=1/, "")).
49
- to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
50
- end
46
+ next unless i.zero?
47
+
48
+ # First page exists at URL with and without page param
49
+ stub_request(:get, links[:self].sub(/\?page=1/, ""))
50
+ .to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
51
51
  end
52
52
  end
53
53
 
54
54
  def stub_worldwide_api_has_selection_of_locations
55
- stub_worldwide_api_has_locations %w(
56
- afghanistan angola australia bahamas belarus brazil brunei cambodia chad
57
- croatia denmark eritrea france ghana iceland japan laos luxembourg malta
58
- micronesia mozambique nicaragua panama portugal sao-tome-and-principe singapore
59
- south-korea sri-lanka uk-delegation-to-council-of-europe
55
+ stub_worldwide_api_has_locations %w[
56
+ afghanistan
57
+ angola
58
+ australia
59
+ bahamas
60
+ belarus
61
+ brazil
62
+ brunei
63
+ cambodia
64
+ chad
65
+ croatia
66
+ denmark
67
+ eritrea
68
+ france
69
+ ghana
70
+ iceland
71
+ japan
72
+ laos
73
+ luxembourg
74
+ malta
75
+ micronesia
76
+ mozambique
77
+ nicaragua
78
+ panama
79
+ portugal
80
+ sao-tome-and-principe
81
+ singapore
82
+ south-korea
83
+ sri-lanka
84
+ uk-delegation-to-council-of-europe
60
85
  uk-delegation-to-organization-for-security-and-co-operation-in-europe
61
- united-kingdom venezuela vietnam
62
- )
86
+ united-kingdom
87
+ venezuela
88
+ vietnam
89
+ ]
63
90
  end
64
91
 
65
92
  def stub_worldwide_api_has_location(location_slug, details = nil)
66
93
  details ||= world_location_for_slug(location_slug)
67
- stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}").
68
- to_return(status: 200, body: details.to_json)
94
+ stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}")
95
+ .to_return(status: 200, body: details.to_json)
69
96
  end
70
97
 
71
98
  def stub_worldwide_api_does_not_have_location(location_slug)
@@ -75,15 +102,15 @@ module GdsApi
75
102
  def stub_worldwide_api_has_organisations_for_location(location_slug, json_or_hash)
76
103
  json = json_or_hash.is_a?(Hash) ? json_or_hash.to_json : json_or_hash
77
104
  url = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}/organisations"
78
- stub_request(:get, url).
79
- to_return(status: 200, body: json, headers: { "Link" => "<#{url}; rel\"self\"" })
105
+ stub_request(:get, url)
106
+ .to_return(status: 200, body: json, headers: { "Link" => "<#{url}; rel\"self\"" })
80
107
  end
81
108
 
82
109
  def stub_worldwide_api_has_no_organisations_for_location(location_slug)
83
110
  details = { "results" => [], "total" => 0, "_response_info" => { "status" => "ok" } }
84
111
  url = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}/organisations"
85
- stub_request(:get, url).
86
- to_return(status: 200, body: details.to_json, headers: { "Link" => "<#{url}; rel\"self\"" })
112
+ stub_request(:get, url)
113
+ .to_return(status: 200, body: details.to_json, headers: { "Link" => "<#{url}; rel\"self\"" })
87
114
  end
88
115
 
89
116
  def world_location_for_slug(slug)
@@ -112,13 +139,6 @@ module GdsApi
112
139
  "content_id" => "content_id_for_#{slug}",
113
140
  }
114
141
  end
115
-
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
122
142
  end
123
143
  end
124
144
  end