Skip to content

Commit

Permalink
Drop 6.1 related code
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Sep 2, 2024
1 parent 4dd9521 commit 3b36479
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 31 deletions.
3 changes: 1 addition & 2 deletions lib/rspec/rails/fixture_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ module FixtureSupport
include ActiveRecord::TestFixtures

# @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.
# Monkey patched to avoid collisions with 'let(:name)' since Rails 6.1
def run_in_transaction?
current_example_name = (RSpec.current_example && RSpec.current_example.metadata[:description])
use_transactional_tests && !self.class.uses_transaction?(current_example_name)
Expand Down
17 changes: 3 additions & 14 deletions lib/rspec/rails/matchers/active_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def base_job_message(job)
msg_parts << "on queue #{job[:queue]}" if job[:queue]
msg_parts << "at #{Time.at(job[:at])}" if job[:at]
msg_parts <<
if fetch_priority(job)
"with priority #{fetch_priority(job)}"
if job[:priority]
"with priority #{job[:priority]}"
else
"with no priority specified"
end
Expand All @@ -167,17 +167,6 @@ def job_matches?(job)
@job ? @job == job[:job] : true
end

# Rails 6.1 serializes the priority with a string key
if ::Rails.version.to_f >= 7
def fetch_priority(job)
job[:priority]
end
else
def fetch_priority(job)
job['priority']
end
end

def arguments_match?(job)
if @args.any?
args = serialize_and_deserialize_arguments(@args)
Expand Down Expand Up @@ -218,7 +207,7 @@ def queue_match?(job)
def priority_match?(job)
return true unless @priority

@priority == fetch_priority(job)
@priority == job[:priority]
end

def at_match?(job)
Expand Down
3 changes: 0 additions & 3 deletions snippets/avoid_fixture_name_collision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@
RSpec.describe 'Foo' do
subject { true }

# Rails 6.1 and after
let(:name) { raise "Should never raise" }
# Before Rails 6.1
let(:method_name) { raise "Should never raise" }

it { is_expected.to be_truthy }
end
7 changes: 1 addition & 6 deletions snippets/include_activesupport_testing_tagged_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ def perform

describe 'error raised in perform_enqueued_jobs with block' do
it 'raises the explicitly thrown error' do
# Rails 6.1+ wraps unexpected errors in tests
expected_error = if Rails::VERSION::STRING.to_f >= 6.1
Minitest::UnexpectedError.new(TestError)
else
TestError
end
expected_error = Minitest::UnexpectedError.new(TestError)

expect { perform_enqueued_jobs { TestJob.perform_later } }
.to raise_error(expected_error)
Expand Down
7 changes: 1 addition & 6 deletions spec/rspec/rails/example/controller_example_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ def my_helper
end
end

# Rails 6.1 removes config from ./activerecord/lib/active_record/test_fixtures.rb
if respond_to?(:config)
config.include mod
else
ActiveRecord::Base.include mod
end
ActiveRecord::Base.include mod

group.class_exec do
let(:my_helper) { "my_value" }
Expand Down

0 comments on commit 3b36479

Please sign in to comment.