ere's a checklist for testing the defaults in your new_framework_defaults_6_0.rb
file:
-
# Rails.application.config.action_view.default_enforce_utf8 = false
- Purpose: Stops Rails from automatically adding
accept-charset="UTF-8"
to forms. This was mainly for older IE versions and is usually unnecessary now. - How to Test:
- Enable it (remove the line or set to
false
). - Check your forms in various browsers, especially if you need to support very old ones. Ensure character encoding works as expected, particularly with non-ASCII characters submitted via forms.
- Enable it (remove the line or set to
- Purpose: Stops Rails from automatically adding
-
# Rails.application.config.action_dispatch.use_cookies_with_metadata = true
- Purpose: Embeds purpose and expiry metadata into signed/encrypted cookies to prevent tampering (e.g., copying a cookie's value to another).
- How to Test:
- Enable it (uncomment the line).
- Test all functionality relying on signed or encrypted cookies (e.g., session management, "remember me" features).
- Verify that existing cookies set before enabling this are still readable (Rails aims for backward compatibility here, but verify).
- Ensure new cookies are set and read correctly across requests.
-
# Rails.application.config.active_job.return_false_on_aborted_enqueue = true
- Purpose: Makes
.perform_later
returnfalse
if abefore_enqueue
oraround_enqueue
callback halts the job enqueuing process. Previously, it returned the job instance. - How to Test:
- Enable it (uncomment the line).
- Identify any ActiveJob classes using
before_enqueue
oraround_enqueue
callbacks that might abort (throw :abort
). - Test the code paths that call
.perform_later
on these jobs, especially if the return value is checked. Ensure your application logic correctly handlesfalse
being returned instead of a job object.
- Purpose: Makes
-
# Rails.application.config.active_storage.queues.analysis = :active_storage_analysis
# Rails.application.config.active_storage.queues.purge = :active_storage_purge
- Purpose: Routes Active Storage background jobs (like analyzing uploads or purging deleted files) to specific queues instead of the default queue.
- How to Test:
- Enable them (uncomment the lines).
- Ensure your background job processor (e.g., Sidekiq, Que) is configured to listen to these specific queue names (
:active_storage_analysis
,:active_storage_purge
). - Upload files and trigger analysis (e.g., preview generation). Verify the analysis job runs successfully in the correct queue.
- Delete files that are set to be purged later. Verify the purge job runs successfully in the correct queue.
- Note: If you don't want dedicated queues, leave these commented to use the default queue.
-
# Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
- Purpose: Uses a single, standardized job class (
ActionMailer::MailDeliveryJob
) for sending emails asynchronously via.deliver_later
, replacing older, separate job classes. - How to Test:
- Enable it (uncomment the line).
- Test all parts of your application that send emails using
.deliver_later
. - Verify emails are still delivered correctly via your background job queue.
- Check any tests that assert on enqueued mailer jobs; they might need updating to look for
ActionMailer::MailDeliveryJob
. Ensure tests using helpers likeperform_enqueued_jobs
still work as expected.
- Purpose: Uses a single, standardized job class (
-
# Rails.application.config.active_record.collection_cache_versioning = true
- Purpose: Enables cache versioning for collections (relations) cached using
Rails.cache.fetch
. This helps reuse cache keys more effectively by embedding version info (based on count and maxupdated_at
) separately from the main key, reducing unnecessary cache invalidations. - How to Test:
- Enable it (uncomment the line).
- Identify areas using
Rails.cache.fetch
with ActiveRecord relations (e.g., caching lists in views). - Verify that caching still works correctly.
- Test cache invalidation: Update a record within a cached collection and ensure the cache correctly reflects the change on the next fetch. Add/remove a record and verify the cache updates. Performance testing might be needed to see the benefit.
- Purpose: Enables cache versioning for collections (relations) cached using
Remember to test thoroughly in a staging environment after enabling each default.