You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried but ran into issues with threading. Specifically, I'd get errors like Read: #<ActiveRecord::ActiveRecordError: Cannot expire connection, it is owned by a different thread: #<Thread:0x0000000111657040@puma srv tp 004 and #<ActiveRecord::ConnectionTimeoutError: could not obtain a connection from the pool within 5.000 seconds (waited 5.003 seconds); all pooled connections were in use>
class Fixtures
include ActiveRecord::TestFixtures
extend ActiveSupport::Concern
def run_in_transaction?
true
end
included do
self.use_transactional_tests = true
self.use_instantiated_fixtures = false
end
end
@@fixtures ||= Fixtures.new
# teardown is done *before* each step to follow Cypress best practices of
# tearing down state only in *before* hooks:
# https://docs.cypress.io/guides/references/best-practices#Using-after-or-afterEach-hooks
if @@fixtures.respond_to?(:@fixture_connections, true) &&
@@fixtures.send(:@fixture_connections).any?
@@fixtures.teardown_fixtures
end
@@fixtures.setup_fixtures
This builds on #26, I suppose
Rails has built-in transactional fixtures, which should mean database cleaner is never needed: https://anti-pattern.com/transactional-fixtures-in-rails
As far as I can tell, this just means including
ActiveRecord::TestFixtures
, then callingsetup_fixtures
andteardown_fixtures
. See https://github.com/rails/rails/blob/812bae8167488ee5984043ef71125e055352b873/activerecord/lib/active_record/test_fixtures.rbThe text was updated successfully, but these errors were encountered: