Skip to content

Commit 3b36479

Browse files
committed
Drop 6.1 related code
1 parent 4dd9521 commit 3b36479

File tree

5 files changed

+6
-31
lines changed

5 files changed

+6
-31
lines changed

lib/rspec/rails/fixture_support.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ module FixtureSupport
1010
include ActiveRecord::TestFixtures
1111

1212
# @private prevent ActiveSupport::TestFixtures to start a DB transaction.
13-
# Monkey patched to avoid collisions with 'let(:name)' in Rails 6.1 and after
14-
# and let(:method_name) before Rails 6.1.
13+
# Monkey patched to avoid collisions with 'let(:name)' since Rails 6.1
1514
def run_in_transaction?
1615
current_example_name = (RSpec.current_example && RSpec.current_example.metadata[:description])
1716
use_transactional_tests && !self.class.uses_transaction?(current_example_name)

lib/rspec/rails/matchers/active_job.rb

+3-14
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ def base_job_message(job)
148148
msg_parts << "on queue #{job[:queue]}" if job[:queue]
149149
msg_parts << "at #{Time.at(job[:at])}" if job[:at]
150150
msg_parts <<
151-
if fetch_priority(job)
152-
"with priority #{fetch_priority(job)}"
151+
if job[:priority]
152+
"with priority #{job[:priority]}"
153153
else
154154
"with no priority specified"
155155
end
@@ -167,17 +167,6 @@ def job_matches?(job)
167167
@job ? @job == job[:job] : true
168168
end
169169

170-
# Rails 6.1 serializes the priority with a string key
171-
if ::Rails.version.to_f >= 7
172-
def fetch_priority(job)
173-
job[:priority]
174-
end
175-
else
176-
def fetch_priority(job)
177-
job['priority']
178-
end
179-
end
180-
181170
def arguments_match?(job)
182171
if @args.any?
183172
args = serialize_and_deserialize_arguments(@args)
@@ -218,7 +207,7 @@ def queue_match?(job)
218207
def priority_match?(job)
219208
return true unless @priority
220209

221-
@priority == fetch_priority(job)
210+
@priority == job[:priority]
222211
end
223212

224213
def at_match?(job)

snippets/avoid_fixture_name_collision.rb

-3
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@
4747
RSpec.describe 'Foo' do
4848
subject { true }
4949

50-
# Rails 6.1 and after
5150
let(:name) { raise "Should never raise" }
52-
# Before Rails 6.1
53-
let(:method_name) { raise "Should never raise" }
5451

5552
it { is_expected.to be_truthy }
5653
end

snippets/include_activesupport_testing_tagged_logger.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ def perform
5656

5757
describe 'error raised in perform_enqueued_jobs with block' do
5858
it 'raises the explicitly thrown error' do
59-
# Rails 6.1+ wraps unexpected errors in tests
60-
expected_error = if Rails::VERSION::STRING.to_f >= 6.1
61-
Minitest::UnexpectedError.new(TestError)
62-
else
63-
TestError
64-
end
59+
expected_error = Minitest::UnexpectedError.new(TestError)
6560

6661
expect { perform_enqueued_jobs { TestJob.perform_later } }
6762
.to raise_error(expected_error)

spec/rspec/rails/example/controller_example_group_spec.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,7 @@ def my_helper
5454
end
5555
end
5656

57-
# Rails 6.1 removes config from ./activerecord/lib/active_record/test_fixtures.rb
58-
if respond_to?(:config)
59-
config.include mod
60-
else
61-
ActiveRecord::Base.include mod
62-
end
57+
ActiveRecord::Base.include mod
6358

6459
group.class_exec do
6560
let(:my_helper) { "my_value" }

0 commit comments

Comments
 (0)