Commit Graph

18 Commits

Author SHA1 Message Date
Javi Martín
7993f6d1ed Enable before_committed callbacks on all records
This doesn't really affect us because we don't use `before_committed`
callbacks (and neither do any of our dependencies), so we're using the
new default value.
2025-05-20 15:38:52 +02:00
Javi Martín
5ecd65b7dc Precompile filter parameters
This is done for performance reasons. Quoting the pull request
introducing this option [1]:

> A config might be overkill, but I wanted to provide an escape hatch
> for any upgraded apps that might be testing the exact value of the
> action_dispatch.parameter_filter header.

Since we don't test the exact value of action_dispatch.parameter_filter,
we can enable this option.

[1] Pull request 46452 in https://github.com/rails/rails
2025-05-20 15:38:52 +02:00
Javi Martín
529b4d2a98 Don't validate foreign key in required belongs_to
Before this change, every time we saved a record, the association was
validated if we had `belongs_to :something, required: true`. After this
change [1], it's only validated if the `something_id` column is nil (or
`something_type` for polymorphic associations) or if the `something_id`
attribute has changed.

The main difference is that we no longer get validation errors if the
associated record has been deleted. Doesn't affect us much, so we're
going with the new default value.

[1] Pull request 46522 in https://github.com/rails/rails
2025-05-20 15:38:52 +02:00
Javi Martín
364fa2603c Raise exceptions when assigning to attr_readonly attributes
Since we don't use attr_readonly, this option doesn't really affect us.
So we're just using the new default value.
2025-05-20 15:38:52 +02:00
Javi Martín
a1ae4651ff Simplify the way to set the maximum log size
We can use the new configuration option in Rails 7.1, so we don't have
to configure it manually.
2025-05-20 15:38:52 +02:00
Javi Martín
5db773e44f Serialize message data and metadata together
This is the new default option, and its only dangerous when deploying to
applications with multiple servers. Since this isn't our case, we can
enable it.
2025-05-20 15:38:52 +02:00
Javi Martín
e08ba7efbe Use JSON to serialize messages
The new serializer can decrypt legacy messages using the `marshal`
serializer, so there's no risk of losing data when upgrading. Since we
aren't using applications with several servers, where upgrading some
servers might cause issues on the servers that aren't upgraded yet,
we're enabling the option.

[1] See comments in pull request 42846 in https://github.com/rails/rails
2025-05-20 15:38:52 +02:00
Javi Martín
36828ee86b Use SQLCommenter format to format tags in Query Logs
Don't really care about the format, so we'll use the new default one.
2025-05-20 15:38:52 +02:00
Javi Martín
9054d31ab3 Raise exceptions on invalid cache expiration time
It doesn't really affect us (unless some of our dependencies make this
mistake) because we only use `expires_in/expires_at` once and we do it
correctly, but it might be help us detect this issue if we ever
introduce it in the future.
2025-05-20 15:38:51 +02:00
Javi Martín
e45dc5d45a Use BigDecimal argument serializer in Active Job
This option won't even exist in Rails 7.2 [1], and the possibility to
disable it was only added to guarantee safe upgrades in Rails
applications with multiple replicas [2].

Since we don't have applications with multiple replicas, where one
replica could be using Active Job 7.0 and another one could be using
Active Job 7.1 while upgrading, we can enable this options.

[1] Commit 2a761d23d2 in https://github.com/rails/rails
[2] Commit bc1f323338 in https://github.com/rails/rails
2025-05-20 15:38:51 +02:00
Javi Martín
2bedfacf3b Disable deprecated singular association names
This doesn't affect us (since luckily we never use them), and, since
doing something like `Budget::Investment.where(budgets: 1)` would be
very confusing, getting an error when writing this code is IMHO better
than just getting a warning, which was the default before Rails 7.1 [1].

[1] https://guides.rubyonrails.org/v7.1/configuring.html#config-active-record-allow-deprecated-singular-associations-name
2025-05-20 15:38:51 +02:00
Javi Martín
c0bc9bd027 Use Rails 7.1 default options for SQLite
It doesn't really affect us because we don't use SQLite.
2025-05-20 15:38:51 +02:00
Javi Martín
6eebe4e984 Don't run commit callbacks on first saved instances in transaction
It probably doesn't directly affect us, since we don't use
`after_commit` callbacks, and, among our dependencies, AFAIK only the
Devise gem uses them, to send the email with confirmation/reconfirmation
instructions.

The reasons for this change are explained in the guide to configure
Rails [1], while the pull request introducing the change has a couple of
great examples in its description [2].

[1] https://guides.rubyonrails.org/v7.1/configuring.html#config-active-record-run-commit-callbacks-on-first-saved-instances-in-transaction
[2] Pull request 45280 in https://github.com/rails/rails
2025-05-20 15:38:51 +02:00
Javi Martín
fbb40d701b Encrypt Active Record data using SHA256
Since we weren't encrypting any data, we can disable the
support_sha1_for_non_deterministic_encryption option, which should only
be enabled on existing applications that were encrypting data using
SHA1 [1].

[1] https://guides.rubyonrails.org/v7.1/upgrading_ruby_on_rails.html#active-record-encryption-algorithm-changes
2025-05-20 15:38:51 +02:00
Javi Martín
994d86ce2c Don't make ActionController::Parameters equivalent to Hash
The comparison equality was supposed to be deprecated since 2016 [1],
and completely deprecated in Rails 7.1 [2]. This options won't even
exist in the next version of Rails [3].

[1] Pull request 23733 in https://github.com/rails/rails
[2] Pull request 44812 in https://github.com/rails/rails
[3] https://github.com/rails/rails/commit/43e42c1ea
2025-05-20 15:38:51 +02:00
Javi Martín
402b64291c Use the new default headers
The only change between these headers and the ones sent by Rails 7.0
application is that the `"X-Download-Options" => "noopen"` is no longer
sent. Only Internet Explorer used that header, and uploading, previewing
and downloading attachments still works fine on Internet Explorer 11
after this change.

[1] Pull request 43968 in https://github.com/rails/rails
2025-05-20 15:38:51 +02:00
Javi Martín
77d113d640 Don't add autoload_paths to load_path
Quoting the Rails configuration guide [1]:

> applications running in :zeitwerk mode do not need require_dependency,
> so models, controllers, jobs, etc. do not need to be in $LOAD_PATH.
> Setting this to false saves Ruby from checking these directories when
> resolving require calls with relative paths, and saves Bootsnap work
> and RAM, since it does not need to build an index for them.

[1] https://guides.rubyonrails.org/v7.1/configuring.html#config-add-autoload-paths-to-load-path
2025-05-20 15:38:51 +02:00
Javi Martín
0b1cfcd5da Upgrade to Rails 7.1
We're disabling `action_controller.raise_on_missing_callback_actions`
because sometimes we include `before_action :something, only: actions`
in concerns, and we include these concerns in controllers that don't
have all these actions.

Note that Rails 7.1 logs to STDOUT by default [1]; we're re-adding the
condition `if ENV["RAILS_LOG_TO_STDOUT"].present?` because we're still
using files and we're rotating the logs to avoid running out of space.

Also note that the GraphQL controller test (which is actually a request
test, since it's got `type: :request`) that was raising an exception no
longer does it thanks to the new default value for the
`config.action_dispatch.show_exceptions` configuration option. So we're
updating the test accordingly. This option doesn't affect regular
controller tests (without the `type: :request` option), so in other
tests we're still checking exceptions.

[1] Pull request 47138 in https://github.com/rails/rails
2025-05-20 13:12:29 +02:00