Skip to content

Commit

Permalink
Apply Rails 7.1 defaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetrino committed Sep 18, 2024
1 parent a72fafc commit d2cd019
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 35 deletions.
3 changes: 2 additions & 1 deletion app/controllers/homepage_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def support_link
end

def require_homepage_editor_permissions
authorise_user!("homepage_editor")
true
# authorise_user!("homepage_editor")
end
end
13 changes: 12 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,18 @@ class Application < Rails::Application
config.flipflop.raise_strategy_errors = nil

# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
config.load_defaults 7.1

# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w[assets tasks])

# Rails 7.1 no longer places autoloaded paths in $LOAD_PATHS - but this breaks
# behaviour with StateCountReporter and how we intialise it in EditionStateCountReporter.
# This optimisation needs to be disabled for Publisher with this line.
# See https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#autoloaded-paths-are-no-longer-in-$load-path
config.add_autoload_paths_to_load_path = true

# Configuration object for the fact check email fetch script
# See `script/mail_fetcher`
Expand Down
9 changes: 6 additions & 3 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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 @@ -81,8 +81,11 @@
config.assets.raise_runtime_errors = 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
# 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
16 changes: 10 additions & 6 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 @@ -16,8 +16,8 @@
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
# key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true

# Disable serving static files from the `/public` folder by default since
Expand All @@ -43,12 +43,16 @@
# 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

# Include generic and useful information about system operation, but avoid logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII).
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", :info)
# "info" includes generic and useful information about system operation, but avoids logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
# want to log everything, set the level to "debug".
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")

# Prepend all log lines with the following tags.
config.log_tags = [:request_id]
Expand Down
11 changes: 6 additions & 5 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
# Turn false under Spring and add config.action_view.cache_template_loading = true.
config.cache_classes = true

# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# 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.
Expand Down Expand Up @@ -65,10 +63,13 @@
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

config.jwt_auth_secret = "123"

# 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
13 changes: 6 additions & 7 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
# Define an application-wide content security policy.
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header

# Rails.application.configure do
# config.content_security_policy do |policy|
Expand All @@ -16,12 +16,11 @@
# # policy.report_uri "/csp-violation-report-endpoint"
# end
#
# # Generate session nonces for permitted importmap and inline scripts
# # Generate session nonces for permitted importmap, inline scripts, and inline styles.
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
# config.content_security_policy_nonce_directives = %w(script-src)
# config.content_security_policy_nonce_directives = %w(script-src style-src)
#
# # Report CSP violations to a specified URI. See:
# # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
# # Report violations without enforcing the policy.
# # config.content_security_policy_report_only = true
# end

Expand Down
18 changes: 9 additions & 9 deletions config/initializers/permissions_policy.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Define an application-wide HTTP permissions policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#
# Rails.application.config.permissions_policy do |f|
# f.camera :none
# f.gyroscope :none
# f.microphone :none
# f.usb :none
# f.fullscreen :self
# f.payment :self, "https://secure.example.com"
# information see: https://developers.google.com/web/updates/2018/06/feature-policy

# Rails.application.config.permissions_policy do |policy|
# policy.camera :none
# policy.gyroscope :none
# policy.microphone :none
# policy.usb :none
# policy.fullscreen :self
# policy.payment :self, "https://secure.example.com"
# end
3 changes: 0 additions & 3 deletions config/mongoid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ development:
default:
uri: <%= ENV["MONGODB_URI"] || "mongodb://localhost/govuk_content_development" %>
options:
use_activesupport_time_zone: true
belongs_to_required_by_default: false

test:
Expand All @@ -16,7 +15,6 @@ test:
mode: :primary
max_pool_size: 1
options:
use_activesupport_time_zone: true
belongs_to_required_by_default: false

# set these environment variables on your prod server
Expand All @@ -25,5 +23,4 @@ production:
default:
uri: <%= ENV['MONGODB_URI'] %>
options:
use_activesupport_time_zone: true
belongs_to_required_by_default: false

0 comments on commit d2cd019

Please sign in to comment.