From c4e26479750d27227c6491371685ec24800d62a7 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Wed, 10 Mar 2021 10:01:00 +0100 Subject: [PATCH] Fix support for Rails 4.2 Rails 4.2 does not have `use_transactional_tests` defined Fix #2477 --- lib/rspec/rails/fixture_support.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/rspec/rails/fixture_support.rb b/lib/rspec/rails/fixture_support.rb index 12acfdfbd6..017993dada 100644 --- a/lib/rspec/rails/fixture_support.rb +++ b/lib/rspec/rails/fixture_support.rb @@ -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