Skip to content

Commit

Permalink
Merge pull request #2545 from alphagov/ruby-3-1-2
Browse files Browse the repository at this point in the history
Upgrade Ruby to 3.1.2
  • Loading branch information
AgaDufrat authored Oct 11, 2022
2 parents 75a3fa2 + 8f1a5d4 commit f357105
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.6
3.1.2
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG base_image=ghcr.io/alphagov/govuk-ruby-base:2.7.6
ARG builder_image=ghcr.io/alphagov/govuk-ruby-builder:2.7.6
ARG base_image=ghcr.io/alphagov/govuk-ruby-base:3.1.2
ARG builder_image=ghcr.io/alphagov/govuk-ruby-builder:3.1.2

FROM $builder_image AS builder

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ gem "plek"
gem "rack_strip_client_ip"
gem "rails-controller-testing"
gem "rails-i18n"
gem "rss"
gem "sassc-rails"
gem "slimmer"
gem "sprockets-rails"
Expand Down
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ GEM
netrc (~> 0.8)
rexml (3.2.5)
rouge (4.0.0)
rss (0.2.9)
rexml
rubocop (1.35.0)
json (~> 2.3)
parallel (~> 1.10)
Expand Down Expand Up @@ -412,6 +414,7 @@ DEPENDENCIES
rails-controller-testing
rails-i18n
rails_translation_manager
rss
rubocop-govuk
sassc-rails
simplecov
Expand All @@ -422,4 +425,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
2.1.4
2.3.22
2 changes: 1 addition & 1 deletion app/presenters/contact_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def phone_numbers_in_group(group)

def v_card_part(v_card_class, value)
{
v_card_class: v_card_class,
v_card_class:,
value: value.try(:strip).try(:html_safe),
}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def further_information_link(type)

def further_information_about(type)
link = further_information_link(type)
I18n.t("corporate_information_page.#{type}_html", link: link) if link
I18n.t("corporate_information_page.#{type}_html", link:) if link
end

def corporate_information_heading
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/content_item/manual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ def page_title
title += " - " if title.present?

if hmrc?
I18n.t("manuals.hmrc_title", title: title)
I18n.t("manuals.hmrc_title", title:)
else
I18n.t("manuals.title", title: title)
I18n.t("manuals.title", title:)
end
end
alias_method :manual_page_title, :page_title
Expand All @@ -29,7 +29,7 @@ def body

def manual_metadata
{
from: from,
from:,
first_published: published,
other: other_metadata,
inverse: true,
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/content_item/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ module Metadata

def metadata
{
from: from,
from:,
first_published: published,
last_updated: updated,
see_updates_link: true,
part_of: part_of,
part_of:,
direction: text_direction,
other: {},
}
Expand All @@ -21,7 +21,7 @@ def important_metadata

def publisher_metadata
{
from: from,
from:,
first_published: published,
last_updated: updated,
see_updates_link: true,
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/content_item/title_and_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ContentItem
module TitleAndContext
def title_and_context
{
title: title,
title:,
context: I18n.t("content_item.schema_name.#{document_type}", count: 1),
context_locale: view_context.t_locale_fallback("content_item.schema_name.#{document_type}", count: 1),
average_title_length: "long",
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/content_item/withdrawable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def withdrawal_notice_time
end

def english_display_date(timestamp, format = "%-d %B %Y")
I18n.l(Time.zone.parse(timestamp), format: format, locale: :en) if timestamp
I18n.l(Time.zone.parse(timestamp), format:, locale: :en) if timestamp
end
end
end
4 changes: 2 additions & 2 deletions app/presenters/content_item_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def voting_is_open?
end

def display_date(timestamp, format = "%-d %B %Y")
I18n.l(Time.zone.parse(timestamp), format: format, locale: "en") if timestamp
I18n.l(Time.zone.parse(timestamp), format:, locale: "en") if timestamp
end

def sorted_locales(translations)
Expand All @@ -135,6 +135,6 @@ def text_direction
end

def native_language_name_for(locale)
I18n.t("language_names.#{locale}", locale: locale)
I18n.t("language_names.#{locale}", locale:)
end
end
2 changes: 1 addition & 1 deletion app/presenters/travel_advice_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def metadata
other["Latest update"] = view_context.simple_format(latest_update, { class: "metadata__update" }, wrapper_tag: "span") if latest_update.present?

{
other: other,
other:,
}
end

Expand Down
2 changes: 1 addition & 1 deletion test/component_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def component_name
end

def render_component(locals)
render partial: "components/#{component_name}", locals: locals
render partial: "components/#{component_name}", locals:
end
end
12 changes: 6 additions & 6 deletions test/controllers/content_items_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ class ContentItemsControllerTest < ActionController::TestCase
test "renders translated content items in their locale" do
content_item = content_store_has_schema_example("case_study", "translated")
locale = content_item["locale"]
translated_schema_name = I18n.t("content_item.schema_name.case_study", count: 1, locale: locale)
translated_schema_name = I18n.t("content_item.schema_name.case_study", count: 1, locale:)

get :show, params: { path: path_for(content_item, locale), locale: locale }
get :show, params: { path: path_for(content_item, locale), locale: }

assert_response :success
assert_select "title", %r{#{translated_schema_name}}
Expand Down Expand Up @@ -296,7 +296,7 @@ class ContentItemsControllerTest < ActionController::TestCase

stub_content_store_does_not_have_item("/#{path}")

get :show, params: { path: path }
get :show, params: { path: }
assert_response :not_found
end

Expand All @@ -305,7 +305,7 @@ class ContentItemsControllerTest < ActionController::TestCase

stub_content_store_does_not_have_item("/#{path}")

get :show, params: { path: path }
get :show, params: { path: }
assert_response :not_found
end

Expand All @@ -317,7 +317,7 @@ class ContentItemsControllerTest < ActionController::TestCase

stub_content_store_has_item("/#{path}", content_item)

get :show, params: { path: path }
get :show, params: { path: }
assert_response :not_found
end

Expand All @@ -326,7 +326,7 @@ class ContentItemsControllerTest < ActionController::TestCase
url = "#{content_store_endpoint}/content/#{path}"
stub_request(:get, url).to_return(status: 403, headers: {})

get :show, params: { path: path }
get :show, params: { path: }
assert_response :forbidden
end

Expand Down
8 changes: 4 additions & 4 deletions test/controllers/get_involved_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def setup
title = "Next closing consultation on time zones"
stub_search_query(query: hash_including(filter_content_store_document_type: "open_consultation",
filter_end_date: "from: #{Time.zone.now.to_date}"),
response: { "results" => [consultation_result(title: title)] })
response: { "results" => [consultation_result(title:)] })

get :show
assert_select ".gem-c-inset-text", /#{title}/
Expand All @@ -72,7 +72,7 @@ def setup
test "showing recently opened consultations" do
title = "Open consultation on time zones"
stub_search_query(query: hash_including(filter_content_store_document_type: "open_consultation"),
response: { "results" => [consultation_result(title: title)] })
response: { "results" => [consultation_result(title:)] })

get :show
assert response.body.include?(title)
Expand All @@ -81,7 +81,7 @@ def setup
test "showing recent consultation outcomes" do
title = "Consultation outcome on time zones"
stub_search_query(query: hash_including(filter_content_store_document_type: "consultation_outcome"),
response: { "results" => [consultation_result(title: title)] })
response: { "results" => [consultation_result(title:)] })

get :show
assert response.body.include?(title)
Expand All @@ -97,7 +97,7 @@ def setup

def stub_search_query(query:, response:)
stub_request(:get, /\A#{Plek.new.find('search')}\/search.json/)
.with(query: query)
.with(query:)
.to_return(body: response.to_json)
end

Expand Down
14 changes: 7 additions & 7 deletions test/controllers/service_sign_in_content_item_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ContentItemsControllerTest < ActionController::TestCase

stub_request(:get, %r{#{path}}).to_return(status: 200, body: content_item.to_json, headers: {})

get :show, params: { path: path }
get :show, params: { path: }

assert_template :service_sign_in
end
Expand All @@ -46,14 +46,14 @@ class ContentItemsControllerTest < ActionController::TestCase

stub_request(:get, %r{#{path}}).to_return(status: 200, body: content_item.to_json, headers: {})

get :show, params: { path: path }
get :show, params: { path: }

assert_template :service_sign_in
end

test "raises a 404 for a content item which isn't a service_sign_in page" do
path = "this/is/not/a/sign/in/page"
post :service_sign_in_options, params: { path: path }
post :service_sign_in_options, params: { path: }
assert_response :not_found
end

Expand All @@ -67,7 +67,7 @@ class ContentItemsControllerTest < ActionController::TestCase

stub_request(:get, %r{#{path}}).to_return(status: 200, body: content_item.to_json, headers: {})

post :service_sign_in_options, params: { path: path, option: value }
post :service_sign_in_options, params: { path:, option: value }

assert_response :redirect
assert_redirected_to link
Expand All @@ -79,7 +79,7 @@ class ContentItemsControllerTest < ActionController::TestCase

stub_request(:get, %r{#{path}}).to_return(status: 200, body: content_item.to_json, headers: {})

post :service_sign_in_options, params: { path: path }
post :service_sign_in_options, params: { path: }

assert_not_nil @controller.instance_variable_get(:@error)
assert_template :service_sign_in
Expand All @@ -93,7 +93,7 @@ class ContentItemsControllerTest < ActionController::TestCase

stub_request(:get, %r{#{path}}).to_return(status: 200, body: content_item.to_json, headers: {})

post :service_sign_in_options, params: { path: path, option: option }
post :service_sign_in_options, params: { path:, option: }

assert_not_nil @controller.instance_variable_get(:@error)
assert_template :service_sign_in
Expand All @@ -112,7 +112,7 @@ class ContentItemsControllerTest < ActionController::TestCase

stub_request(:get, %r{#{path}}).to_return(status: 200, body: content_item.to_json, headers: {})

post :service_sign_in_options, params: { path: path, _ga: "1.1111111.1111111.111111111", option: value }
post :service_sign_in_options, params: { path:, _ga: "1.1111111.1111111.111111111", option: value }

assert_response :redirect
assert_redirected_to "https://www.horse.service.gov.uk/account?horse=brown&_ga=1.1111111.1111111.111111111"
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/step_navigation_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ContentItemsControllerTest < ActionController::TestCase

@controller.stubs(:page_in_scope?).returns(false)

get :show, params: { path: path }
get :show, params: { path: }

assert_response 200
assert response.body.include?("Learn to drive a car: step by step")
Expand All @@ -28,7 +28,7 @@ class ContentItemsControllerTest < ActionController::TestCase

@controller.stubs(:page_in_scope?).returns(false)

get :show, params: { path: path }
get :show, params: { path: }

assert_response 200
assert_not response.body.include?("Learn to drive a car: step by step")
Expand Down
2 changes: 1 addition & 1 deletion test/integration/specialist_document_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def assert_nested_content_item(heading)

if heading_level < 4
assert page.has_css?(selector), "Failed to find an element matching: #{selector}"
assert page.has_css?(selector, text: text), "Failed to find an element matching #{selector} with text: #{text}"
assert page.has_css?(selector, text:), "Failed to find an element matching #{selector} with text: #{text}"
else
assert_not page.has_css?(selector), "Found a nested heading too deep, there should be no element matching: #{selector}"
end
Expand Down
2 changes: 1 addition & 1 deletion test/support/govuk_content_schema_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def content_store_has_schema_example(schema_name, example_name)
end

def govuk_content_schema_example(schema_name, example_name)
GovukSchemas::Example.find(schema_name, example_name: example_name)
GovukSchemas::Example.find(schema_name, example_name:)
end

module ClassMethods
Expand Down
10 changes: 5 additions & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def assert_has_contents_list(contents)
selector = "a[href=\"##{heading[:id]}\"]"
text = heading.fetch(:text)
assert page.has_css?(selector), "Failed to find an element matching: #{selector}"
assert page.has_css?(selector, text: text), "Failed to find an element matching #{selector} with text: #{text}"
assert page.has_css?(selector, text:), "Failed to find an element matching #{selector} with text: #{text}"
end
end
end
Expand Down Expand Up @@ -105,7 +105,7 @@ def assert_has_metadata(any_args, extra_metadata_classes: nil)
value = { value => nil } if value.is_a?(String)
value.each do |text, href|
if href
assert page.has_link?(text, href: href), "Metadata text '#{text} with link of #{href}' not found"
assert page.has_link?(text, href:), "Metadata text '#{text} with link of #{href}' not found"
else
assert page.has_text?(text), "Metadata value '#{text}' not found"
end
Expand All @@ -120,9 +120,9 @@ def assert_has_metadata_local(metadata, term_selector, definition_selector)
"Metadata term '#{key}' not found"
value = { value => nil } if value.is_a?(String)
value.each do |text, href|
within(definition_selector, text: text) do
within(definition_selector, text:) do
if href
assert page.has_link?(text, href: href), "Metadata link '#{text}' not found"
assert page.has_link?(text, href:), "Metadata link '#{text}' not found"
else
assert page.has_text?(text), "Metadata value '#{text}' not found"
end
Expand Down Expand Up @@ -156,7 +156,7 @@ def assert_has_devolved_nations_component(text, nations = nil)
end

def assert_footer_has_published_dates(first_published = nil, last_updated = nil, history_link: false)
assert_has_published_dates(first_published, last_updated, history_link: history_link)
assert_has_published_dates(first_published, last_updated, history_link:)
end

def setup_and_visit_content_item(name, parameter_string = "")
Expand Down

0 comments on commit f357105

Please sign in to comment.