From 5f8db67cc02250af4a8896fa47bd48731cbf5540 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Fri, 29 Mar 2024 02:34:45 +0100
Subject: [PATCH 01/22] Make Apartment compatible with Rails 7
The `database:` argument from the `connected_to` method was deprecated
in Rails 6.1 [1] and removed in Rails 7.0 [2]. The ros-apartement gem
has already introduced fixes for this issue [3][4], but there has been
no release including these fixes.
So we're applying the fix in our code.
Note that, since Apartment already overwrites the `connected_to` method
by creating a `connected_to_with_tenant` method, we're calling the
`connected_to_without_tenant` method inside the patch, which is
equivalent to ActiveRecord's original `connected_to`.
[1] Pull request 37874 in https://github.com/rails/rails
[2] Pull request 40530 in https://github.com/rails/rails/pull
[3] Pull request 194 in https://github.com/rails-on-services/apartment
[4] Pull request 243 in https://github.com/rails-on-services/apartment
---
Gemfile | 2 +-
config/initializers/apartment.rb | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/Gemfile b/Gemfile
index 7514d7801..82f6831d6 100644
--- a/Gemfile
+++ b/Gemfile
@@ -46,7 +46,7 @@ gem "recipient_interceptor", "~> 0.3.1"
gem "redcarpet", "~> 3.6.0"
gem "responders", "~> 3.1.1"
gem "rinku", "~> 2.0.6", require: "rails_rinku"
-gem "ros-apartment", "~> 2.11.0", require: "apartment"
+gem "ros-apartment", "~> 2.11.0", require: "apartment" # Remove ConnectionHandling monkey patch when upgrading
gem "sassc-embedded", "~> 1.70.1"
gem "sassc-rails", "~> 2.1.2"
gem "savon", "~> 2.15.0"
diff --git a/config/initializers/apartment.rb b/config/initializers/apartment.rb
index cda7ae581..e5d0a5110 100644
--- a/config/initializers/apartment.rb
+++ b/config/initializers/apartment.rb
@@ -1,3 +1,20 @@
+module ActiveRecord # TODO: Remove after upgrading ros-apartment
+ # Code based on the current (as of March 2024) development version of the apartment gem
+ module ConnectionHandling
+ def connected_to_with_rails7_tenant(role: nil, prevent_writes: false, &blk)
+ current_tenant = Apartment::Tenant.current
+
+ # The connected_to_without_tenant method is defined by Apartment
+ connected_to_without_tenant(role: role, prevent_writes: prevent_writes) do
+ Apartment::Tenant.switch!(current_tenant)
+ yield(blk)
+ end
+ end
+
+ alias connected_to connected_to_with_rails7_tenant
+ end
+end
+
# You can have Apartment route to the appropriate Tenant by adding some Rack middleware.
# Apartment can support many different "Elevators" that can take care of this routing to your data.
# Require whichever Elevator you're using below or none if you have a custom one.
From 8596f1539f977a6eab863c3854f92d634f0190f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Fri, 22 Mar 2024 23:48:20 +0100
Subject: [PATCH 02/22] Upgrade to Rails 7.0
The config.file_watcher option still exists but it's no longer included
in the default environtment file. Since we don't use it, we're removing
it.
The config.assets.assets.debug option is no longer true by default [1],
so it isn't included anymore.
The config.active_support.deprecation option is now omitted on
production in favor of config.active_support.report_deprecations, which
is false by default. I think it's OK to keep it this way, since we check
deprecations in the development and test environments but never on
production environments.
As mentioned in the Rails upgrade guide, sprockets-rails is no longer a
rails dependency and we need to explicitly include it in our Gemfile.
The behavior of queries trying to find an invalid enum value has changed
[2], so we're updating the tests accordingly.
The `favicon_link_tag` method has removed the deprecated `shortcut`
link type [3], so we're updating the tests accordingly.
The method `raw_filter` in ActiveSupport callbacks has been renamed to
`filter` [4], so we're updating the code accordingly.
[1] https://github.com/rails/rails/commit/adec7e7ba87e3
[2] https://github.com/rails/rails/commit/b68f0954
[3] Pull request 43850 in https://github.com/rails/rails
[4] Pull request 41598 in https://github.com/rails/rails
---
.rubocop.yml | 3 -
Gemfile | 3 +-
Gemfile.lock | 127 ++--
app/models/concerns/skip_validation.rb | 4 +-
config/application.rb | 1 -
config/environments/development.rb | 13 +-
config/environments/production.rb | 38 +-
config/environments/test.rb | 7 +-
.../01_filter_parameter_logging.rb | 4 +-
.../initializers/content_security_policy.rb | 45 +-
config/initializers/inflections.rb | 8 +-
.../new_framework_defaults_7_0.rb | 143 ++++
...e_storage_blobs_checksum.active_storage.rb | 8 +
db/schema.rb | 625 +++++++++---------
spec/models/sdg/phase_spec.rb | 2 +-
spec/system/site_customization/images_spec.rb | 2 +-
16 files changed, 578 insertions(+), 455 deletions(-)
create mode 100644 config/initializers/new_framework_defaults_7_0.rb
create mode 100644 db/migrate/20240322223950_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb
diff --git a/.rubocop.yml b/.rubocop.yml
index 61a117f97..9fffe97aa 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -374,9 +374,6 @@ Rails/CreateTableWithTimestamps:
Rails/Date:
Enabled: true
-Rails/DeprecatedActiveModelErrorsMethods: # TODO: Remove after upgrading to Rails 7
- Enabled: true
-
Rails/DurationArithmetic:
Enabled: true
diff --git a/Gemfile b/Gemfile
index 82f6831d6..8c90f3c4b 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,6 @@
source "https://rubygems.org"
-gem "rails", "6.1.7.7"
+gem "rails", "7.0.8.1"
gem "acts-as-taggable-on", "~> 10.0.0"
gem "acts_as_votable", "~> 0.14.0"
@@ -53,6 +53,7 @@ gem "savon", "~> 2.15.0"
gem "sitemap_generator", "~> 6.3.0"
gem "social-share-button", "~> 1.2.4"
gem "sprockets", "~> 4.2.1"
+gem "sprockets-rails", "~> 3.4.2", require: "sprockets/railtie"
gem "turbolinks", "~> 5.2.1"
gem "turnout", "~> 2.5.0"
gem "uglifier", "~> 4.2.0"
diff --git a/Gemfile.lock b/Gemfile.lock
index 538c88148..bd616810e 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -2,65 +2,71 @@ GEM
remote: https://rubygems.org/
specs:
Ascii85 (1.1.0)
- actioncable (6.1.7.7)
- actionpack (= 6.1.7.7)
- activesupport (= 6.1.7.7)
+ actioncable (7.0.8.1)
+ actionpack (= 7.0.8.1)
+ activesupport (= 7.0.8.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
- actionmailbox (6.1.7.7)
- actionpack (= 6.1.7.7)
- activejob (= 6.1.7.7)
- activerecord (= 6.1.7.7)
- activestorage (= 6.1.7.7)
- activesupport (= 6.1.7.7)
+ actionmailbox (7.0.8.1)
+ actionpack (= 7.0.8.1)
+ activejob (= 7.0.8.1)
+ activerecord (= 7.0.8.1)
+ activestorage (= 7.0.8.1)
+ activesupport (= 7.0.8.1)
mail (>= 2.7.1)
- actionmailer (6.1.7.7)
- actionpack (= 6.1.7.7)
- actionview (= 6.1.7.7)
- activejob (= 6.1.7.7)
- activesupport (= 6.1.7.7)
+ net-imap
+ net-pop
+ net-smtp
+ actionmailer (7.0.8.1)
+ actionpack (= 7.0.8.1)
+ actionview (= 7.0.8.1)
+ activejob (= 7.0.8.1)
+ activesupport (= 7.0.8.1)
mail (~> 2.5, >= 2.5.4)
+ net-imap
+ net-pop
+ net-smtp
rails-dom-testing (~> 2.0)
- actionpack (6.1.7.7)
- actionview (= 6.1.7.7)
- activesupport (= 6.1.7.7)
- rack (~> 2.0, >= 2.0.9)
+ actionpack (7.0.8.1)
+ actionview (= 7.0.8.1)
+ activesupport (= 7.0.8.1)
+ rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
- actiontext (6.1.7.7)
- actionpack (= 6.1.7.7)
- activerecord (= 6.1.7.7)
- activestorage (= 6.1.7.7)
- activesupport (= 6.1.7.7)
+ actiontext (7.0.8.1)
+ actionpack (= 7.0.8.1)
+ activerecord (= 7.0.8.1)
+ activestorage (= 7.0.8.1)
+ activesupport (= 7.0.8.1)
+ globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
- actionview (6.1.7.7)
- activesupport (= 6.1.7.7)
+ actionview (7.0.8.1)
+ activesupport (= 7.0.8.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
- activejob (6.1.7.7)
- activesupport (= 6.1.7.7)
+ activejob (7.0.8.1)
+ activesupport (= 7.0.8.1)
globalid (>= 0.3.6)
- activemodel (6.1.7.7)
- activesupport (= 6.1.7.7)
- activerecord (6.1.7.7)
- activemodel (= 6.1.7.7)
- activesupport (= 6.1.7.7)
- activestorage (6.1.7.7)
- actionpack (= 6.1.7.7)
- activejob (= 6.1.7.7)
- activerecord (= 6.1.7.7)
- activesupport (= 6.1.7.7)
+ activemodel (7.0.8.1)
+ activesupport (= 7.0.8.1)
+ activerecord (7.0.8.1)
+ activemodel (= 7.0.8.1)
+ activesupport (= 7.0.8.1)
+ activestorage (7.0.8.1)
+ actionpack (= 7.0.8.1)
+ activejob (= 7.0.8.1)
+ activerecord (= 7.0.8.1)
+ activesupport (= 7.0.8.1)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
- activesupport (6.1.7.7)
+ activesupport (7.0.8.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
- zeitwerk (~> 2.3)
acts-as-taggable-on (10.0.0)
activerecord (>= 6.1, < 7.2)
acts_as_votable (0.14.0)
@@ -91,7 +97,7 @@ GEM
execjs (~> 2)
base64 (0.1.1)
bcrypt (3.1.20)
- better_html (2.0.2)
+ better_html (2.1.1)
actionview (>= 6.0)
activesupport (>= 6.0)
ast (~> 2.0)
@@ -460,21 +466,20 @@ GEM
rack
rack-test (2.1.0)
rack (>= 1.3)
- rails (6.1.7.7)
- actioncable (= 6.1.7.7)
- actionmailbox (= 6.1.7.7)
- actionmailer (= 6.1.7.7)
- actionpack (= 6.1.7.7)
- actiontext (= 6.1.7.7)
- actionview (= 6.1.7.7)
- activejob (= 6.1.7.7)
- activemodel (= 6.1.7.7)
- activerecord (= 6.1.7.7)
- activestorage (= 6.1.7.7)
- activesupport (= 6.1.7.7)
+ rails (7.0.8.1)
+ actioncable (= 7.0.8.1)
+ actionmailbox (= 7.0.8.1)
+ actionmailer (= 7.0.8.1)
+ actionpack (= 7.0.8.1)
+ actiontext (= 7.0.8.1)
+ actionview (= 7.0.8.1)
+ activejob (= 7.0.8.1)
+ activemodel (= 7.0.8.1)
+ activerecord (= 7.0.8.1)
+ activestorage (= 7.0.8.1)
+ activesupport (= 7.0.8.1)
bundler (>= 1.15.0)
- railties (= 6.1.7.7)
- sprockets-rails (>= 2.0.0)
+ railties (= 7.0.8.1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
@@ -482,15 +487,16 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
- rails-i18n (6.0.0)
+ rails-i18n (7.0.9)
i18n (>= 0.7, < 2)
- railties (>= 6.0.0, < 7)
- railties (6.1.7.7)
- actionpack (= 6.1.7.7)
- activesupport (= 6.1.7.7)
+ railties (>= 6.0.0, < 8)
+ railties (7.0.8.1)
+ actionpack (= 7.0.8.1)
+ activesupport (= 7.0.8.1)
method_source
rake (>= 12.2)
thor (~> 1.0)
+ zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.1.0)
rbtree3 (0.7.1)
@@ -752,7 +758,7 @@ DEPENDENCIES
pronto-rubocop (~> 0.11.5)
pronto-stylelint (~> 0.10.3)
puma (~> 5.6.8)
- rails (= 6.1.7.7)
+ rails (= 7.0.8.1)
recipient_interceptor (~> 0.3.1)
redcarpet (~> 3.6.0)
responders (~> 3.1.1)
@@ -776,6 +782,7 @@ DEPENDENCIES
social-share-button (~> 1.2.4)
spring (~> 4.1.3)
sprockets (~> 4.2.1)
+ sprockets-rails (~> 3.4.2)
turbolinks (~> 5.2.1)
turnout (~> 2.5.0)
uglifier (~> 4.2.0)
diff --git a/app/models/concerns/skip_validation.rb b/app/models/concerns/skip_validation.rb
index 7c1a3c549..214b67e21 100644
--- a/app/models/concerns/skip_validation.rb
+++ b/app/models/concerns/skip_validation.rb
@@ -12,8 +12,8 @@ module SkipValidation
_validators[field].reject! { |existing_validator| existing_validator.is_a?(validator_class) }
_validate_callbacks.each do |callback|
- if callback.raw_filter.is_a?(validator_class)
- callback.raw_filter.instance_variable_set(:@attributes, callback.raw_filter.attributes - [field])
+ if callback.filter.is_a?(validator_class)
+ callback.filter.instance_variable_set(:@attributes, callback.filter.attributes - [field])
end
end
end
diff --git a/config/application.rb b/config/application.rb
index a4cc6006b..ae3ef7b8f 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -13,7 +13,6 @@ require "action_mailer/railtie"
# require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
-require "sprockets/railtie"
require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
diff --git a/config/environments/development.rb b/config/environments/development.rb
index df04c5583..ab669e80b 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -15,9 +15,12 @@ Rails.application.configure do
# Show full error reports.
config.consider_all_requests_local = true
+ # Enable server timing
+ config.server_timing = true
+
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
- if Rails.root.join("tmp", "caching-dev.txt").exist?
+ if Rails.root.join("tmp/caching-dev.txt").exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
@@ -58,11 +61,6 @@ Rails.application.configure do
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
- # Debug mode disables concatenation and preprocessing of assets.
- # This option may cause significant delays in view rendering with a large
- # number of complex assets.
- config.assets.debug = false
-
# Suppress logger output for asset requests.
config.assets.quiet = true
@@ -89,9 +87,6 @@ Rails.application.configure do
Bullet.add_footer = true
end
end
- # Use an evented file watcher to asynchronously detect changes in source code,
- # routes, locales, etc. This feature depends on the listen gem.
- # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 57ba25c25..36ee4d03d 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -74,18 +74,13 @@ Rails.application.configure do
config.action_mailer.smtp_settings = Rails.application.secrets.smtp_settings
end
- # Disable locale fallbacks for I18n
- # (prevents using fallback locales set in application.rb).
- # config.i18n.fallbacks = false
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ # (commented because it prevents using fallback locales set in application.rb).
+ # config.i18n.fallbacks = true
- # Send deprecation notices to registered listeners.
- config.active_support.deprecation = :notify
-
- # Log disallowed deprecations.
- config.active_support.disallowed_deprecation = :log
-
- # Tell Active Support which deprecation messages to disallow.
- config.active_support.disallowed_deprecation_warnings = []
+ # Don't log any deprecations.
+ config.active_support.report_deprecations = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
@@ -107,27 +102,6 @@ Rails.application.configure do
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
-
- # Inserts middleware to perform automatic connection switching.
- # The `database_selector` hash is used to pass options to the DatabaseSelector
- # middleware. The `delay` is used to determine how long to wait after a write
- # to send a subsequent read to the primary.
- #
- # The `database_resolver` class is used by the middleware to determine which
- # database is appropriate to use based on the time delay.
- #
- # The `database_resolver_context` class is used by the middleware to set
- # timestamps for the last write to the primary. The resolver uses the context
- # class timestamps to determine how long to wait before reading from the
- # replica.
- #
- # By default Rails will store a last write timestamp in the session. The
- # DatabaseSelector middleware is designed as such you can define your own
- # strategy for connection switching and pass that into the middleware through
- # these configuration options.
- # config.active_record.database_selector = { delay: 2.seconds }
- # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
- # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end
require Rails.root.join("config", "environments", "custom", "production")
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 369978ed2..5c9b0b58d 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -15,11 +15,12 @@ Rails.application.configure do
config.i18n.default_locale = :en
config.i18n.available_locales = %w[de en es fr nl pt-BR zh-CN]
+ # 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.
+ # 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.
config.eager_load = ENV["CI"].present?
# Configure public file server for tests with Cache-Control for performance.
diff --git a/config/initializers/01_filter_parameter_logging.rb b/config/initializers/01_filter_parameter_logging.rb
index 4b34a0366..adc6568ce 100644
--- a/config/initializers/01_filter_parameter_logging.rb
+++ b/config/initializers/01_filter_parameter_logging.rb
@@ -1,6 +1,8 @@
# Be sure to restart your server when you modify this file.
-# Configure sensitive parameters which will be filtered from the log file.
+# Configure parameters to be filtered from the log file. Use this to limit dissemination of
+# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
+# notations and behaviors.
Rails.application.config.filter_parameters += [
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
]
diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb
index 41c43016f..54f47cf15 100644
--- a/config/initializers/content_security_policy.rb
+++ b/config/initializers/content_security_policy.rb
@@ -1,28 +1,25 @@
# 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.config.content_security_policy do |policy|
-# policy.default_src :self, :https
-# policy.font_src :self, :https, :data
-# policy.img_src :self, :https, :data
-# policy.object_src :none
-# policy.script_src :self, :https
-# policy.style_src :self, :https
-
-# # Specify URI for violation reports
-# # policy.report_uri "/csp-violation-report-endpoint"
+# Rails.application.configure do
+# config.content_security_policy do |policy|
+# policy.default_src :self, :https
+# policy.font_src :self, :https, :data
+# policy.img_src :self, :https, :data
+# policy.object_src :none
+# policy.script_src :self, :https
+# policy.style_src :self, :https
+# # Specify URI for violation reports
+# # policy.report_uri "/csp-violation-report-endpoint"
+# end
+#
+# # Generate session nonces for permitted importmap and inline scripts
+# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
+# config.content_security_policy_nonce_directives = %w(script-src)
+#
+# # Report violations without enforcing the policy.
+# # config.content_security_policy_report_only = true
# end
-
-# If you are using UJS then enable automatic nonce generation
-# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
-
-# Set the nonce only to specific directives
-# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
-
-# Report CSP violations to a specified URI
-# For further information see the following documentation:
-# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
-# Rails.application.config.content_security_policy_report_only = true
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
index 17b2717d6..951175208 100644
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -4,15 +4,15 @@
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
-# inflect.plural /^(ox)$/i, '\1en'
-# inflect.singular /^(ox)en/i, '\1'
-# inflect.irregular 'person', 'people'
+# inflect.plural /^(ox)$/i, "\\1en"
+# inflect.singular /^(ox)en/i, "\\1"
+# inflect.irregular "person", "people"
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
-# inflect.acronym 'RESTful'
+# inflect.acronym "RESTful"
# end
ActiveSupport::Inflector.inflections(:en) do |inflect|
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
new file mode 100644
index 000000000..b13ef5ed1
--- /dev/null
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -0,0 +1,143 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file eases your Rails 7.0 framework defaults upgrade.
+#
+# Uncomment each configuration one by one to switch to the new default.
+# Once your application is ready to run with all new defaults, you can remove
+# this file and set the `config.load_defaults` to `7.0`.
+#
+# Read the Guide for Upgrading Ruby on Rails for more info on each option.
+# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
+
+# `button_to` view helper will render `
<% end %>
<% if investment.should_show_ballots? %>
- <%= button_to budget_ballot_line_path(id: investment.id,
+ <%= button_to t("budgets.ballots.show.remove"),
+ budget_ballot_line_path(id: investment.id,
budget_id: investment.budget_id,
investments_ids: investment_ids),
class: "button button-remove-support expanded",
method: :delete,
remote: true,
- "aria-label": remove_vote_aria_label do %>
- <%= t("budgets.ballots.show.remove") %>
- <% end %>
+ "aria-label": remove_vote_aria_label %>
<% end %>
<% else %>
@@ -29,16 +28,15 @@
<% end %>
<% if investment.should_show_ballots? %>
- <%= button_to budget_ballot_lines_path(investment_id: investment.id,
+ <%= button_to t("budgets.investments.investment.add"),
+ budget_ballot_lines_path(investment_id: investment.id,
budget_id: investment.budget_id,
investments_ids: investment_ids),
class: "button button-support expanded",
title: t("budgets.investments.investment.support_title"),
method: :post,
remote: true,
- "aria-label": vote_aria_label do %>
- <%= t("budgets.investments.investment.add") %>
- <% end %>
+ "aria-label": vote_aria_label %>
<% end %>
<% end %>
diff --git a/app/components/budgets/investments/votes_component.html.erb b/app/components/budgets/investments/votes_component.html.erb
index 015e520c9..1d86737db 100644
--- a/app/components/budgets/investments/votes_component.html.erb
+++ b/app/components/budgets/investments/votes_component.html.erb
@@ -12,13 +12,12 @@
<%= t("budgets.investments.votes.already_supported") %>
<% if feature?(:remove_investments_supports) %>
- <%= button_to remove_support_path,
+ <%= button_to t("budgets.investments.votes.remove_support"),
+ remove_support_path,
class: "button button-remove-support expanded",
method: "delete",
remote: true,
- "aria-label": remove_support_aria_label do %>
- <%= t("budgets.investments.votes.remove_support") %>
- <% end %>
+ "aria-label": remove_support_aria_label %>
<% end %>
<% else %>
diff --git a/app/components/polls/questions/answers_component.html.erb b/app/components/polls/questions/answers_component.html.erb
index c73247ec2..c9fc65343 100644
--- a/app/components/polls/questions/answers_component.html.erb
+++ b/app/components/polls/questions/answers_component.html.erb
@@ -2,23 +2,21 @@
<% if can?(:answer, question) && !question.poll.voted_in_booth?(current_user) %>
<% question_answers.each do |question_answer| %>
<% if already_answered?(question_answer) %>
- <%= button_to question_answer_path(question, user_answer(question_answer)),
+ <%= button_to question_answer.title,
+ question_answer_path(question, user_answer(question_answer)),
method: :delete,
remote: true,
title: t("poll_questions.show.voted", answer: question_answer.title),
class: "button answered",
- "aria-pressed": true do %>
- <%= question_answer.title %>
- <% end %>
+ "aria-pressed": true %>
<% else %>
- <%= button_to answer_question_path(question, answer: question_answer.title),
+ <%= button_to question_answer.title,
+ answer_question_path(question, answer: question_answer.title),
remote: true,
title: t("poll_questions.show.vote_answer", answer: question_answer.title),
class: "button secondary hollow",
"aria-pressed": false,
- disabled: disable_answer?(question_answer) do %>
- <%= question_answer.title %>
- <% end %>
+ disabled: disable_answer?(question_answer) %>
<% end %>
<% end %>
<% elsif !user_signed_in? %>
diff --git a/app/components/proposals/votes_component.html.erb b/app/components/proposals/votes_component.html.erb
index c96200e00..612052103 100644
--- a/app/components/proposals/votes_component.html.erb
+++ b/app/components/proposals/votes_component.html.erb
@@ -7,14 +7,13 @@
<%= t("proposals.proposal.already_supported") %>
<% else %>
- <%= button_to vote_url,
+ <%= button_to t("proposals.proposal.support"),
+ vote_url,
class: "button button-support small expanded",
title: t("proposals.proposal.support_title"),
method: "post",
remote: true,
- "aria-label": support_aria_label do %>
- <%= t("proposals.proposal.support") %>
- <% end %>
+ "aria-label": support_aria_label %>
<% end %>
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index b13ef5ed1..39df8d8fd 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -11,7 +11,7 @@
# `button_to` view helper will render `` element, regardless of whether
# or not the content is passed as the first argument or as a block.
-# Rails.application.config.action_view.button_to_generates_button_tag = true
+Rails.application.config.action_view.button_to_generates_button_tag = true
# `stylesheet_link_tag` view helper will not render the media attribute by default.
# Rails.application.config.action_view.apply_stylesheet_media_default = false
From b3f5705121b81b7a9b4d8dda56faf6271785a4e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 23:14:58 +0100
Subject: [PATCH 04/22] Use SHA256 to encrypt messages and cookies
Note that enabling this options means all encrypted messages and cookies
generated the application become invalid, so we're adding a cookie
rotator in order to keep sessions from expiring when upgrading the
application, as recommended in the "Upgrading Ruby on Rails" guideline
[1].
Since we haven't seen any Consul Democracy applications using encrypted
messages and these messages become invalid with this change, we're also
removing the pre-Rails 5.2 encryption to authenticate messages
(AES-256-CBC) and switching to the default one since Rails 5.2
(AES-256-GCM). Since the configured encryption is used by the cookie
rotator initializer (through the ActiveSupport::MessageEncryptor.key_len
method), at first I thought this might affect the cookie rotator, but it
doesn't: upgrading works as expected, and existing sessions are still
active.
I'm adding a comment to remove the initializer once all cookies have
been migrated. I've added "Rails 7.1" in the comment because we usually
check for these comments when upgrading Rails, but we rarely check for
them when after releasing new versions of Consul Democracy.
[1] https://guides.rubyonrails.org/v7.0/upgrading_ruby_on_rails.html#key-generator-digest-class-changing-to-use-sha256
---
.rubocop.yml | 1 +
config/application.rb | 4 ----
config/initializers/cookie_rotator.rb | 23 +++++++++++++++++++
.../new_framework_defaults_7_0.rb | 2 +-
4 files changed, 25 insertions(+), 5 deletions(-)
create mode 100644 config/initializers/cookie_rotator.rb
diff --git a/.rubocop.yml b/.rubocop.yml
index 9fffe97aa..cf411617d 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -163,6 +163,7 @@ Layout/LineLength:
- "config/environments/staging.rb"
- "config/initializers/devise.rb"
- "config/initializers/backtrace_silencers.rb"
+ - "config/initializers/cookie_rotator.rb"
- "db/migrate/*create_delayed_jobs.rb"
- "db/migrate/*create_active_storage_variant_records.active_storage.rb"
- "app/models/budget/stats.rb"
diff --git a/config/application.rb b/config/application.rb
index ae3ef7b8f..fc512ff98 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -27,10 +27,6 @@ module Consul
# Rails 4 models worked
config.active_record.belongs_to_required_by_default = false
- # Keep using AES-256-CBC for message encryption in case it's used
- # in any CONSUL DEMOCRACY installations
- config.active_support.use_authenticated_message_encryption = false
-
# Don't enable has_many_inversing because it doesn't seem to currently
# work with the _count database columns we use for caching purposes
config.active_record.has_many_inversing = false
diff --git a/config/initializers/cookie_rotator.rb b/config/initializers/cookie_rotator.rb
new file mode 100644
index 000000000..b82c9de1d
--- /dev/null
+++ b/config/initializers/cookie_rotator.rb
@@ -0,0 +1,23 @@
+# This code was copied from:
+# https://guides.rubyonrails.org/v7.0/upgrading_ruby_on_rails.html#key-generator-digest-class-changing-to-use-sha256
+# TODO: safe to remove after upgrading to Rails 7.1 or releasing a new
+# version of Consul Democracy
+Rails.application.config.after_initialize do
+ Rails.application.config.action_dispatch.cookies_rotations.tap do |cookies|
+ authenticated_encrypted_cookie_salt = Rails.application.config.action_dispatch.authenticated_encrypted_cookie_salt
+ signed_cookie_salt = Rails.application.config.action_dispatch.signed_cookie_salt
+
+ secret_key_base = Rails.application.secret_key_base
+
+ key_generator = ActiveSupport::KeyGenerator.new(
+ secret_key_base, iterations: 1000, hash_digest_class: OpenSSL::Digest::SHA1
+ )
+ key_len = ActiveSupport::MessageEncryptor.key_len
+
+ old_encrypted_secret = key_generator.generate_key(authenticated_encrypted_cookie_salt, key_len)
+ old_signed_secret = key_generator.generate_key(signed_cookie_salt)
+
+ cookies.rotate :encrypted, old_encrypted_secret
+ cookies.rotate :signed, old_signed_secret
+ end
+end
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 39df8d8fd..c8c21ad4c 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -23,7 +23,7 @@ Rails.application.config.action_view.button_to_generates_button_tag = true
#
# See upgrading guide for more information on how to build a rotator.
# https://guides.rubyonrails.org/v7.0/upgrading_ruby_on_rails.html
-# Rails.application.config.active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
+Rails.application.config.active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
# Change the digest class for ActiveSupport::Digest.
# Changing this default means that for example Etags change and
From 49754bca2eb0bc1dc2b0d2e18ae6eea1d518e491 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 00:17:39 +0100
Subject: [PATCH 05/22] Use SHA256 as digest class
This is similar to what we did in commit 00a5dc921 when upgrading to
Rails 5.2. Quoting from that commit:
> Note this change will cause all fragment caching to expire. We
> consider it acceptable considering the page where caching is most
> important (stats) is barely affected by this change, since this change
> only affects the view, and the time-consuming operations are cached in
> the model.
>
> Comments are actually affected, though, and pages with thousands of
> comments might take a few extra seconds to load the first time they're
> accessed after this change. We don't think this is going to be an
> issue on existing CONSUL installations.
---
config/initializers/new_framework_defaults_7_0.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index c8c21ad4c..40448620f 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -28,7 +28,7 @@ Rails.application.config.active_support.key_generator_hash_digest_class = OpenSS
# Change the digest class for ActiveSupport::Digest.
# Changing this default means that for example Etags change and
# various cache keys leading to cache invalidation.
-# Rails.application.config.active_support.hash_digest_class = OpenSSL::Digest::SHA256
+Rails.application.config.active_support.hash_digest_class = OpenSSL::Digest::SHA256
# Don't override ActiveSupport::TimeWithZone.name and use the default Ruby
# implementation.
From 87fa2b1fbb0a0f7d67fb6a55400404a2b0f23884 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 00:28:32 +0100
Subject: [PATCH 06/22] Don't override ActiveSupport::TimeWithZone.name
We aren't getting any warnings when running our test suite, which means
that gems that depended on this method (like graphql [1]) have already
added compatibility for this case.
[1] Pull request 3774 in https://github.com/rmosolgo/graphql-ruby/
---
config/initializers/new_framework_defaults_7_0.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 40448620f..0bdd126ee 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -32,7 +32,7 @@ Rails.application.config.active_support.hash_digest_class = OpenSSL::Digest::SHA
# Don't override ActiveSupport::TimeWithZone.name and use the default Ruby
# implementation.
-# Rails.application.config.active_support.remove_deprecated_time_with_zone_name = true
+Rails.application.config.active_support.remove_deprecated_time_with_zone_name = true
# Calls `Rails.application.executor.wrap` around test cases.
# This makes test cases behave closer to an actual request or job.
From 855cd609add0a74f321a6964ee4bc777fe741971 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 00:38:08 +0100
Subject: [PATCH 07/22] Call Rails executor wrap around test cases
Not sure whether this affects us since we use RSpec; in any case, if it
affects us, it seems like a good idea, although we'll have to watch
whether some tests start failing more often.
---
config/initializers/new_framework_defaults_7_0.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 0bdd126ee..0645ee87c 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -38,7 +38,7 @@ Rails.application.config.active_support.remove_deprecated_time_with_zone_name =
# This makes test cases behave closer to an actual request or job.
# Several features that are normally disabled in test, such as Active Record query cache
# and asynchronous queries will then be enabled.
-# Rails.application.config.active_support.executor_around_test_case = true
+Rails.application.config.active_support.executor_around_test_case = true
# Set both the `:open_timeout` and `:read_timeout` values for `:smtp` delivery method.
# Rails.application.config.action_mailer.smtp_timeout = 5
From 904a175541dd24afa6a4aaccb94a23c0f5e9aa4b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 01:03:06 +0100
Subject: [PATCH 08/22] Enable ActionMailer SMTP timeouts
Before Rails 7.0 was released, neither the Mail gem or Rails were
providing a default timeout for SMTP, so there was a risk of processes
being stuck while sending emails.
That's no longer the case, though; we're using version 2.8.x of the Mail
gem, which already provides a default timeout [2].
Since the default timeout provided by the Mail gem is the same as the
default timeout provided by Rails 7.0, it doesn't matter whether we
enable this option. We're enabling because it's easier to just use the
default 7.0 configuration.
[1] Issue 41244 in https://github.com/rails/rails
[2] Pull request 1427 in https://github.com/mikel/mail
---
config/initializers/new_framework_defaults_7_0.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 0645ee87c..5f706e6e9 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -41,7 +41,7 @@ Rails.application.config.active_support.remove_deprecated_time_with_zone_name =
Rails.application.config.active_support.executor_around_test_case = true
# Set both the `:open_timeout` and `:read_timeout` values for `:smtp` delivery method.
-# Rails.application.config.action_mailer.smtp_timeout = 5
+Rails.application.config.action_mailer.smtp_timeout = 5
# The ActiveStorage video previewer will now use scene change detection to generate
# better preview images (rather than the previous default of using the first frame
From 14015948b9606a78640e4832536df76fd8b03dbd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 01:11:54 +0100
Subject: [PATCH 09/22] Use new defaults for ActiveStorage video previews
Since we don't generate video previews, this change doesn't affect us.
---
config/initializers/new_framework_defaults_7_0.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 5f706e6e9..60dbd8fe1 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -46,8 +46,8 @@ Rails.application.config.action_mailer.smtp_timeout = 5
# The ActiveStorage video previewer will now use scene change detection to generate
# better preview images (rather than the previous default of using the first frame
# of the video).
-# Rails.application.config.active_storage.video_preview_arguments =
-# "-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1' -frames:v 1 -f image2"
+Rails.application.config.active_storage.video_preview_arguments =
+ "-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1' -frames:v 1 -f image2"
# Automatically infer `inverse_of` for associations with a scope.
# Rails.application.config.active_record.automatic_scope_inversing = true
From 961f4a9cd257c6e9e9da2e6f3b07012000734552 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 02:36:03 +0100
Subject: [PATCH 10/22] Enable automatic inverse_of infering
It looks like we can't really benefit from this rule because usually we
need to specify the option anyway (maybe `user has_many :comments` is
one of the few exceptions). We might make some changes in the code when
Rubocop changes its Rails/InverseOf rule so it doesn't report this case
when using Rails 7, but, until then, we aren't changing anything so we
don't have to deal with false positives in Rubocop.
---
config/initializers/new_framework_defaults_7_0.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 60dbd8fe1..51df20c28 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -50,7 +50,7 @@ Rails.application.config.active_storage.video_preview_arguments =
"-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1' -frames:v 1 -f image2"
# Automatically infer `inverse_of` for associations with a scope.
-# Rails.application.config.active_record.automatic_scope_inversing = true
+Rails.application.config.active_record.automatic_scope_inversing = true
# Raise when running tests if fixtures contained foreign key violations
# Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true
From 0376da80e708956745dc85cc346dfc1b54eba6c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 02:44:54 +0100
Subject: [PATCH 11/22] Verify foreign keys for fixtures
It doesn't really affect us because we don't use fixtures, so we're just
using the new default value.
---
config/initializers/new_framework_defaults_7_0.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 51df20c28..eb631c265 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -53,7 +53,7 @@ Rails.application.config.active_storage.video_preview_arguments =
Rails.application.config.active_record.automatic_scope_inversing = true
# Raise when running tests if fixtures contained foreign key violations
-# Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true
+Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true
# Disable partial inserts.
# This default means that all columns will be referenced in INSERT queries
From 9b4525ac71e75640a32030d158d6897f030729f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 02:51:26 +0100
Subject: [PATCH 12/22] Disable ActiveRecord partial inserts
As mentioned in the Rails pull request [1], the main reason for partial
inserts is no longer relevant thanks to the `ignored_columns` method
(which we haven't even needed so far).
I don't have a preference regarding this setting; we're enabling it in
order to reduce the number of settings we customize.
[1] Pull request 42769 in https://github.com/rails/rails
---
config/initializers/new_framework_defaults_7_0.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index eb631c265..04b2bb5ad 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -58,7 +58,7 @@ Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true
# Disable partial inserts.
# This default means that all columns will be referenced in INSERT queries
# regardless of whether they have a default or not.
-# Rails.application.config.active_record.partial_inserts = false
+Rails.application.config.active_record.partial_inserts = false
# Protect from open redirect attacks in `redirect_back_or_to` and `redirect_to`.
# Rails.application.config.action_controller.raise_on_open_redirects = true
From cc628f0363b94556cead86897b5596d4b2664a12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 02:59:07 +0100
Subject: [PATCH 13/22] Raise an exception on open redirects
This way we'll add an extra layer of protection from attacks that might
cause our application to redirect to an external host.
There's one place where we're allowing redirects to external hosts,
though: administrators can link external resources in notifications, and
we're redirecting to them after marking the notification as read.
Since the tests for the remote translations controller were
(accidentally) using an external redirect, we're updating them to use a
relative URL.
---
app/controllers/notifications_controller.rb | 2 +-
config/initializers/new_framework_defaults_7_0.rb | 2 +-
spec/controllers/remote_translations_controller_spec.rb | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb
index 8d5e2fe4f..e8a8f441d 100644
--- a/app/controllers/notifications_controller.rb
+++ b/app/controllers/notifications_controller.rb
@@ -11,7 +11,7 @@ class NotificationsController < ApplicationController
def show
@notification = current_user.notifications.find(params[:id])
@notification.mark_as_read
- redirect_to linkable_resource_path(@notification)
+ redirect_to linkable_resource_path(@notification), allow_other_host: true
end
def read
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 04b2bb5ad..343c33ced 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -61,7 +61,7 @@ Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true
Rails.application.config.active_record.partial_inserts = false
# Protect from open redirect attacks in `redirect_back_or_to` and `redirect_to`.
-# Rails.application.config.action_controller.raise_on_open_redirects = true
+Rails.application.config.action_controller.raise_on_open_redirects = true
# Change the variant processor for Active Storage.
# Changing this default means updating all places in your code that
diff --git a/spec/controllers/remote_translations_controller_spec.rb b/spec/controllers/remote_translations_controller_spec.rb
index e7685f46e..9832607e5 100644
--- a/spec/controllers/remote_translations_controller_spec.rb
+++ b/spec/controllers/remote_translations_controller_spec.rb
@@ -11,7 +11,7 @@ describe RemoteTranslationsController, :remote_translations do
end
before do
- request.env["HTTP_REFERER"] = "any_path"
+ request.env["HTTP_REFERER"] = "/any_path"
end
it "create correctly remote translation" do
@@ -39,7 +39,7 @@ describe RemoteTranslationsController, :remote_translations do
it "redirect_to request referer after create" do
post :create, params: { remote_translations: remote_translations_params }
- expect(subject).to redirect_to("any_path")
+ expect(subject).to redirect_to "/any_path"
end
end
end
From e1e5efe34b869f0166d6dca3786ee5342f73fb8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 03:08:33 +0100
Subject: [PATCH 14/22] Wrap parameters by default in ActionController
As mentioned in the Rails configuration documentation [1] (note the link
points to the configuration guide for Rails 7.1, but only because the
documentation for this option wasn't as good in the configuration guide
for Rails 7.0; the behavior hasn't changed between these two versions),
this was done in the `wrap_parameters` initializer but now it can be
done using a new default configuration option.
[1] https://guides.rubyonrails.org/v7.1/configuring.html#config-action-controller-wrap-parameters-by-default
---
config/initializers/new_framework_defaults_7_0.rb | 2 +-
config/initializers/wrap_parameters.rb | 14 --------------
2 files changed, 1 insertion(+), 15 deletions(-)
delete mode 100644 config/initializers/wrap_parameters.rb
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 343c33ced..aa3bfb5bc 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -73,7 +73,7 @@ Rails.application.config.action_controller.raise_on_open_redirects = true
# Enable parameter wrapping for JSON.
# Previously this was set in an initializer. It's fine to keep using that initializer if you've customized it.
# To disable parameter wrapping entirely, set this config to `false`.
-# Rails.application.config.action_controller.wrap_parameters_by_default = true
+Rails.application.config.action_controller.wrap_parameters_by_default = true
# Specifies whether generated namespaced UUIDs follow the RFC 4122 standard for namespace IDs provided as a
# `String` to `Digest::UUID.uuid_v3` or `Digest::UUID.uuid_v5` method calls.
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
deleted file mode 100644
index bbfc3961b..000000000
--- a/config/initializers/wrap_parameters.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# This file contains settings for ActionController::ParamsWrapper which
-# is enabled by default.
-
-# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
-ActiveSupport.on_load(:action_controller) do
- wrap_parameters format: [:json]
-end
-
-# To enable root element in JSON for ActiveRecord objects.
-# ActiveSupport.on_load(:active_record) do
-# self.include_root_in_json = true
-# end
From 47331061a8f74a4eeb22c802ffa3243a4ec87e58 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 21:43:56 +0100
Subject: [PATCH 15/22] Use RFC 4122 namespaced UUIDs
This configuration option disappeared in Rails 7.1 [1] (meaning it isn't
possible to set it to `false` in a Rails 7.1 application). Since it's
going to be our only option when upgrading to Rails 7.1, we're already
activating it now.
[1] https://github.com/rails/rails/commit/7b4affc78
---
config/initializers/new_framework_defaults_7_0.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index aa3bfb5bc..55906df86 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -80,7 +80,7 @@ Rails.application.config.action_controller.wrap_parameters_by_default = true
#
# See https://guides.rubyonrails.org/configuring.html#config-active-support-use-rfc4122-namespaced-uuids for
# more information.
-# Rails.application.config.active_support.use_rfc4122_namespaced_uuids = true
+Rails.application.config.active_support.use_rfc4122_namespaced_uuids = true
# Change the default headers to disable browsers' flawed legacy XSS protection.
# Rails.application.config.action_dispatch.default_headers = {
From d846fdad39ee0b4d43fc95d607deba7028ee2b5e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 22:00:46 +0100
Subject: [PATCH 16/22] Use the new default headers
The only change between these headers and the ones sent by Rails 6.1
application is that now the `X-XSS-Protection` header is set to zero. As
mentioned in the pull request introducing the change [1]:
> This header has been deprecated and the XSS auditor it triggered has
> been removed from all major modern browsers (in favour of Content
> Security Policy) that implemented this header to begin with (Firefox
> never did).
[1] Pull request 41769 in https://github.com/rails/rails
---
.../initializers/new_framework_defaults_7_0.rb | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 55906df86..723b20904 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -83,14 +83,14 @@ Rails.application.config.action_controller.wrap_parameters_by_default = true
Rails.application.config.active_support.use_rfc4122_namespaced_uuids = true
# Change the default headers to disable browsers' flawed legacy XSS protection.
-# Rails.application.config.action_dispatch.default_headers = {
-# "X-Frame-Options" => "SAMEORIGIN",
-# "X-XSS-Protection" => "0",
-# "X-Content-Type-Options" => "nosniff",
-# "X-Download-Options" => "noopen",
-# "X-Permitted-Cross-Domain-Policies" => "none",
-# "Referrer-Policy" => "strict-origin-when-cross-origin"
-# }
+Rails.application.config.action_dispatch.default_headers = {
+ "X-Frame-Options" => "SAMEORIGIN",
+ "X-XSS-Protection" => "0",
+ "X-Content-Type-Options" => "nosniff",
+ "X-Download-Options" => "noopen",
+ "X-Permitted-Cross-Domain-Policies" => "none",
+ "Referrer-Policy" => "strict-origin-when-cross-origin"
+}
# ** Please read carefully, this must be configured in config/application.rb **
From 001eee3d6cb399500b4d37087a6ad7b8db23d60d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 22:05:19 +0100
Subject: [PATCH 17/22] Use Rails 7.0 cache format
According to the Rails configuration guide [1], with this format, Rails
serializes cache entries more efficiently. Most importantly:
> All formats are backward and forward compatible, meaning cache entries
> written in one format can be read when using another format. This
> behavior makes it easy to migrate between formats without invalidating
> the entire cache.
[1] https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-cache-format-version
---
config/application.rb | 7 +++++++
config/initializers/new_framework_defaults_7_0.rb | 11 -----------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/config/application.rb b/config/application.rb
index fc512ff98..0c19b18c8 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -23,6 +23,13 @@ module Consul
class Application < Rails::Application
config.load_defaults 6.1
+ # Change the format of the cache entry.
+ # Changing this default means that all new cache entries added to the cache
+ # will have a different format that is not supported by Rails 6.1 applications.
+ # Only change this value after your application is fully deployed to Rails 7.0
+ # and you have no plans to rollback.
+ config.active_support.cache_format_version = 7.0
+
# Keep belongs_to fields optional by default, because that's the way
# Rails 4 models worked
config.active_record.belongs_to_required_by_default = false
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 723b20904..cbd23a7ce 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -92,17 +92,6 @@ Rails.application.config.action_dispatch.default_headers = {
"Referrer-Policy" => "strict-origin-when-cross-origin"
}
-
-# ** Please read carefully, this must be configured in config/application.rb **
-# Change the format of the cache entry.
-# Changing this default means that all new cache entries added to the cache
-# will have a different format that is not supported by Rails 6.1 applications.
-# Only change this value after your application is fully deployed to Rails 7.0
-# and you have no plans to rollback.
-# When you're ready to change format, add this to `config/application.rb` (NOT this file):
-# config.active_support.cache_format_version = 7.0
-
-
# Cookie serializer: 2 options
#
# If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer
From 077faa2ad0117184b5cc0477c6eafdca36f224a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 22:12:28 +0100
Subject: [PATCH 18/22] Move cookies serializer option to Rails 7.0 file
We're moving it here so it's easier to remove it when we start using the
default Rails 7.0 options and will no longer need to specify it.
---
config/initializers/cookies_serializer.rb | 5 -----
.../new_framework_defaults_7_0.rb | 19 +------------------
2 files changed, 1 insertion(+), 23 deletions(-)
delete mode 100644 config/initializers/cookies_serializer.rb
diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb
deleted file mode 100644
index 5a6a32d37..000000000
--- a/config/initializers/cookies_serializer.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# Specify a serializer for the signed and encrypted cookie jars.
-# Valid options are :json, :marshal, and :hybrid.
-Rails.application.config.action_dispatch.cookies_serializer = :json
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index cbd23a7ce..488587cfe 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -97,26 +97,9 @@ Rails.application.config.action_dispatch.default_headers = {
# If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer
# is `:marshal`. The default for new apps is `:json`.
#
-# Rails.application.config.action_dispatch.cookies_serializer = :json
-#
-#
-# To migrate an existing application to the `:json` serializer, use the `:hybrid` option.
-#
-# Rails transparently deserializes existing (Marshal-serialized) cookies on read and
-# re-writes them in the JSON format.
-#
-# It is fine to use `:hybrid` long term; you should do that until you're confident *all* your cookies
-# have been converted to JSON. To keep using `:hybrid` long term, move this config to its own
-# initializer or to `config/application.rb`.
-#
-# Rails.application.config.action_dispatch.cookies_serializer = :hybrid
-#
-#
-# If your cookies can't yet be serialized to JSON, keep using `:marshal` for backward-compatibility.
-#
# If you have configured the serializer elsewhere, you can remove this section of the file.
#
-# See https://guides.rubyonrails.org/action_controller_overview.html#cookies for more information.
+Rails.application.config.action_dispatch.cookies_serializer = :json
# Change the return value of `ActionDispatch::Request#content_type` to the Content-Type header without modification.
# Rails.application.config.action_dispatch.return_only_request_media_type_on_content_type = false
From 77977bd8fe586423d0a8cfdbf1f00d7f190d22d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 22:21:29 +0100
Subject: [PATCH 19/22] Return Content-Type header without modification
Setting it to `true` was deprecated in Rails 7.0 and the option was was
removed in Rails 7.1, so in Rails 7.1 applications it isn't possible to
set it to `true` [1]. So we're setting it to `false` now.
[1] https://github.com/rails/rails/commit/689b27773
---
config/initializers/new_framework_defaults_7_0.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 488587cfe..092eab294 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -102,7 +102,7 @@ Rails.application.config.action_dispatch.default_headers = {
Rails.application.config.action_dispatch.cookies_serializer = :json
# Change the return value of `ActionDispatch::Request#content_type` to the Content-Type header without modification.
-# Rails.application.config.action_dispatch.return_only_request_media_type_on_content_type = false
+Rails.application.config.action_dispatch.return_only_request_media_type_on_content_type = false
# Active Storage `has_many_attached` relationships will default to replacing the current collection instead of appending to it.
# Thus, to support submitting an empty collection, the `file_field` helper will render an hidden field `include_hidden` by default when `multiple_file_field_include_hidden` is set to `true`.
From a8047a96c89986655e899a50496baa11171184d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 22:26:15 +0100
Subject: [PATCH 20/22] Include a hidden field in multiple file inputs
This doesn't really affect us because we don'thave any multiple file
inputs in the application, but we're enabling it because it's the new
default configuration option.
---
config/initializers/new_framework_defaults_7_0.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 092eab294..8ffa00cba 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -107,7 +107,7 @@ Rails.application.config.action_dispatch.return_only_request_media_type_on_conte
# Active Storage `has_many_attached` relationships will default to replacing the current collection instead of appending to it.
# Thus, to support submitting an empty collection, the `file_field` helper will render an hidden field `include_hidden` by default when `multiple_file_field_include_hidden` is set to `true`.
# See https://guides.rubyonrails.org/configuring.html#config-active-storage-multiple-file-field-include-hidden for more information.
-# Rails.application.config.active_storage.multiple_file_field_include_hidden = true
+Rails.application.config.active_storage.multiple_file_field_include_hidden = true
# ** Please read carefully, this must be configured in config/application.rb (NOT this file) **
# Disables the deprecated #to_s override in some Ruby core classes
From 726d8a8935a261541f69d8be78aa3956613e2aae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 22:42:01 +0100
Subject: [PATCH 21/22] Disable Rails' deprecated to_s override
This option was deprecated in Rails 7.0 and removed in Rails 7.1 [1]. It
doesn't really affect us because we weren't using `to_s` with a
parameter anywhere in the application.
The Rubocop rule Rails/ToSWithArgument can be used to detect these cases
but, since we've never used them, and adding them now would cause the
application to crash and so it'll be obvious we've done something wrong,
I don't think it's necessary to add the rule.
[1] https://github.com/rails/rails/commit/e420c3380
---
config/application.rb | 4 ++++
config/initializers/new_framework_defaults_7_0.rb | 5 -----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/config/application.rb b/config/application.rb
index 0c19b18c8..872130418 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -30,6 +30,10 @@ module Consul
# and you have no plans to rollback.
config.active_support.cache_format_version = 7.0
+ # Disables the deprecated #to_s override in some Ruby core classes
+ # See https://guides.rubyonrails.org/configuring.html#config-active-support-disable-to-s-conversion for more information.
+ config.active_support.disable_to_s_conversion = true
+
# Keep belongs_to fields optional by default, because that's the way
# Rails 4 models worked
config.active_record.belongs_to_required_by_default = false
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
index 8ffa00cba..3d86cc89c 100644
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -108,8 +108,3 @@ Rails.application.config.action_dispatch.return_only_request_media_type_on_conte
# Thus, to support submitting an empty collection, the `file_field` helper will render an hidden field `include_hidden` by default when `multiple_file_field_include_hidden` is set to `true`.
# See https://guides.rubyonrails.org/configuring.html#config-active-storage-multiple-file-field-include-hidden for more information.
Rails.application.config.active_storage.multiple_file_field_include_hidden = true
-
-# ** Please read carefully, this must be configured in config/application.rb (NOT this file) **
-# Disables the deprecated #to_s override in some Ruby core classes
-# See https://guides.rubyonrails.org/configuring.html#config-active-support-disable-to-s-conversion for more information.
-# config.active_support.disable_to_s_conversion = true
From 492b2281b0459c051a051e89a8e38680387c2fa8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javi=20Mart=C3=ADn?=
Date: Thu, 28 Mar 2024 00:09:18 +0100
Subject: [PATCH 22/22] Use Rails 7.0 defaults and overwrite them
We're keeping the old `apply_stylesheet_media_default` option behavior
because removing `media="screen"` from our stylesheets would completely
break our `print` stylesheet, which would now load the default the
styles defined in `application.css`.
We're also keeping the old `:mini_magick` option to process images so
existing installations don't have to install libvips on their server. We
might change it in the future.
---
config/application.rb | 22 ++--
.../new_framework_defaults_7_0.rb | 110 ------------------
2 files changed, 10 insertions(+), 122 deletions(-)
delete mode 100644 config/initializers/new_framework_defaults_7_0.rb
diff --git a/config/application.rb b/config/application.rb
index 872130418..deaf238f6 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -21,18 +21,7 @@ Bundler.require(*Rails.groups)
module Consul
class Application < Rails::Application
- config.load_defaults 6.1
-
- # Change the format of the cache entry.
- # Changing this default means that all new cache entries added to the cache
- # will have a different format that is not supported by Rails 6.1 applications.
- # Only change this value after your application is fully deployed to Rails 7.0
- # and you have no plans to rollback.
- config.active_support.cache_format_version = 7.0
-
- # Disables the deprecated #to_s override in some Ruby core classes
- # See https://guides.rubyonrails.org/configuring.html#config-active-support-disable-to-s-conversion for more information.
- config.active_support.disable_to_s_conversion = true
+ config.load_defaults 7.0
# Keep belongs_to fields optional by default, because that's the way
# Rails 4 models worked
@@ -45,6 +34,15 @@ module Consul
# Disable Sprockets AssetUrlProcessor for CKEditor compatibility
config.assets.resolve_assets_in_css_urls = false
+ # Keep adding media="screen" attribute to stylesheets, just like
+ # Rails 4, 5 and 6 did, until we change the print stylesheet so it
+ # works when loading all the styles
+ config.action_view.apply_stylesheet_media_default = true
+
+ # Keep using ImageMagick instead of libvips for image processing in
+ # order to make upgrades easier.
+ config.active_storage.variant_processor = :mini_magick
+
# Keep reading existing data in the legislation_annotations ranges column
config.active_record.yaml_column_permitted_classes = [ActiveSupport::HashWithIndifferentAccess, Symbol]
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
deleted file mode 100644
index 3d86cc89c..000000000
--- a/config/initializers/new_framework_defaults_7_0.rb
+++ /dev/null
@@ -1,110 +0,0 @@
-# Be sure to restart your server when you modify this file.
-#
-# This file eases your Rails 7.0 framework defaults upgrade.
-#
-# Uncomment each configuration one by one to switch to the new default.
-# Once your application is ready to run with all new defaults, you can remove
-# this file and set the `config.load_defaults` to `7.0`.
-#
-# Read the Guide for Upgrading Ruby on Rails for more info on each option.
-# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
-
-# `button_to` view helper will render `` element, regardless of whether
-# or not the content is passed as the first argument or as a block.
-Rails.application.config.action_view.button_to_generates_button_tag = true
-
-# `stylesheet_link_tag` view helper will not render the media attribute by default.
-# Rails.application.config.action_view.apply_stylesheet_media_default = false
-
-# Change the digest class for the key generators to `OpenSSL::Digest::SHA256`.
-# Changing this default means invalidate all encrypted messages generated by
-# your application and, all the encrypted cookies. Only change this after you
-# rotated all the messages using the key rotator.
-#
-# See upgrading guide for more information on how to build a rotator.
-# https://guides.rubyonrails.org/v7.0/upgrading_ruby_on_rails.html
-Rails.application.config.active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
-
-# Change the digest class for ActiveSupport::Digest.
-# Changing this default means that for example Etags change and
-# various cache keys leading to cache invalidation.
-Rails.application.config.active_support.hash_digest_class = OpenSSL::Digest::SHA256
-
-# Don't override ActiveSupport::TimeWithZone.name and use the default Ruby
-# implementation.
-Rails.application.config.active_support.remove_deprecated_time_with_zone_name = true
-
-# Calls `Rails.application.executor.wrap` around test cases.
-# This makes test cases behave closer to an actual request or job.
-# Several features that are normally disabled in test, such as Active Record query cache
-# and asynchronous queries will then be enabled.
-Rails.application.config.active_support.executor_around_test_case = true
-
-# Set both the `:open_timeout` and `:read_timeout` values for `:smtp` delivery method.
-Rails.application.config.action_mailer.smtp_timeout = 5
-
-# The ActiveStorage video previewer will now use scene change detection to generate
-# better preview images (rather than the previous default of using the first frame
-# of the video).
-Rails.application.config.active_storage.video_preview_arguments =
- "-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1' -frames:v 1 -f image2"
-
-# Automatically infer `inverse_of` for associations with a scope.
-Rails.application.config.active_record.automatic_scope_inversing = true
-
-# Raise when running tests if fixtures contained foreign key violations
-Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true
-
-# Disable partial inserts.
-# This default means that all columns will be referenced in INSERT queries
-# regardless of whether they have a default or not.
-Rails.application.config.active_record.partial_inserts = false
-
-# Protect from open redirect attacks in `redirect_back_or_to` and `redirect_to`.
-Rails.application.config.action_controller.raise_on_open_redirects = true
-
-# Change the variant processor for Active Storage.
-# Changing this default means updating all places in your code that
-# generate variants to use image processing macros and ruby-vips
-# operations. See the upgrading guide for detail on the changes required.
-# The `:mini_magick` option is not deprecated; it's fine to keep using it.
-# Rails.application.config.active_storage.variant_processor = :vips
-
-# Enable parameter wrapping for JSON.
-# Previously this was set in an initializer. It's fine to keep using that initializer if you've customized it.
-# To disable parameter wrapping entirely, set this config to `false`.
-Rails.application.config.action_controller.wrap_parameters_by_default = true
-
-# Specifies whether generated namespaced UUIDs follow the RFC 4122 standard for namespace IDs provided as a
-# `String` to `Digest::UUID.uuid_v3` or `Digest::UUID.uuid_v5` method calls.
-#
-# See https://guides.rubyonrails.org/configuring.html#config-active-support-use-rfc4122-namespaced-uuids for
-# more information.
-Rails.application.config.active_support.use_rfc4122_namespaced_uuids = true
-
-# Change the default headers to disable browsers' flawed legacy XSS protection.
-Rails.application.config.action_dispatch.default_headers = {
- "X-Frame-Options" => "SAMEORIGIN",
- "X-XSS-Protection" => "0",
- "X-Content-Type-Options" => "nosniff",
- "X-Download-Options" => "noopen",
- "X-Permitted-Cross-Domain-Policies" => "none",
- "Referrer-Policy" => "strict-origin-when-cross-origin"
-}
-
-# Cookie serializer: 2 options
-#
-# If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer
-# is `:marshal`. The default for new apps is `:json`.
-#
-# If you have configured the serializer elsewhere, you can remove this section of the file.
-#
-Rails.application.config.action_dispatch.cookies_serializer = :json
-
-# Change the return value of `ActionDispatch::Request#content_type` to the Content-Type header without modification.
-Rails.application.config.action_dispatch.return_only_request_media_type_on_content_type = false
-
-# Active Storage `has_many_attached` relationships will default to replacing the current collection instead of appending to it.
-# Thus, to support submitting an empty collection, the `file_field` helper will render an hidden field `include_hidden` by default when `multiple_file_field_include_hidden` is set to `true`.
-# See https://guides.rubyonrails.org/configuring.html#config-active-storage-multiple-file-field-include-hidden for more information.
-Rails.application.config.active_storage.multiple_file_field_include_hidden = true