Skip to content

Commit

Permalink
Upgrade app configuration to Rails 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetrino committed Jan 19, 2024
1 parent 0e9185e commit 5b06d83
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require "fileutils"
APP_ROOT = File.expand_path("..", __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
system(*args, exception: true)
end

FileUtils.chdir APP_ROOT do
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
module GovernmentFrontend
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
config.load_defaults 7.1

# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
Expand Down
2 changes: 1 addition & 1 deletion config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require "bundler/setup" # Set up gems listed in the Gemfile.
require "bootsnap/setup"
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
7 changes: 5 additions & 2 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
config.enable_reloading = true

# Do not eager load code on boot.
config.eager_load = false
Expand Down Expand Up @@ -46,7 +46,7 @@
config.assets.quiet = true

# Raises error for missing translations.
config.i18n.raise_on_missing_translations = true
# config.i18n.raise_on_missing_translations = true

# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
Expand All @@ -55,4 +55,7 @@

# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true

# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true
end
8 changes: 6 additions & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Settings specified here will take precedence over those in config/application.rb.

# Code is not reloaded between requests.
config.cache_classes = true
config.enable_reloading = false

# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
Expand All @@ -30,7 +30,7 @@
# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
# Do not fall back to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

# Rather than use a CSS compressor, use the SASS style to perform compression.
Expand All @@ -44,6 +44,10 @@
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX

# Assume all access to the app is happening through a SSL-terminating reverse proxy.
# Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
# config.assume_ssl = true

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true

Expand Down
16 changes: 10 additions & 6 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# Turn false under Spring and add config.action_view.cache_template_loading = true.
config.cache_classes = true
# While tests run files are not watched, reloading is not necessary.
config.enable_reloading = false

# Eager loading loads your whole application. When running a single test locally,
# this probably isn't necessary. It's a good idea to do in a continuous integration
# system, or in some way before deploying your code.
# Eager loading loads your entire application. When running a single test locally,
# this is usually not necessary, and can slow down your test suite. However, it's
# recommended that you enable it in continuous integration systems to ensure eager
# loading is working properly before deploying your code.
config.eager_load = ENV["CI"].present?

# Configure public file server for tests with Cache-Control for performance.
Expand Down Expand Up @@ -43,8 +44,11 @@
config.active_support.disallowed_deprecation_warnings = []

# Raises error for missing translations.
config.i18n.raise_on_missing_translations = true
# config.i18n.raise_on_missing_translations = true

# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true

# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true
end
14 changes: 7 additions & 7 deletions test/integration/how_government_works_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ class HowGovernmentWorksTest < ActionDispatch::IntegrationTest
test "includes the count of ministers" do
setup_and_visit_content_item("reshuffle-mode-off")

assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig("details", "ministerial_role_counts", "prime_minister")}.+Prime Minister/m)
assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig("details", "ministerial_role_counts", "cabinet_ministers")}.+Cabinet ministers/m)
assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig("details", "ministerial_role_counts", "other_ministers")}.+Other ministers/m)
assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig("details", "ministerial_role_counts", "total_ministers")}.+Total ministers/m)
assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig('details', 'ministerial_role_counts', 'prime_minister')}.+Prime Minister/m)
assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig('details', 'ministerial_role_counts', 'cabinet_ministers')}.+Cabinet ministers/m)
assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig('details', 'ministerial_role_counts', 'other_ministers')}.+Other ministers/m)
assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig('details', 'ministerial_role_counts', 'total_ministers')}.+Total ministers/m)
end

test "includes the count of departments" do
setup_and_visit_content_item("reshuffle-mode-off")

assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig("details", "department_counts", "ministerial_departments")}.+Ministerial departments/m)
assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig("details", "department_counts", "non_ministerial_departments")}.+Non-ministerial departments/m)
assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig("details", "department_counts", "agencies_and_other_public_bodies")}.+Agencies and other public bodies/m)
assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig('details', 'department_counts', 'ministerial_departments')}.+Ministerial departments/m)
assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig('details', 'department_counts', 'non_ministerial_departments')}.+Non-ministerial departments/m)
assert page.has_selector?(".gem-c-big-number", text: /#{@content_item.dig('details', 'department_counts', 'agencies_and_other_public_bodies')}.+Agencies and other public bodies/m)
end

test "does not include the count of ministers during a reshuffle" do
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def assert_has_publisher_metadata_other(any_args)

def assert_has_metadata(any_args, extra_metadata_classes: nil)
within ".gem-c-metadata#{extra_metadata_classes}" do
any_args.each do |_key, value|
any_args.each_value do |value|
value = { value => nil } if value.is_a?(String)
value.each do |text, href|
if href
Expand Down

0 comments on commit 5b06d83

Please sign in to comment.