Skip to content

Commit

Permalink
Fix support for Rails 4.2
Browse files Browse the repository at this point in the history
Rails 4.2 does not have `use_transactional_tests` defined

Fix #2477
  • Loading branch information
tagliala committed Mar 10, 2021
1 parent c100cf1 commit c4e2647
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/rspec/rails/fixture_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ module FixtureSupport
# @private prevent ActiveSupport::TestFixtures to start a DB transaction.
# Monkey patched to avoid collisions with 'let(:name)' in Rails 6.1 and after
# and let(:method_name) before Rails 6.1.
def run_in_transaction?
use_transactional_tests && !self.class.uses_transaction?(self)
if ::Rails::VERSION::STRING > '5'
def run_in_transaction?
use_transactional_tests && !self.class.uses_transaction?(self)
end
else
def run_in_transaction?
use_transactional_fixtures && !self.class.uses_transaction?(self)
end
end

included do
Expand Down

0 comments on commit c4e2647

Please sign in to comment.