best-practices-badge icon indicating copy to clipboard operation
best-practices-badge copied to clipboard

Upgrade to Rails 6

Open david-a-wheeler opened this issue 5 years ago • 3 comments

Update to Rail 6.

I don't see the new functionality being something we want to jump to. Rails 6 adds the Trix editor, but it can't handle Markdown (and there's no clear plan to do so).

Rails 6 adds config.action_dispatch.use_cookies_with_metadata which enables writing cookies with the purpose and expiry metadata embedded. It defaults to true. Unfortunately, enabling that would log off everyone and generally be unfriendly. Rails 6 doesn't have any built-in graceful upgrade process where it only writes the cookie value without requiring it. We might be able to implement that by directly calling some cookie methods as defined in the original pull request for it: https://github.com/rails/rails/pull/32937/files

david-a-wheeler avatar May 02 '19 15:05 david-a-wheeler

More upgrade info here: https://medium.com/rubyinside/whats-coming-to-rails-6-0-8ec79eea66da

Key points:

  • config.action_dispatch.use_cookies_with_metadata = false (or handle specially)
  • Set up ActionDispatch::HostAuthorization
  • Enable parallel testing (that should be a big help)

Enabling parallel testing looks like:

class ActiveSupport::TestCase
  parallelize(workers: 2, with: :processes) # or :threads
end

david-a-wheeler avatar May 02 '19 19:05 david-a-wheeler

@jdossett @dankohn - I think we need to start prioritizing moving to Rails 6.

Our current version is only in vulnerability patch mode (bugs are no longer being fixed). We also can't easily upgrade to Ruby 2.7.1 with the current version of Rails. Ruby 2.7.1 deprecates certain practices that Rails 5 uses internally. So Rails 6 update needs to happen first.

If there are any "gotchas", someone please let me know!

david-a-wheeler avatar Aug 22 '20 18:08 david-a-wheeler

The gem fastly-rails was not compatible with Rails 6. It recommends switching to a different library, but that library doesn't support threading (!!). I fixed this by removing fastly-rails and calling the Fastly API directly.

The gem minitest-rails-capybara requires railties 5.X, while Rails 6 requires railties 6.X) The obvious solution is to switch to Rails’ system test framework, as Rails does now have a system test framework. I'm in the process of doing that now. I haven't found any real blockers, it just takes a little time. I'm trying to make the converted tests run in parallel (if they could not already), since Rails 6 supports parallel tests & that would speed up testing greatly.

I did a quick try after removing fastly-rails; much of the code seems to work on Rails 6, though there was an oddity in trying to log out that we'll need to check. So I think we're well on the path of switching to Rails 6.

david-a-wheeler avatar Jan 27 '21 19:01 david-a-wheeler