cypress-rails
cypress-rails copied to clipboard
Add Rails 7.2 compatibility
Hopefully takes care of https://github.com/testdouble/cypress-rails/issues/164.
There are 3 significant changes in this PR:
1. Remove lock_thread
on connection pool
The commit that added lock_thread
(https://github.com/testdouble/cypress-rails/commit/f6380859e82193c6a16bdbf2950b933054f65355) notes that
Transaction management is largely ripped straight out of test_fixtures.rb in Rails
The commit that adds lock_thread
in Rails has some helpful context:
When a system test starts Puma spins up one thread and Capybara spins up another thread. Because of this when tests are run the database cannot see what was inserted into the database on teardown. This is because there are two threads using two different connections.
This change uses the statement cache to lock the threads to using a single connection ID instead of each not being able to see each other.
So lock_thread
exists because there are two different threads — Puma and Capybara — trying to access the same database but not necessarily seeing the same thing. But! cypress-rails doesn't use Capybara, and more importantly, it doesn't use tests or a test runner written in Ruby at all, so there's only one thread trying to use the database. So we don't need all this thread locking stuff. So let's remove it to make things more compatible with Rails 7.2. Hat tip to @tinney for saying this to my face before I came around to it. 😅
I think I'm right about this, but I plan to do a pre-release with these changes and try to get some folks from https://github.com/testdouble/cypress-rails/issues/164 to do real world testing.
(Aside for breadcrumbs, the commits that remove lock_thread
are https://github.com/rails/rails/commit/26de25d7ee13a00d188c98bbe455bbc79695ce52 and https://github.com/rails/rails/commit/1dcb41142953e12c308900159893ddd74aaa0026.)
2. Use #lease_connection
instead of #connection
(when available)
This change is ripped straight from https://github.com/testdouble/cypress-rails/pull/165, so thank you to @ledermann! 🙇
3. Build and test the example app with both Rails 7.1 and 7.2
Rails 7.1 is still supported, and I wouldn't be surprised if we end up with 3 simultaneously supported versions at some point: 7.1, 7.2, and 8.0. I'd like the tests to cover all versions we support so that we can feel more confident in changes.
I went about this with symlinked Gemfiles (hat tip to @jasonkarns on this one) with some logic in Gemfile
to do the right Rails version, paired with some use of BUNDLE_GEMFILE
.