Conversation
The commit that added lock_thread (f638085) notes that > Transaction management is largely ripped straight out of > test_fixtures.rb in Rails The commit that adds lock_thread in Rails -- rails/rails@d6466be -- 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.
Taken from #165, hence the coauthor credit. Co-authored-by: Georg Ledermann <georg@ledermann.dev>
Use symlinks for multiple Gemfiles.
This prevents us from installing gems in the example app that aren't needed by a different gemfile.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hopefully takes care of #164.
There are 3 significant changes in this PR:
1. Remove
lock_threadon connection poolThe commit that added
lock_thread(f638085) notes thatThe commit that adds
lock_threadin Rails has some helpful context:So
lock_threadexists 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 #164 to do real world testing.
(Aside for breadcrumbs, the commits that remove
lock_threadare rails/rails@26de25d and rails/rails@1dcb411.)2. Use
#lease_connectioninstead of#connection(when available)This change is ripped straight from #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
Gemfileto do the right Rails version, paired with some use ofBUNDLE_GEMFILE.