From 74047dd6ca5aa26884b371cc563bbb421c40a16b Mon Sep 17 00:00:00 2001 From: Murilo Dal Ri Date: Tue, 13 Feb 2024 11:59:20 +0000 Subject: [PATCH 1/6] Update minimum required Ruby version We're adding support for Ruby 3.3 and dropping support for 3.0. The new minimum required version will be 3.1.4. For more info: https://docs.publishing.service.gov.uk/manual/publishing-a-ruby-gem.html#ruby-version-compatibility --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index eca690e7..0aec50e6 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.0.5 +3.1.4 From d6d4ef585cda62a5dd03eb2d54f6a9f32d8fe341 Mon Sep 17 00:00:00 2001 From: Murilo Dal Ri Date: Tue, 13 Feb 2024 12:06:56 +0000 Subject: [PATCH 2/6] Update .gemspec file --- gds-api-adapters.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gds-api-adapters.gemspec b/gds-api-adapters.gemspec index 7a714b81..152285c6 100644 --- a/gds-api-adapters.gemspec +++ b/gds-api-adapters.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.homepage = "http://github.com/alphagov/gds-api-adapters" s.description = "A set of adapters providing easy access to the GDS GOV.UK APIs" - s.required_ruby_version = ">= 3.0" + s.required_ruby_version = ">= 3.1.4" s.files = Dir.glob("lib/**/*") + Dir.glob("test/fixtures/**/*") + %w[README.md Rakefile] s.require_path = "lib" s.add_dependency "addressable" From 87d50f629481c2c4f88d1db981dd41054822c05b Mon Sep 17 00:00:00 2001 From: Murilo Dal Ri Date: Tue, 13 Feb 2024 12:14:58 +0000 Subject: [PATCH 3/6] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e7a7c45..8780588a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: fail-fast: false matrix: # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' - ruby: ['3.0', 3.1, 3.2] + ruby: [3.1, 3.2, 3.3] runs-on: ubuntu-latest env: GOVUK_CONTENT_SCHEMAS_PATH: vendor/publishing-api/content_schemas From 82705f8cad975ea6c621dd04f00dd32321f1d7d3 Mon Sep 17 00:00:00 2001 From: Murilo Dal Ri Date: Tue, 13 Feb 2024 12:21:03 +0000 Subject: [PATCH 4/6] Remove comment about Ruby 3.0 --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8780588a..8fbe13af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,6 @@ jobs: strategy: fail-fast: false matrix: - # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' ruby: [3.1, 3.2, 3.3] runs-on: ubuntu-latest env: From eeb564547a36ad5ac4822a05e4bc9ce472241857 Mon Sep 17 00:00:00 2001 From: Murilo Dal Ri Date: Tue, 13 Feb 2024 12:31:48 +0000 Subject: [PATCH 5/6] Update CHANGELOG.md Updates the CHANGELOG.md file to include the following changes: Drop support for Ruby 3.0. --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc955c53..4ee54009 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Unreleased + +* Drop support for Ruby 3.0. The minimum required Ruby version is now 3.1.4. +* Add support for Ruby 3.3. + # 93.0.0 * BREAKING: removed Support app `create_foi_request` method. * Note: This is no longer used by any apps, so should not be breaking in practice. From 32e37a4c9663ad790e9cff3970b58b4c0ee34197 Mon Sep 17 00:00:00 2001 From: Callum Knights Date: Mon, 19 Feb 2024 16:01:53 +0000 Subject: [PATCH 6/6] Fix Linting errors --- lib/gds_api/account_api.rb | 16 +-- lib/gds_api/asset_manager.rb | 4 +- lib/gds_api/email_alert_api.rb | 34 +++--- lib/gds_api/imminence.rb | 6 +- lib/gds_api/json_client.rb | 4 +- lib/gds_api/link_checker_api.rb | 14 +-- lib/gds_api/publishing_api.rb | 20 ++-- .../publishing_api/special_route_publisher.rb | 6 +- lib/gds_api/router.rb | 4 +- lib/gds_api/test_helpers/account_api.rb | 46 ++++---- lib/gds_api/test_helpers/asset_manager.rb | 2 +- lib/gds_api/test_helpers/calendars.rb | 14 +-- lib/gds_api/test_helpers/content_store.rb | 6 +- lib/gds_api/test_helpers/email_alert_api.rb | 80 ++++++------- lib/gds_api/test_helpers/imminence.rb | 6 +- lib/gds_api/test_helpers/link_checker_api.rb | 48 ++++---- .../test_helpers/local_links_manager.rb | 26 ++--- lib/gds_api/test_helpers/publishing_api.rb | 34 +++--- lib/gds_api/test_helpers/router.rb | 12 +- lib/gds_api/test_helpers/support_api.rb | 2 +- test/email_alert_api_test.rb | 108 +++++++++--------- test/pacts/account_api_pact_test.rb | 44 +++---- test/pacts/organisations_api_pact_test.rb | 2 +- .../get_content_items_pact_test.rb | 12 +- .../unreserve_path_pact_test.rb | 4 +- .../special_route_publisher_test.rb | 4 +- test/response_test.rb | 8 +- test/support_api_test.rb | 4 +- test/test_helpers/email_alert_api_test.rb | 6 +- 29 files changed, 288 insertions(+), 288 deletions(-) diff --git a/lib/gds_api/account_api.rb b/lib/gds_api/account_api.rb index 837dcf57..ef6ff440 100644 --- a/lib/gds_api/account_api.rb +++ b/lib/gds_api/account_api.rb @@ -17,8 +17,8 @@ class GdsApi::AccountApi < GdsApi::Base def get_sign_in_url(redirect_path: nil, mfa: false) querystring = nested_query_string( { - redirect_path: redirect_path, - mfa: mfa, + redirect_path:, + mfa:, }.compact, ) get_json("#{endpoint}/api/oauth2/sign-in?#{querystring}") @@ -31,7 +31,7 @@ def get_sign_in_url(redirect_path: nil, mfa: false) # # @return [Hash] The value for the govuk_account_session header, the path to redirect the user to, and the GA client ID (if there is one) def validate_auth_response(code:, state:) - post_json("#{endpoint}/api/oauth2/callback", code: code, state: state) + post_json("#{endpoint}/api/oauth2/callback", code:, state:) end # Get an OIDC end-session URL to redirect the user to @@ -59,7 +59,7 @@ def get_user(govuk_account_session:) # # @return [Hash] One field, "match", indicating whether the session matches the given email address def match_user_by_email(email:, govuk_account_session: nil) - querystring = nested_query_string({ email: email }) + querystring = nested_query_string({ email: }) get_json("#{endpoint}/api/user/match-by-email?#{querystring}", auth_headers(govuk_account_session)) end @@ -79,8 +79,8 @@ def delete_user_by_subject_identifier(subject_identifier:) # @return [Hash] The user's subject identifier and email attributes def update_user_by_subject_identifier(subject_identifier:, email: nil, email_verified: nil) params = { - email: email, - email_verified: email_verified, + email:, + email_verified:, }.compact patch_json("#{endpoint}/api/oidc-users/#{subject_identifier}", params) @@ -93,7 +93,7 @@ def update_user_by_subject_identifier(subject_identifier:, email: nil, email_ver # # @return [Hash] The attribute values (if present), and a new session header def get_attributes(attributes:, govuk_account_session:) - querystring = nested_query_string({ attributes: attributes }.compact) + querystring = nested_query_string({ attributes: }.compact) get_json("#{endpoint}/api/attributes?#{querystring}", auth_headers(govuk_account_session)) end @@ -104,7 +104,7 @@ def get_attributes(attributes:, govuk_account_session:) # # @return [Hash] A new session header def set_attributes(attributes:, govuk_account_session:) - patch_json("#{endpoint}/api/attributes", { attributes: attributes }, auth_headers(govuk_account_session)) + patch_json("#{endpoint}/api/attributes", { attributes: }, auth_headers(govuk_account_session)) end private diff --git a/lib/gds_api/asset_manager.rb b/lib/gds_api/asset_manager.rb index 77fb6b4c..1dd2964a 100644 --- a/lib/gds_api/asset_manager.rb +++ b/lib/gds_api/asset_manager.rb @@ -45,7 +45,7 @@ class GdsApi::AssetManager < GdsApi::Base # response = asset_manager.create_asset(file: params[:file]) # response['content_type'] #=> "image/jpeg" def create_asset(asset) - post_multipart("#{base_url}/assets", asset: asset) + post_multipart("#{base_url}/assets", asset:) end # Updates an asset given a hash with one +file+ attribute @@ -76,7 +76,7 @@ def create_asset(asset) # uuid = '594602dd-75b3-4e6f-b5d1-cacf8c4d4164' # asset_manager.update_asset(uuid, file: File.new('image.jpg', 'r')) def update_asset(id, asset) - put_multipart("#{base_url}/assets/#{id}", asset: asset) + put_multipart("#{base_url}/assets/#{id}", asset:) end # Fetches an asset's metadata given the id diff --git a/lib/gds_api/email_alert_api.rb b/lib/gds_api/email_alert_api.rb index 1f626482..5d07ff9e 100644 --- a/lib/gds_api/email_alert_api.rb +++ b/lib/gds_api/email_alert_api.rb @@ -69,10 +69,10 @@ def unsubscribe_subscriber(id) def subscribe(subscriber_list_id:, address:, frequency: "immediately", skip_confirmation_email: false) post_json( "#{endpoint}/subscriptions", - subscriber_list_id: subscriber_list_id, - address: address, - frequency: frequency, - skip_confirmation_email: skip_confirmation_email, + subscriber_list_id:, + address:, + frequency:, + skip_confirmation_email:, ) end @@ -166,7 +166,7 @@ def get_subscriptions(id:, order: nil) def change_subscriber(id:, new_address:, on_conflict: nil) patch_json( "#{endpoint}/subscribers/#{uri_encode(id)}", - { new_address: new_address, on_conflict: on_conflict }.compact, + { new_address:, on_conflict: }.compact, ) end @@ -179,7 +179,7 @@ def change_subscriber(id:, new_address:, on_conflict: nil) def change_subscription(id:, frequency:) patch_json( "#{endpoint}/subscriptions/#{uri_encode(id)}", - frequency: frequency, + frequency:, ) end @@ -191,7 +191,7 @@ def change_subscription(id:, frequency:) def authenticate_subscriber_by_govuk_account(govuk_account_session:) post_json( "#{endpoint}/subscribers/govuk-account", - govuk_account_session: govuk_account_session, + govuk_account_session:, ) end @@ -206,7 +206,7 @@ def authenticate_subscriber_by_govuk_account(govuk_account_session:) def link_subscriber_to_govuk_account(govuk_account_session:) post_json( "#{endpoint}/subscribers/govuk-account/link", - govuk_account_session: govuk_account_session, + govuk_account_session:, ) end @@ -231,8 +231,8 @@ def find_subscriber_by_govuk_account(govuk_account_id:) def send_subscriber_verification_email(address:, destination:) post_json( "#{endpoint}/subscribers/auth-token", - address: address, - destination: destination, + address:, + destination:, ) end @@ -247,9 +247,9 @@ def send_subscriber_verification_email(address:, destination:) def send_subscription_verification_email(address:, frequency:, topic_id:) post_json( "#{endpoint}/subscriptions/auth-token", - address: address, - frequency: frequency, - topic_id: topic_id, + address:, + frequency:, + topic_id:, ) end @@ -264,8 +264,8 @@ def bulk_unsubscribe(slug:, govuk_request_id: nil, body: nil, sender_message_id: post_json( "#{endpoint}/subscriber-lists/#{slug}/bulk-unsubscribe", { - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, }.compact, { "Govuk-Request-Id" => govuk_request_id, @@ -281,8 +281,8 @@ def bulk_unsubscribe(slug:, govuk_request_id: nil, body: nil, sender_message_id: def bulk_migrate(from_slug:, to_slug:) post_json( "#{endpoint}/subscriber-lists/bulk-migrate", - from_slug: from_slug, - to_slug: to_slug, + from_slug:, + to_slug:, ) end diff --git a/lib/gds_api/imminence.rb b/lib/gds_api/imminence.rb index 70c9861a..5a437302 100644 --- a/lib/gds_api/imminence.rb +++ b/lib/gds_api/imminence.rb @@ -8,13 +8,13 @@ def api_url(type, params) end def places(type, lat, lon, limit = 5) - url = api_url(type, lat: lat, lng: lon, limit: limit) + url = api_url(type, lat:, lng: lon, limit:) get_json(url) end def places_for_postcode(type, postcode, limit = 5, local_authority_slug = nil) - options = { postcode: postcode, limit: limit } - options.merge!(local_authority_slug: local_authority_slug) if local_authority_slug + options = { postcode:, limit: } + options.merge!(local_authority_slug:) if local_authority_slug url = api_url(type, options) get_json(url) || [] end diff --git a/lib/gds_api/json_client.rb b/lib/gds_api/json_client.rb index bb87dffc..d24169df 100644 --- a/lib/gds_api/json_client.rb +++ b/lib/gds_api/json_client.rb @@ -162,8 +162,8 @@ def do_request(method, url, params = nil, additional_headers = {}) logger.debug start_logging.to_json method_params = { - method: method, - url: url, + method:, + url:, } method_params[:payload] = params diff --git a/lib/gds_api/link_checker_api.rb b/lib/gds_api/link_checker_api.rb index fc02d496..58173341 100644 --- a/lib/gds_api/link_checker_api.rb +++ b/lib/gds_api/link_checker_api.rb @@ -22,9 +22,9 @@ class GdsApi::LinkCheckerApi < GdsApi::Base # @raise [HTTPErrorResponse] if the request returns an error def check(uri, synchronous: nil, checked_within: nil) params = { - uri: uri, - synchronous: synchronous, - checked_within: checked_within, + uri:, + synchronous:, + checked_within:, } response = get_json( @@ -54,10 +54,10 @@ def check(uri, synchronous: nil, checked_within: nil) # @raise [HTTPErrorResponse] if the request returns an error def create_batch(uris, checked_within: nil, webhook_uri: nil, webhook_secret_token: nil) payload = { - uris: uris, - checked_within: checked_within, - webhook_uri: webhook_uri, - webhook_secret_token: webhook_secret_token, + uris:, + checked_within:, + webhook_uri:, + webhook_secret_token:, } response = post_json( diff --git a/lib/gds_api/publishing_api.rb b/lib/gds_api/publishing_api.rb index 49d3bc4c..5eabb574 100644 --- a/lib/gds_api/publishing_api.rb +++ b/lib/gds_api/publishing_api.rb @@ -48,7 +48,7 @@ def get_content(content_id, params = {}) # @raise [NoLiveVersion] when the content item is not found # @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2contentcontent_id def get_live_content(content_id, locale = "en") - content_item = get_content(content_id, locale: locale) + content_item = get_content(content_id, locale:) live_states = %w[published unpublished] return content_item if live_states.include?(content_item.to_h["publication_state"]) @@ -56,7 +56,7 @@ def get_live_content(content_id, locale = "en") live_version_number = content_item["state_history"].find { |_, v| live_states.include?(v) }&.first raise NoLiveVersion, "No live version exists for content_id: #{content_id}" unless live_version_number - get_content(content_id, locale: locale, version: live_version_number) + get_content(content_id, locale:, version: live_version_number) end # Find the content_ids for a list of base_paths. @@ -73,7 +73,7 @@ def get_live_content(content_id, locale = "en") # # @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-lookup-by-base-path def lookup_content_ids(base_paths:, exclude_document_types: nil, exclude_unpublishing_types: nil, with_drafts: false) - options = { base_paths: base_paths } + options = { base_paths: } options[:exclude_document_types] = exclude_document_types if exclude_document_types options[:exclude_unpublishing_types] = exclude_unpublishing_types if exclude_unpublishing_types options[:with_drafts] = with_drafts if with_drafts @@ -102,9 +102,9 @@ def lookup_content_ids(base_paths:, exclude_document_types: nil, exclude_unpubli def lookup_content_id(base_path:, exclude_document_types: nil, exclude_unpublishing_types: nil, with_drafts: false) lookups = lookup_content_ids( base_paths: [base_path], - exclude_document_types: exclude_document_types, - exclude_unpublishing_types: exclude_unpublishing_types, - with_drafts: with_drafts, + exclude_document_types:, + exclude_unpublishing_types:, + with_drafts:, ) lookups[base_path] end @@ -122,7 +122,7 @@ def lookup_content_id(base_path:, exclude_document_types: nil, exclude_unpublish # @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-v2contentcontent_idpublish def publish(content_id, update_type = nil, options = {}) params = { - update_type: update_type, + update_type:, } optional_keys = %i[locale previous_version] @@ -168,7 +168,7 @@ def republish(content_id, options = {}) # @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-v2contentcontent_idunpublish def unpublish(content_id, type:, explanation: nil, alternative_path: nil, discard_drafts: false, allow_draft: false, previous_version: nil, locale: nil, unpublished_at: nil, redirects: nil) params = { - type: type, + type:, } params[:explanation] = explanation if explanation @@ -435,7 +435,7 @@ def get_paged_editions(params = {}) # } # def get_links_for_content_ids(content_ids) - post_json("#{endpoint}/v2/links/by-content-id", content_ids: content_ids).to_hash + post_json("#{endpoint}/v2/links/by-content-id", content_ids:).to_hash end # Reserves a path for a publishing application @@ -452,7 +452,7 @@ def put_path(base_path, payload) end def unreserve_path(base_path, publishing_app) - payload = { publishing_app: publishing_app } + payload = { publishing_app: } delete_json(unreserve_url(base_path), payload) end diff --git a/lib/gds_api/publishing_api/special_route_publisher.rb b/lib/gds_api/publishing_api/special_route_publisher.rb index 4ff6b130..76c397ef 100644 --- a/lib/gds_api/publishing_api/special_route_publisher.rb +++ b/lib/gds_api/publishing_api/special_route_publisher.rb @@ -22,7 +22,7 @@ def publish(options) schema_name: options.fetch(:schema_name, "special_route"), title: options.fetch(:title), description: options.fetch(:description, ""), - locale: locale, + locale:, details: {}, routes: [ { @@ -33,11 +33,11 @@ def publish(options) publishing_app: options.fetch(:publishing_app), rendering_app: options.fetch(:rendering_app), public_updated_at: time.now.iso8601, - update_type: update_type, + update_type:, ) publishing_api.patch_links(options.fetch(:content_id), links: options[:links]) if options[:links] - publishing_api.publish(options.fetch(:content_id), update_type, locale: locale) + publishing_api.publish(options.fetch(:content_id), update_type, locale:) put_content_response end diff --git a/lib/gds_api/router.rb b/lib/gds_api/router.rb index da095d7d..25a170ee 100644 --- a/lib/gds_api/router.rb +++ b/lib/gds_api/router.rb @@ -28,7 +28,7 @@ def add_route(path, type, backend_id) incoming_path: path, route_type: type, handler: "backend", - backend_id: backend_id, + backend_id:, }, ) end @@ -41,7 +41,7 @@ def add_redirect_route(path, type, destination, redirect_type = "permanent", opt route_type: type, handler: "redirect", redirect_to: destination, - redirect_type: redirect_type, + redirect_type:, segments_mode: options[:segments_mode], }, ) diff --git a/lib/gds_api/test_helpers/account_api.rb b/lib/gds_api/test_helpers/account_api.rb index 95804efd..d55097a3 100644 --- a/lib/gds_api/test_helpers/account_api.rb +++ b/lib/gds_api/test_helpers/account_api.rb @@ -20,11 +20,11 @@ def stub_account_api_request(method, path, with: {}, response_status: 200, respo # GET /api/oauth2/sign-in ######################### def stub_account_api_get_sign_in_url(redirect_path: nil, mfa: false, auth_uri: "http://auth/provider", state: "state") - querystring = Rack::Utils.build_nested_query({ redirect_path: redirect_path, mfa: mfa }.compact) + querystring = Rack::Utils.build_nested_query({ redirect_path:, mfa: }.compact) stub_request(:get, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/sign-in?#{querystring}") .to_return( status: 200, - body: { auth_uri: auth_uri, state: state }.to_json, + body: { auth_uri:, state: }.to_json, ) end @@ -33,16 +33,16 @@ def stub_account_api_get_sign_in_url(redirect_path: nil, mfa: false, auth_uri: " ########################### def stub_account_api_validates_auth_response(code: nil, state: nil, govuk_account_session: "govuk-account-session", redirect_path: "/", ga_client_id: "ga-client-id", cookie_consent: false, feedback_consent: false) stub_request(:post, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/callback") - .with(body: hash_including({ code: code, state: state }.compact)) + .with(body: hash_including({ code:, state: }.compact)) .to_return( status: 200, - body: { govuk_account_session: govuk_account_session, redirect_path: redirect_path, ga_client_id: ga_client_id, cookie_consent: cookie_consent, feedback_consent: feedback_consent }.to_json, + body: { govuk_account_session:, redirect_path:, ga_client_id:, cookie_consent:, feedback_consent: }.to_json, ) end def stub_account_api_rejects_auth_response(code: nil, state: nil) stub_request(:post, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/callback") - .with(body: hash_including({ code: code, state: state }.compact)) + .with(body: hash_including({ code:, state: }.compact)) .to_return(status: 401) end @@ -55,13 +55,13 @@ def stub_account_api_get_end_session_url(govuk_account_session: nil, end_session .with(headers: { GdsApi::AccountApi::AUTH_HEADER_NAME => govuk_account_session }) .to_return( status: 200, - body: { end_session_uri: end_session_uri }.to_json, + body: { end_session_uri: }.to_json, ) else stub_request(:get, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/end-session") .to_return( status: 200, - body: { end_session_uri: end_session_uri }.to_json, + body: { end_session_uri: }.to_json, ) end end @@ -74,11 +74,11 @@ def stub_account_api_user_info(id: "user-id", mfa: false, email: "email@example. :get, "/api/user", response_body: { - id: id, - mfa: mfa, - email: email, - email_verified: email_verified, - services: services, + id:, + mfa:, + email:, + email_verified:, + services:, }, **options, ) @@ -108,7 +108,7 @@ def stub_account_api_unauthorized_user_info(**options) def stub_account_api_match_user_by_email_matches(email:, **options) stub_account_api_request( :get, - "/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: email })}", + "/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: })}", response_body: { match: true, }, @@ -119,7 +119,7 @@ def stub_account_api_match_user_by_email_matches(email:, **options) def stub_account_api_match_user_by_email_does_not_match(email:, **options) stub_account_api_request( :get, - "/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: email })}", + "/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: })}", response_body: { match: false, }, @@ -130,7 +130,7 @@ def stub_account_api_match_user_by_email_does_not_match(email:, **options) def stub_account_api_match_user_by_email_does_not_exist(email:, **options) stub_account_api_request( :get, - "/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: email })}", + "/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: })}", response_status: 404, **options, ) @@ -163,7 +163,7 @@ def stub_update_user_by_subject_identifier(subject_identifier:, email: nil, emai stub_account_api_request( :patch, "/api/oidc-users/#{subject_identifier}", - with: { body: hash_including({ email: email, email_verified: email_verified }.compact) }, + with: { body: hash_including({ email:, email_verified: }.compact) }, response_body: { sub: subject_identifier, email: email || old_email, @@ -176,17 +176,17 @@ def stub_update_user_by_subject_identifier(subject_identifier:, email: nil, emai # GET /api/attributes ##################### def stub_account_api_has_attributes(attributes: [], values: {}, **options) - querystring = Rack::Utils.build_nested_query({ attributes: attributes }.compact) + querystring = Rack::Utils.build_nested_query({ attributes: }.compact) stub_account_api_request( :get, "/api/attributes?#{querystring}", - response_body: { values: values }, + response_body: { values: }, **options, ) end def stub_account_api_unauthorized_has_attributes(attributes: [], **options) - querystring = Rack::Utils.build_nested_query({ attributes: attributes }.compact) + querystring = Rack::Utils.build_nested_query({ attributes: }.compact) stub_account_api_request( :get, "/api/attributes?#{querystring}", @@ -196,7 +196,7 @@ def stub_account_api_unauthorized_has_attributes(attributes: [], **options) end def stub_account_api_forbidden_has_attributes(attributes: [], **options) - querystring = Rack::Utils.build_nested_query({ attributes: attributes }.compact) + querystring = Rack::Utils.build_nested_query({ attributes: }.compact) stub_account_api_request( :get, "/api/attributes?#{querystring}", @@ -212,7 +212,7 @@ def stub_account_api_set_attributes(attributes: nil, **options) stub_account_api_request( :patch, "/api/attributes", - with: { body: hash_including({ attributes: attributes }.compact) }, + with: { body: hash_including({ attributes: }.compact) }, **options, ) end @@ -221,7 +221,7 @@ def stub_account_api_unauthorized_set_attributes(attributes: nil, **options) stub_account_api_request( :patch, "/api/attributes", - with: { body: hash_including({ attributes: attributes }.compact) }, + with: { body: hash_including({ attributes: }.compact) }, response_status: 401, **options, ) @@ -231,7 +231,7 @@ def stub_account_api_forbidden_set_attributes(attributes: nil, **options) stub_account_api_request( :patch, "/api/attributes", - with: { body: hash_including({ attributes: attributes }.compact) }, + with: { body: hash_including({ attributes: }.compact) }, response_status: 403, **options, ) diff --git a/lib/gds_api/test_helpers/asset_manager.rb b/lib/gds_api/test_helpers/asset_manager.rb index 29200c43..bf3f788f 100644 --- a/lib/gds_api/test_helpers/asset_manager.rb +++ b/lib/gds_api/test_helpers/asset_manager.rb @@ -70,7 +70,7 @@ def stub_asset_manager_receives_an_asset(response_url = {}) file_url = "#{ASSET_MANAGER_ENDPOINT}/media/#{options[:id]}/#{options[:filename]}" end - { body: { file_url: file_url }.to_json, status: 200 } + { body: { file_url: }.to_json, status: 200 } end end diff --git a/lib/gds_api/test_helpers/calendars.rb b/lib/gds_api/test_helpers/calendars.rb index e6a32fca..a7bd0124 100644 --- a/lib/gds_api/test_helpers/calendars.rb +++ b/lib/gds_api/test_helpers/calendars.rb @@ -8,7 +8,7 @@ def calendars_endpoint(in_division: nil) end def stub_calendars_has_no_bank_holidays(in_division: nil) - stub_calendars_has_bank_holidays_on([], in_division: in_division) + stub_calendars_has_bank_holidays_on([], in_division:) end def stub_calendars_has_bank_holidays_on(dates, in_division: nil) @@ -26,30 +26,30 @@ def stub_calendars_has_bank_holidays_on(dates, in_division: nil) { "england-and-wales" => { division: "england-and-wales", - events: events, + events:, }, "scotland" => { division: "scotland", - events: events, + events:, }, "northern-ireland" => { division: "northern-ireland", - events: events, + events:, }, } else { division: in_division, - events: events, + events:, } end - stub_request(:get, calendars_endpoint(in_division: in_division)) + stub_request(:get, calendars_endpoint(in_division:)) .to_return(body: response.to_json, status: 200) end def stub_calendars_has_a_bank_holiday_on(date, in_division: nil) - stub_calendars_has_bank_holidays_on([date], in_division: in_division) + stub_calendars_has_bank_holidays_on([date], in_division:) end end end diff --git a/lib/gds_api/test_helpers/content_store.rb b/lib/gds_api/test_helpers/content_store.rb index b3247931..c848401f 100644 --- a/lib/gds_api/test_helpers/content_store.rb +++ b/lib/gds_api/test_helpers/content_store.rb @@ -26,7 +26,7 @@ def stub_content_store_has_item(base_path, body = content_item_for_base_path(bas endpoint = content_store_endpoint(draft: options[:draft]) stub_request(:get, "#{endpoint}/content#{base_path}").to_return( status: 200, - body: body, + body:, headers: { cache_control: "#{visibility}, max-age=#{max_age}", date: Time.now.httpdate, @@ -69,7 +69,7 @@ def stub_content_store_has_gone_item(base_path, body = gone_content_item_for_bas endpoint = content_store_endpoint(draft: options[:draft]) stub_request(:get, "#{endpoint}/content#{base_path}").to_return( status: 410, - body: body, + body:, headers: {}, ) end @@ -86,7 +86,7 @@ def stub_content_store_has_incoming_links(base_path, links) url = "#{content_store_endpoint}/incoming-links#{base_path}" body = links.to_json - stub_request(:get, url).to_return(body: body) + stub_request(:get, url).to_return(body:) end end end diff --git a/lib/gds_api/test_helpers/email_alert_api.rb b/lib/gds_api/test_helpers/email_alert_api.rb index 79549d59..736e3e2a 100644 --- a/lib/gds_api/test_helpers/email_alert_api.rb +++ b/lib/gds_api/test_helpers/email_alert_api.rb @@ -28,7 +28,7 @@ def stub_email_alert_api_has_updated_subscription(subscription_id, frequency) stub_request(:patch, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/#{subscription_id}") .to_return( status: 200, - body: get_subscription_response(subscription_id, frequency: frequency).to_json, + body: get_subscription_response(subscription_id, frequency:).to_json, ) end @@ -43,7 +43,7 @@ def stub_email_alert_api_has_subscriber_subscriptions(id, address, order = nil, stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/#{id}/subscriptions#{params}") .to_return( status: 200, - body: get_subscriber_subscriptions_response(id, address, subscriptions: subscriptions).to_json, + body: get_subscriber_subscriptions_response(id, address, subscriptions:).to_json, ) end @@ -62,11 +62,11 @@ def stub_email_alert_api_has_subscription( ) response = get_subscription_response( id, - frequency: frequency, - title: title, - subscriber_id: subscriber_id, - subscriber_list_id: subscriber_list_id, - ended: ended, + frequency:, + title:, + subscriber_id:, + subscriber_list_id:, + ended:, ).to_json stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/#{id}") @@ -217,16 +217,16 @@ def stub_email_alert_api_creates_a_subscription( ) response = get_subscription_response( returned_subscription_id, - frequency: frequency, - subscriber_list_id: subscriber_list_id, - subscriber_id: subscriber_id, + frequency:, + subscriber_list_id:, + subscriber_id:, ) request_params = { - subscriber_list_id: subscriber_list_id, - address: address, - frequency: frequency, - skip_confirmation_email: skip_confirmation_email, + subscriber_list_id:, + address:, + frequency:, + skip_confirmation_email:, } stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions") @@ -238,9 +238,9 @@ def stub_email_alert_api_refuses_to_create_subscription(subscriber_list_id, addr stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions") .with( body: hash_including( - subscriber_list_id: subscriber_list_id, - address: address, - frequency: frequency, + subscriber_list_id:, + address:, + frequency:, ), ).to_return(status: 422) end @@ -248,14 +248,14 @@ def stub_email_alert_api_refuses_to_create_subscription(subscriber_list_id, addr def stub_email_alert_api_sends_subscription_verification_email(address, frequency, topic_id) stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/auth-token") .with( - body: { address: address, frequency: frequency, topic_id: topic_id }.to_json, + body: { address:, frequency:, topic_id: }.to_json, ).to_return(status: 200) end def stub_email_alert_api_subscription_verification_email_invalid(address, frequency, topic_id) stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/auth-token") .with( - body: { address: address, frequency: frequency, topic_id: topic_id }.to_json, + body: { address:, frequency:, topic_id: }.to_json, ).to_return(status: 422) end @@ -285,7 +285,7 @@ def stub_email_alert_api_subscriber_verification_email_linked_to_govuk_account def stub_email_alert_api_authenticate_subscriber_by_govuk_account(govuk_account_session, subscriber_id, address, govuk_account_id: "user-id", new_govuk_account_session: nil) stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account") .with( - body: { govuk_account_session: govuk_account_session }.to_json, + body: { govuk_account_session: }.to_json, ).to_return( status: 200, body: { @@ -297,7 +297,7 @@ def stub_email_alert_api_authenticate_subscriber_by_govuk_account(govuk_account_ def stub_email_alert_api_authenticate_subscriber_by_govuk_account_session_invalid(govuk_account_session) stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account") .with( - body: { govuk_account_session: govuk_account_session }.to_json, + body: { govuk_account_session: }.to_json, ).to_return( status: 401, ) @@ -306,7 +306,7 @@ def stub_email_alert_api_authenticate_subscriber_by_govuk_account_session_invali def stub_email_alert_api_authenticate_subscriber_by_govuk_account_email_unverified(govuk_account_session, new_govuk_account_session: nil) stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account") .with( - body: { govuk_account_session: govuk_account_session }.to_json, + body: { govuk_account_session: }.to_json, ).to_return( status: 403, body: { @@ -318,7 +318,7 @@ def stub_email_alert_api_authenticate_subscriber_by_govuk_account_email_unverifi def stub_email_alert_api_authenticate_subscriber_by_govuk_account_no_subscriber(govuk_account_session, new_govuk_account_session: nil) stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account") .with( - body: { govuk_account_session: govuk_account_session }.to_json, + body: { govuk_account_session: }.to_json, ).to_return( status: 404, body: { @@ -330,7 +330,7 @@ def stub_email_alert_api_authenticate_subscriber_by_govuk_account_no_subscriber( def stub_email_alert_api_link_subscriber_to_govuk_account(govuk_account_session, subscriber_id, address, govuk_account_id: "user-id", new_govuk_account_session: nil) stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account/link") .with( - body: { govuk_account_session: govuk_account_session }.to_json, + body: { govuk_account_session: }.to_json, ).to_return( status: 200, body: { @@ -342,7 +342,7 @@ def stub_email_alert_api_link_subscriber_to_govuk_account(govuk_account_session, def stub_email_alert_api_link_subscriber_to_govuk_account_session_invalid(govuk_account_session) stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account/link") .with( - body: { govuk_account_session: govuk_account_session }.to_json, + body: { govuk_account_session: }.to_json, ).to_return( status: 401, ) @@ -351,7 +351,7 @@ def stub_email_alert_api_link_subscriber_to_govuk_account_session_invalid(govuk_ def stub_email_alert_api_link_subscriber_to_govuk_account_email_unverified(govuk_account_session, new_govuk_account_session: nil) stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/govuk-account/link") .with( - body: { govuk_account_session: govuk_account_session }.to_json, + body: { govuk_account_session: }.to_json, ).to_return( status: 403, body: { @@ -380,9 +380,9 @@ def assert_unsubscribed(uuid) def assert_subscribed(subscriber_list_id, address, frequency = "immediately") assert_requested(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions") do |req| JSON.parse(req.body).symbolize_keys == { - subscriber_list_id: subscriber_list_id, - address: address, - frequency: frequency, + subscriber_list_id:, + address:, + frequency:, } end end @@ -411,8 +411,8 @@ def stub_email_alert_api_bulk_unsubscribe_with_message(slug:, body:, sender_mess stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe") .with({ body: { - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, }.to_json, }.tap { |attr| attr[:headers] = { "Govuk-Request-Id" => govuk_request_id } if govuk_request_id }) .to_return(status: 202) @@ -427,8 +427,8 @@ def stub_email_alert_api_bulk_unsubscribe_not_found_with_message(slug:, body:, s stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe") .with({ body: { - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, }.to_json, }.tap { |attr| attr[:headers] = { "Govuk-Request-Id" => govuk_request_id } if govuk_request_id }) .to_return(status: 404) @@ -443,8 +443,8 @@ def stub_email_alert_api_bulk_unsubscribe_conflict_with_message(slug:, body:, se stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe") .with({ body: { - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, }.to_json, }.tap { |attr| attr[:headers] = { "Govuk-Request-Id" => govuk_request_id } if govuk_request_id }) .to_return(status: 409) @@ -459,8 +459,8 @@ def stub_email_alert_api_bulk_unsubscribe_bad_request_with_message(slug:, body:, stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe") .with({ body: { - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, }.to_json, }.tap { |attr| attr[:headers] = { "Govuk-Request-Id" => govuk_request_id } if govuk_request_id }) .to_return(status: 422) @@ -468,19 +468,19 @@ def stub_email_alert_api_bulk_unsubscribe_bad_request_with_message(slug:, body:, def stub_email_alert_api_bulk_migrate(from_slug:, to_slug:) stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/bulk-migrate") - .with(body: { from_slug: from_slug, to_slug: to_slug }.to_json) + .with(body: { from_slug:, to_slug: }.to_json) .to_return(status: 202) end def stub_email_alert_api_bulk_migrate_bad_request(from_slug:, to_slug:) stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/bulk-migrate") - .with(body: { from_slug: from_slug, to_slug: to_slug }.to_json) + .with(body: { from_slug:, to_slug: }.to_json) .to_return(status: 422) end def stub_email_alert_api_bulk_migrate_not_found(from_slug:, to_slug:) stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/bulk-migrate") - .with(body: { from_slug: from_slug, to_slug: to_slug }.to_json) + .with(body: { from_slug:, to_slug: }.to_json) .to_return(status: 404) end diff --git a/lib/gds_api/test_helpers/imminence.rb b/lib/gds_api/test_helpers/imminence.rb index 7d970bf5..4b01c41a 100644 --- a/lib/gds_api/test_helpers/imminence.rb +++ b/lib/gds_api/test_helpers/imminence.rb @@ -22,18 +22,18 @@ def stub_imminence_has_multiple_authorities_for_postcode(addresses, slug, postco response_data = { status: "address-information-required", content: "addresses", - addresses: addresses, + addresses:, } stub_imminence_places_request(slug, query_hash, response_data) end def stub_imminence_has_places_for_postcode(places, slug, postcode, limit, local_authority_slug) query_hash = { "postcode" => postcode, "limit" => limit } - query_hash.merge!(local_authority_slug: local_authority_slug) if local_authority_slug + query_hash.merge!(local_authority_slug:) if local_authority_slug response_data = { status: "ok", content: "places", - places: places, + places:, } stub_imminence_places_request(slug, query_hash, response_data) end diff --git a/lib/gds_api/test_helpers/link_checker_api.rb b/lib/gds_api/test_helpers/link_checker_api.rb index a70d92b9..5aaf188b 100644 --- a/lib/gds_api/test_helpers/link_checker_api.rb +++ b/lib/gds_api/test_helpers/link_checker_api.rb @@ -7,61 +7,61 @@ module LinkCheckerApi def link_checker_api_link_report_hash(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil) { - uri: uri, - status: status, + uri:, + status:, checked: checked || Time.now.iso8601, - errors: errors, - warnings: warnings, - problem_summary: problem_summary, - suggested_fix: suggested_fix, + errors:, + warnings:, + problem_summary:, + suggested_fix:, } end def link_checker_api_batch_report_hash(id:, status: :completed, links: [], totals: {}, completed_at: nil) { - id: id, - status: status, + id:, + status:, links: links.map { |hash| link_checker_api_link_report_hash(**hash) }, - totals: totals, + totals:, completed_at: completed_at || Time.now.iso8601, } end def stub_link_checker_api_check(uri:, status: :ok, checked: nil, errors: [], warnings: [], problem_summary: nil, suggested_fix: nil) body = link_checker_api_link_report_hash( - uri: uri, status: status, checked: checked, errors: errors, warnings: warnings, problem_summary: problem_summary, suggested_fix: suggested_fix, + uri:, status:, checked:, errors:, warnings:, problem_summary:, suggested_fix:, ).to_json stub_request(:get, "#{LINK_CHECKER_API_ENDPOINT}/check") - .with(query: { uri: uri }) - .to_return(body: body, status: 200, headers: { "Content-Type" => "application/json" }) + .with(query: { uri: }) + .to_return(body:, status: 200, headers: { "Content-Type" => "application/json" }) end def stub_link_checker_api_get_batch(id:, status: :completed, links: [], totals: {}, completed_at: nil) body = link_checker_api_batch_report_hash( - id: id, status: status, links: links, totals: totals, completed_at: completed_at, + id:, status:, links:, totals:, completed_at:, ).to_json stub_request(:get, "#{LINK_CHECKER_API_ENDPOINT}/batch/#{id}") - .to_return(body: body, status: 200, headers: { "Content-Type" => "application/json" }) + .to_return(body:, status: 200, headers: { "Content-Type" => "application/json" }) end 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) - links = uris.map { |uri| { uri: uri } } if links.nil? + links = uris.map { |uri| { uri: } } if links.nil? response_body = link_checker_api_batch_report_hash( - id: id, - status: status, - links: links, - totals: totals, - completed_at: completed_at, + id:, + status:, + links:, + totals:, + completed_at:, ).to_json request_body = { - uris: uris, - checked_within: checked_within, - webhook_uri: webhook_uri, - webhook_secret_token: webhook_secret_token, + uris:, + checked_within:, + webhook_uri:, + webhook_secret_token:, }.delete_if { |_, v| v.nil? }.to_json stub_request(:post, "#{LINK_CHECKER_API_ENDPOINT}/batch") diff --git a/lib/gds_api/test_helpers/local_links_manager.rb b/lib/gds_api/test_helpers/local_links_manager.rb index 91f643e5..d17df92b 100644 --- a/lib/gds_api/test_helpers/local_links_manager.rb +++ b/lib/gds_api/test_helpers/local_links_manager.rb @@ -25,12 +25,12 @@ def stub_local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:, cou response["local_authority"]["snac"] = snac if snac stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link") - .with(query: { authority_slug: authority_slug, lgsl: lgsl, lgil: lgil }) + .with(query: { authority_slug:, lgsl:, lgil: }) .to_return(body: response.to_json, status: 200) unless local_custodian_code.nil? stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link") - .with(query: { local_custodian_code: local_custodian_code, lgsl: lgsl, lgil: lgil }) + .with(query: { local_custodian_code:, lgsl:, lgil: }) .to_return(body: response.to_json, status: 200) end end @@ -49,12 +49,12 @@ def stub_local_links_manager_has_no_link(authority_slug:, lgsl:, lgil:, country_ response["local_authority"]["snac"] = snac if snac stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link") - .with(query: { authority_slug: authority_slug, lgsl: lgsl, lgil: lgil }) + .with(query: { authority_slug:, lgsl:, lgil: }) .to_return(body: response.to_json, status: 200) unless local_custodian_code.nil? stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link") - .with(query: { local_custodian_code: local_custodian_code, lgsl: lgsl, lgil: lgil }) + .with(query: { local_custodian_code:, lgsl:, lgil: }) .to_return(body: response.to_json, status: 200) end end @@ -73,12 +73,12 @@ def stub_local_links_manager_has_no_link_and_no_homepage_url(authority_slug:, lg response["local_authority"]["snac"] = snac if snac stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link") - .with(query: { authority_slug: authority_slug, lgsl: lgsl, lgil: lgil }) + .with(query: { authority_slug:, lgsl:, lgil: }) .to_return(body: response.to_json, status: 200) unless local_custodian_code.nil? stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link") - .with(query: { local_custodian_code: local_custodian_code, lgsl: lgsl, lgil: lgil }) + .with(query: { local_custodian_code:, lgsl:, lgil: }) .to_return(body: response.to_json, status: 200) end end @@ -117,12 +117,12 @@ def stub_local_links_manager_has_a_local_authority(authority_slug, country_name: response["local_authorities"][0]["snac"] = snac if snac stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority") - .with(query: { authority_slug: authority_slug }) + .with(query: { authority_slug: }) .to_return(body: response.to_json, status: 200) unless local_custodian_code.nil? stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority") - .with(query: { local_custodian_code: local_custodian_code }) + .with(query: { local_custodian_code: }) .to_return(body: response.to_json, status: 200) end end @@ -157,7 +157,7 @@ def stub_local_links_manager_has_a_district_and_county_local_authority(district_ unless local_custodian_code.nil? stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority") - .with(query: { local_custodian_code: local_custodian_code }) + .with(query: { local_custodian_code: }) .to_return(body: response.to_json, status: 200) end end @@ -176,13 +176,13 @@ def stub_local_links_manager_request_without_local_custodian_code def stub_local_links_manager_does_not_have_an_authority(authority_slug) stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority") - .with(query: { authority_slug: authority_slug }) + .with(query: { authority_slug: }) .to_return(body: {}.to_json, status: 404) end def stub_local_links_manager_does_not_have_a_custodian_code(local_custodian_code) stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority") - .with(query: { local_custodian_code: local_custodian_code }) + .with(query: { local_custodian_code: }) .to_return(body: {}.to_json, status: 404) end @@ -202,12 +202,12 @@ def stub_local_links_manager_has_a_local_authority_without_homepage(authority_sl response["local_authorities"][0]["snac"] = snac if snac stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority") - .with(query: { authority_slug: authority_slug }) + .with(query: { authority_slug: }) .to_return(body: response.to_json, status: 200) unless local_custodian_code.nil? stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority") - .with(query: { local_custodian_code: local_custodian_code }) + .with(query: { local_custodian_code: }) .to_return(body: response.to_json, status: 200) end end diff --git a/lib/gds_api/test_helpers/publishing_api.rb b/lib/gds_api/test_helpers/publishing_api.rb index 9e90358f..62cf93a4 100644 --- a/lib/gds_api/test_helpers/publishing_api.rb +++ b/lib/gds_api/test_helpers/publishing_api.rb @@ -80,7 +80,7 @@ def stub_publishing_api_publish(content_id, body, response_hash = {}) body: "{}", headers: { "Content-Type" => "application/json; charset=utf-8" }, }.merge(response_hash) - stub_request(:post, url).with(body: body).to_return(response) + stub_request(:post, url).with(body:).to_return(response) end # Stub a POST /v2/content/:content_id/republish request @@ -95,7 +95,7 @@ def stub_publishing_api_republish(content_id, body = {}, response_hash = {}) body: "{}", headers: { "Content-Type" => "application/json; charset=utf-8" }, }.merge(response_hash) - stub_request(:post, url).with(body: body).to_return(response) + stub_request(:post, url).with(body:).to_return(response) end # Stub a POST /v2/content/:content_id/unpublish request @@ -271,9 +271,9 @@ def assert_publishing_api(verb, url, attributes_or_matcher = nil, times = 1) end if matcher - assert_requested(verb, url, times: times, &matcher) + assert_requested(verb, url, times:, &matcher) else - assert_requested(verb, url, times: times) + assert_requested(verb, url, times:) end end @@ -617,7 +617,7 @@ def stub_publishing_api_get_editions(editions, params = {}) results = results.take(per_page) body = { - results: results, + results:, links: [ { rel: "self", href: "#{PUBLISHING_API_V2_ENDPOINT}/editions" }, ], @@ -664,7 +664,7 @@ def stub_publishing_api_put_intent(base_path, params = {}) response = { status: 200, headers: { content_type: "application/json" }, - body: body, + body:, } stub_request(:put, url).with(body: params).to_return(response) end @@ -691,9 +691,9 @@ def assert_publishing_api_put(url, attributes_or_matcher = {}, times = 1) end if matcher - assert_requested(:put, url, times: times, &matcher) + assert_requested(:put, url, times:, &matcher) else - assert_requested(:put, url, times: times) + assert_requested(:put, url, times:) end end @@ -728,7 +728,7 @@ def stub_publishing_api_path_reservation(base_path, params = {}) response = { status: 200, headers: { content_type: "application/json" }, - body: params.merge(base_path: base_path).to_json, + body: params.merge(base_path:).to_json, } stub_request(:put, url).with(body: params).to_return(response) @@ -741,7 +741,7 @@ def stub_publishing_api_path_reservation(base_path, params = {}) def stub_any_publishing_api_path_reservation stub_request(:put, %r{\A#{PUBLISHING_API_ENDPOINT}/paths/}).to_return do |request| base_path = request.uri.path.sub(%r{\A/paths}, "") - body = JSON.parse(request.body).merge(base_path: base_path) + body = JSON.parse(request.body).merge(base_path:) { status: 200, headers: { content_type: "application/json" }, @@ -768,13 +768,13 @@ def stub_publishing_api_has_path_reservation_for(path, publishing_app) stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}") .to_return(status: 422, headers: { content_type: "application/json" }, - body: { error: error }.to_json) + body: { error: }.to_json) stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}") .with(body: { "publishing_app" => publishing_app }) .to_return(status: 200, headers: { content_type: "application/json" }, - body: { publishing_app: publishing_app, base_path: path }.to_json) + body: { publishing_app:, base_path: path }.to_json) end # Stub a PUT /paths/:base_path request for a particular publishing @@ -794,12 +794,12 @@ def stub_publishing_api_returns_path_reservation_validation_error_for(base_path, message = "#{error_fields.keys.first.to_s.capitalize.gsub(/_/, ' ')} #{error_fields.values.flatten.first}" - error = { code: 422, message: message, fields: error_fields } + error = { code: 422, message:, fields: error_fields } stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{base_path}") .to_return(status: 422, headers: { content_type: "application/json" }, - body: { error: error }.to_json) + body: { error: }.to_json) end private @@ -817,7 +817,7 @@ def stub_publishing_api_postlike_call(method, content_id, body, resource_path, o response_hash.merge!(override_response_hash) response_hash[:body] = response_hash[:body].to_json if response_hash[:body].is_a?(Hash) url = "#{PUBLISHING_API_V2_ENDPOINT}#{resource_path}/#{content_id}" - stub_request(method, url).with(body: body).to_return(response_hash) + stub_request(method, url).with(body:).to_return(response_hash) end def deep_stringify_keys(hash) @@ -858,8 +858,8 @@ def version_conflict(expected_version, actual_version = expected_version + 1) def stub_publishing_api_unreserve_path_with_code(base_path, publishing_app, code) url = "#{PUBLISHING_API_ENDPOINT}/paths#{base_path}" - body = { publishing_app: publishing_app } - stub_request(:delete, url).with(body: body).to_return(status: code, body: "{}", headers: { "Content-Type" => "application/json; charset=utf-8" }) + body = { publishing_app: } + stub_request(:delete, url).with(body:).to_return(status: code, body: "{}", headers: { "Content-Type" => "application/json; charset=utf-8" }) end def values_match_recursively(expected_value, actual_value) diff --git a/lib/gds_api/test_helpers/router.rb b/lib/gds_api/test_helpers/router.rb index 040ddf1a..91b0e365 100644 --- a/lib/gds_api/test_helpers/router.rb +++ b/lib/gds_api/test_helpers/router.rb @@ -18,15 +18,15 @@ def stub_router_doesnt_have_route(path, bearer_token = ENV["ROUTER_API_BEARER_TO end def stub_router_has_backend_route(path, backend_id:, route_type: "exact", disabled: false) - stub_router_has_route(path, handler: "backend", backend_id: backend_id, disabled: disabled, route_type: route_type) + stub_router_has_route(path, handler: "backend", backend_id:, disabled:, route_type:) end def stub_router_has_redirect_route(path, redirect_to:, redirect_type: "permanent", route_type: "exact", disabled: false) - stub_router_has_route(path, handler: "redirect", redirect_to: redirect_to, redirect_type: redirect_type, disabled: disabled, route_type: route_type) + stub_router_has_route(path, handler: "redirect", redirect_to:, redirect_type:, disabled:, route_type:) end def stub_router_has_gone_route(path, route_type: "exact", disabled: false) - stub_router_has_route(path, handler: "gone", route_type: route_type, disabled: disabled) + stub_router_has_route(path, handler: "gone", route_type:, disabled:) end def stub_all_router_registration @@ -47,7 +47,7 @@ def stub_route_registration(path, type, backend_id) incoming_path: path, route_type: type, handler: "backend", - backend_id: backend_id, + backend_id:, }, }) end @@ -59,8 +59,8 @@ def stub_redirect_registration(path, type, destination, redirect_type, segments_ route_type: type, handler: "redirect", redirect_to: destination, - redirect_type: redirect_type, - segments_mode: segments_mode, + redirect_type:, + segments_mode:, }, }) end diff --git a/lib/gds_api/test_helpers/support_api.rb b/lib/gds_api/test_helpers/support_api.rb index a92d6f56..4d1e2b60 100644 --- a/lib/gds_api/test_helpers/support_api.rb +++ b/lib/gds_api/test_helpers/support_api.rb @@ -115,7 +115,7 @@ def stub_support_api_organisations_list(response_body = nil) def stub_support_api_organisation(slug = "cabinet-office", response_body = nil) response_body ||= { - slug: slug, + slug:, web_url: "https://www.gov.uk/government/organisations/#{slug}", title: "Cabinet Office", acronym: "CO", diff --git a/test/email_alert_api_test.rb b/test/email_alert_api_test.rb index 8c720616..363df731 100644 --- a/test/email_alert_api_test.rb +++ b/test/email_alert_api_test.rb @@ -847,109 +847,109 @@ let(:sender_message_id) { SecureRandom.uuid } it "returns 202 with just a subscriber_list_slug" do - stub_email_alert_api_bulk_unsubscribe(slug: slug) - api_response = api_client.bulk_unsubscribe(slug: slug) + stub_email_alert_api_bulk_unsubscribe(slug:) + api_response = api_client.bulk_unsubscribe(slug:) assert_equal(202, api_response.code) end it "returns 202 with a message" do stub_email_alert_api_bulk_unsubscribe_with_message( - slug: slug, + slug:, govuk_request_id: "govuk_request_id", - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, ) api_response = api_client.bulk_unsubscribe( - slug: slug, + slug:, govuk_request_id: "govuk_request_id", - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, ) assert_equal(202, api_response.code) end it "returns 202 with a message when govuk_request_id is not passed in as a parameter" do stub_email_alert_api_bulk_unsubscribe_with_message( - slug: slug, - body: body, - sender_message_id: sender_message_id, + slug:, + body:, + sender_message_id:, ) api_response = api_client.bulk_unsubscribe( - slug: slug, - body: body, - sender_message_id: sender_message_id, + slug:, + body:, + sender_message_id:, ) assert_equal(202, api_response.code) end it "returns 404 if the subscription list is not found" do - stub_email_alert_api_bulk_unsubscribe_not_found(slug: slug) + stub_email_alert_api_bulk_unsubscribe_not_found(slug:) assert_raises GdsApi::HTTPNotFound do - api_client.bulk_unsubscribe(slug: slug) + api_client.bulk_unsubscribe(slug:) end end it "returns 404 if the subscription list is not found and a message is provided" do stub_email_alert_api_bulk_unsubscribe_not_found_with_message( - slug: slug, + slug:, govuk_request_id: "govuk_request_id", - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, ) assert_raises GdsApi::HTTPNotFound do api_client.bulk_unsubscribe( - slug: slug, + slug:, govuk_request_id: "govuk_request_id", - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, ) end end it "returns 409 on conflict" do - stub_email_alert_api_bulk_unsubscribe_conflict(slug: slug) + stub_email_alert_api_bulk_unsubscribe_conflict(slug:) assert_raises GdsApi::HTTPConflict do - api_client.bulk_unsubscribe(slug: slug) + api_client.bulk_unsubscribe(slug:) end end it "returns 409 on conflict if a message is provided" do stub_email_alert_api_bulk_unsubscribe_conflict_with_message( - slug: slug, + slug:, govuk_request_id: "govuk_request_id", - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, ) assert_raises GdsApi::HTTPConflict do api_client.bulk_unsubscribe( - slug: slug, + slug:, govuk_request_id: "govuk_request_id", - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, ) end end it "returns 422 on bad request" do - stub_email_alert_api_bulk_unsubscribe_bad_request(slug: slug) + stub_email_alert_api_bulk_unsubscribe_bad_request(slug:) assert_raises GdsApi::HTTPUnprocessableEntity do - api_client.bulk_unsubscribe(slug: slug) + api_client.bulk_unsubscribe(slug:) end end it "returns 422 on bad request if a message is provided" do stub_email_alert_api_bulk_unsubscribe_bad_request_with_message( - slug: slug, + slug:, govuk_request_id: "govuk_request_id", - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, ) assert_raises GdsApi::HTTPUnprocessableEntity do api_client.bulk_unsubscribe( - slug: slug, + slug:, govuk_request_id: "govuk_request_id", - body: body, - sender_message_id: sender_message_id, + body:, + sender_message_id:, ) end end @@ -961,42 +961,42 @@ it "returns 202 if valid to_slug and from_slug are provided" do stub_email_alert_api_bulk_migrate( - from_slug: from_slug, - to_slug: to_slug, + from_slug:, + to_slug:, ) - api_response = api_client.bulk_migrate(from_slug: from_slug, to_slug: to_slug) + api_response = api_client.bulk_migrate(from_slug:, to_slug:) assert_equal(202, api_response.code) end it "returns 404 if the subscription list is not found" do stub_email_alert_api_bulk_migrate_not_found( - from_slug: from_slug, - to_slug: to_slug, + from_slug:, + to_slug:, ) assert_raises GdsApi::HTTPNotFound do - api_client.bulk_migrate(from_slug: from_slug, to_slug: to_slug) + api_client.bulk_migrate(from_slug:, to_slug:) end end it "returns 422 if either from_slug or to_slug are missing" do stub_email_alert_api_bulk_migrate_bad_request( - from_slug: from_slug, + from_slug:, to_slug: "", ) assert_raises GdsApi::HTTPUnprocessableEntity do - api_client.bulk_migrate(from_slug: from_slug, to_slug: "") + api_client.bulk_migrate(from_slug:, to_slug: "") end stub_email_alert_api_bulk_migrate_bad_request( from_slug: "", - to_slug: to_slug, + to_slug:, ) assert_raises GdsApi::HTTPUnprocessableEntity do - api_client.bulk_migrate(from_slug: "", to_slug: to_slug) + api_client.bulk_migrate(from_slug: "", to_slug:) end end end @@ -1007,8 +1007,8 @@ it "returns 200 and subscriber list with updated title" do params = { "title" => "New Title" } - stub_update_subscriber_list_details(slug: slug, params: params) - api_response = api_client.update_subscriber_list_details(slug: slug, params: params) + stub_update_subscriber_list_details(slug:, params:) + api_response = api_client.update_subscriber_list_details(slug:, params:) assert_equal(200, api_response.code) assert_equal(params["title"], api_response.to_h.dig("subscriber_list", "title")) @@ -1017,19 +1017,19 @@ it "returns 404 when subscriber list is not found" do params = { "title" => "New Title" } - stub_update_subscriber_list_details_not_found(slug: slug, params: params) + stub_update_subscriber_list_details_not_found(slug:, params:) assert_raises GdsApi::HTTPNotFound do - api_client.update_subscriber_list_details(slug: slug, params: params) + api_client.update_subscriber_list_details(slug:, params:) end end it "returns 422 when provided with invalid parameters" do params = { "title" => nil } - stub_update_subscriber_list_details_unprocessible_entity(slug: slug, params: params) + stub_update_subscriber_list_details_unprocessible_entity(slug:, params:) assert_raises GdsApi::HTTPUnprocessableEntity do - api_client.update_subscriber_list_details(slug: slug, params: params) + api_client.update_subscriber_list_details(slug:, params:) end end end diff --git a/test/pacts/account_api_pact_test.rb b/test/pacts/account_api_pact_test.rb index 2bece1d9..f8a044b7 100644 --- a/test/pacts/account_api_pact_test.rb +++ b/test/pacts/account_api_pact_test.rb @@ -26,7 +26,7 @@ account_api .upon_receiving("a sign-in request") - .with(method: :get, path: path, headers: headers) + .with(method: :get, path:, headers:) .will_respond_with(status: 200, headers: json_response_headers, body: response_body) api_client.get_sign_in_url @@ -41,7 +41,7 @@ account_api .given("there is a valid OAuth response") .upon_receiving("a validation request") - .with(method: :post, path: path, headers: headers_with_json_body, body: params) + .with(method: :post, path:, headers: headers_with_json_body, body: params) .will_respond_with(status: 200, headers: json_response_headers, body: response_body_with_session_identifier) api_client.validate_auth_response(**params) @@ -49,12 +49,12 @@ it "responds with 200 OK and includes the redirect_path in the response, if given" do redirect_path = "/some-arbitrary-path" - response_body = response_body_with_session_identifier.merge(redirect_path: redirect_path) + response_body = response_body_with_session_identifier.merge(redirect_path:) account_api .given("there is a valid OAuth response, with the redirect path '#{redirect_path}'") .upon_receiving("a validation request") - .with(method: :post, path: path, headers: headers_with_json_body, body: params) + .with(method: :post, path:, headers: headers_with_json_body, body: params) .will_respond_with(status: 200, headers: json_response_headers, body: response_body) api_client.validate_auth_response(**params) @@ -63,7 +63,7 @@ it "responds with 401 Unauthorized if the parameters are not valid" do account_api .upon_receiving("a validation request") - .with(method: :post, path: path, headers: headers_with_json_body, body: params) + .with(method: :post, path:, headers: headers_with_json_body, body: params) .will_respond_with(status: 401) assert_raises GdsApi::HTTPUnauthorized do @@ -82,7 +82,7 @@ account_api .upon_receiving("an end-session request") - .with(method: :get, path: path, headers: headers) + .with(method: :get, path:, headers:) .will_respond_with(status: 200, headers: json_response_headers, body: response_body) api_client.get_end_session_url @@ -102,11 +102,11 @@ account_api .upon_receiving("a request to change the user's email attributes") - .with(method: :patch, path: path, headers: headers_with_json_body, body: email_attributes) + .with(method: :patch, path:, headers: headers_with_json_body, body: email_attributes) .will_respond_with(status: 200, headers: json_response_headers, body: response_body) api_client.update_user_by_subject_identifier( - subject_identifier: subject_identifier, + subject_identifier:, **email_attributes, ) end @@ -120,20 +120,20 @@ account_api .given("there is a user with subject identifier '#{subject_identifier}'") .upon_receiving("a delete-user request for '#{subject_identifier}'") - .with(method: :delete, path: path, headers: headers) + .with(method: :delete, path:, headers:) .will_respond_with(status: 204) - api_client.delete_user_by_subject_identifier(subject_identifier: subject_identifier) + api_client.delete_user_by_subject_identifier(subject_identifier:) end it "responds with 404 if the user does not exist" do account_api .upon_receiving("a delete-user request") - .with(method: :delete, path: path, headers: headers) + .with(method: :delete, path:, headers:) .will_respond_with(status: 404) assert_raises GdsApi::HTTPNotFound do - api_client.delete_user_by_subject_identifier(subject_identifier: subject_identifier) + api_client.delete_user_by_subject_identifier(subject_identifier:) end end end @@ -146,20 +146,20 @@ account_api .given("there is a user with email address '#{email}'") .upon_receiving("a match-user-by-email request for '#{email}'") - .with(method: :get, path: path, headers: headers, query: { email: email }) + .with(method: :get, path:, headers:, query: { email: }) .will_respond_with(status: 200, headers: json_response_headers, body: { match: Pact.like(false) }) - api_client.match_user_by_email(email: email) + api_client.match_user_by_email(email:) end it "responds with 404 if the user does not exist" do account_api .upon_receiving("a match-user-by-email request for '#{email}'") - .with(method: :get, path: path, headers: headers, query: { email: email }) + .with(method: :get, path:, headers:, query: { email: }) .will_respond_with(status: 404) assert_raises GdsApi::HTTPNotFound do - api_client.match_user_by_email(email: email) + api_client.match_user_by_email(email:) end end end @@ -181,10 +181,10 @@ account_api .given("there is a valid user session") .upon_receiving("a get-user request") - .with(method: :get, path: path, headers: headers) + .with(method: :get, path:, headers:) .will_respond_with(status: 200, headers: json_response_headers, body: user_details) - api_client.get_user(govuk_account_session: govuk_account_session) + api_client.get_user(govuk_account_session:) end end @@ -200,10 +200,10 @@ account_api .given("there is a valid user session") .upon_receiving("a get-attributes request") - .with(method: :get, path: path, headers: headers, query: { "attributes[]" => [attribute_name] }) + .with(method: :get, path:, headers:, query: { "attributes[]" => [attribute_name] }) .will_respond_with(status: 200, headers: json_response_headers, body: response_body) - api_client.get_attributes(govuk_account_session: govuk_account_session, attributes: [attribute_name]) + api_client.get_attributes(govuk_account_session:, attributes: [attribute_name]) end it "responds with 200 OK and the attributes, if some exist" do @@ -212,10 +212,10 @@ account_api .given("there is a valid user session, with an attribute called '#{attribute_name}'") .upon_receiving("a get-attributes request") - .with(method: :get, path: path, headers: headers, query: { "attributes[]" => [attribute_name] }) + .with(method: :get, path:, headers:, query: { "attributes[]" => [attribute_name] }) .will_respond_with(status: 200, headers: json_response_headers, body: response_body) - api_client.get_attributes(govuk_account_session: govuk_account_session, attributes: [attribute_name]) + api_client.get_attributes(govuk_account_session:, attributes: [attribute_name]) end end end diff --git a/test/pacts/organisations_api_pact_test.rb b/test/pacts/organisations_api_pact_test.rb index 6de1584f..c8bef1a4 100644 --- a/test/pacts/organisations_api_pact_test.rb +++ b/test/pacts/organisations_api_pact_test.rb @@ -64,7 +64,7 @@ let(:response) do { status: 200, - body: body, + body:, } end diff --git a/test/pacts/publishing_api/get_content_items_pact_test.rb b/test/pacts/publishing_api/get_content_items_pact_test.rb index 14c287ee..191f4f75 100644 --- a/test/pacts/publishing_api/get_content_items_pact_test.rb +++ b/test/pacts/publishing_api/get_content_items_pact_test.rb @@ -59,7 +59,7 @@ rel: "self", }], results: [ - { content_id: content_id, locale: "en" }, + { content_id:, locale: "en" }, ], }, ) @@ -90,7 +90,7 @@ rel: "self", }], results: [ - { content_id: content_id, locale: "fr" }, + { content_id:, locale: "fr" }, ], }, ) @@ -122,9 +122,9 @@ rel: "self", }], results: [ - { content_id: content_id, locale: "en" }, - { content_id: content_id, locale: "fr" }, - { content_id: content_id, locale: "ar" }, + { content_id:, locale: "en" }, + { content_id:, locale: "fr" }, + { content_id:, locale: "ar" }, ], }, ) @@ -156,7 +156,7 @@ rel: "self", }], results: [ - { content_id: content_id, details: { foo: :bar } }, + { content_id:, details: { foo: :bar } }, ], }, ) diff --git a/test/pacts/publishing_api/unreserve_path_pact_test.rb b/test/pacts/publishing_api/unreserve_path_pact_test.rb index 33014e72..9990c9b1 100644 --- a/test/pacts/publishing_api/unreserve_path_pact_test.rb +++ b/test/pacts/publishing_api/unreserve_path_pact_test.rb @@ -16,7 +16,7 @@ .with( method: :delete, path: "/paths#{base_path}", - body: { publishing_app: publishing_app }, + body: { publishing_app: }, headers: { "Content-Type" => "application/json", }, @@ -42,7 +42,7 @@ .with( method: :delete, path: "/paths#{base_path}", - body: { publishing_app: publishing_app }, + body: { publishing_app: }, headers: { "Content-Type" => "application/json", }, diff --git a/test/publishing_api/special_route_publisher_test.rb b/test/publishing_api/special_route_publisher_test.rb index 0c9cd740..7525f1fd 100644 --- a/test/publishing_api/special_route_publisher_test.rb +++ b/test/publishing_api/special_route_publisher_test.rb @@ -10,7 +10,7 @@ let(:content_id) { "a-content-id-of-sorts" } let(:special_route) do { - content_id: content_id, + content_id:, title: "A title", description: "A description", base_path: "/favicon.ico", @@ -101,7 +101,7 @@ stub(:publishing_api, put_content_item: nil) end let(:publisher) do - GdsApi::PublishingApi::SpecialRoutePublisher.new(publishing_api: publishing_api) + GdsApi::PublishingApi::SpecialRoutePublisher.new(publishing_api:) end it "is robust to Time.zone returning nil" do diff --git a/test/response_test.rb b/test/response_test.rb index 5387e322..6fe5fe1c 100644 --- a/test/response_test.rb +++ b/test/response_test.rb @@ -27,7 +27,7 @@ cache_control_headers = { cache_control: "public, max-age=900" } headers = cache_control_headers.merge(date: Time.now.httpdate) - mock_http_response = stub(body: "A Response body", code: 200, headers: headers) + mock_http_response = stub(body: "A Response body", code: 200, headers:) response = GdsApi::Response.new(mock_http_response) assert_equal Time.parse("15:15"), response.expires_at @@ -39,7 +39,7 @@ cache_headers = { cache_control: "public", expires: (Time.now + 900).httpdate } headers = cache_headers.merge(date: Time.now.httpdate) - mock_http_response = stub(body: "A Response body", code: 200, headers: headers) + mock_http_response = stub(body: "A Response body", code: 200, headers:) response = GdsApi::Response.new(mock_http_response) assert_equal Time.parse("15:15"), response.expires_at @@ -65,7 +65,7 @@ it "should be seconds remaining from expiration time inferred from max-age" do cache_control_headers = { cache_control: "public, max-age=900" } headers = cache_control_headers.merge(date: Time.now.httpdate) - mock_http_response = stub(body: "A Response body", code: 200, headers: headers) + mock_http_response = stub(body: "A Response body", code: 200, headers:) Timecop.travel(12 * 60) do response = GdsApi::Response.new(mock_http_response) @@ -76,7 +76,7 @@ it "should be seconds remaining from expiration time inferred from Expires header" do cache_headers = { cache_control: "public", expires: (Time.now + 900).httpdate } headers = cache_headers.merge(date: Time.now.httpdate) - mock_http_response = stub(body: "A Response body", code: 200, headers: headers) + mock_http_response = stub(body: "A Response body", code: 200, headers:) Timecop.travel(12 * 60) do response = GdsApi::Response.new(mock_http_response) diff --git a/test/support_api_test.rb b/test/support_api_test.rb index 055e36ef..7e2391d8 100644 --- a/test/support_api_test.rb +++ b/test/support_api_test.rb @@ -100,7 +100,7 @@ stub_get = stub_support_api_anonymous_feedback_organisation_summary(slug, ordering) - @api.organisation_summary(slug, ordering: ordering) + @api.organisation_summary(slug, ordering:) assert_requested(stub_get) end @@ -194,7 +194,7 @@ stub_get = stub_support_api_anonymous_feedback_doc_type_summary(document_type, ordering) - @api.document_type_summary(document_type, ordering: ordering) + @api.document_type_summary(document_type, ordering:) assert_requested(stub_get) end diff --git a/test/test_helpers/email_alert_api_test.rb b/test/test_helpers/email_alert_api_test.rb index 915d5521..e66f0be8 100644 --- a/test/test_helpers/email_alert_api_test.rb +++ b/test/test_helpers/email_alert_api_test.rb @@ -28,13 +28,13 @@ it "stubs with a single subscription by default" do stub_email_alert_api_has_subscriber_subscriptions(id, address) - result = email_alert_api.get_subscriptions(id: id) + result = email_alert_api.get_subscriptions(id:) assert_equal(1, result["subscriptions"].count) end it "stubs subscriptions with an optional ordering" do stub_email_alert_api_has_subscriber_subscriptions(id, address, "-title") - result = email_alert_api.get_subscriptions(id: id, order: "-title") + result = email_alert_api.get_subscriptions(id:, order: "-title") assert_equal(1, result["subscriptions"].count) end @@ -45,7 +45,7 @@ subscriptions: %w[one two], ) - result = email_alert_api.get_subscriptions(id: id) + result = email_alert_api.get_subscriptions(id:) assert_equal(2, result["subscriptions"].count) end end