Skip to content

Commit 91c1b34

Browse files
pirjmhenrixon
andcommitted
Fix removed ActionMailer::DeliveryJob in Rails 7
fixes #2531 Co-authored-by: Mikael Henriksson <[email protected]>
1 parent 1fe6c2e commit 91c1b34

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

lib/rspec/rails/feature_check.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ def has_action_cable_testing?
2828
end
2929

3030
def has_action_mailer_parameterized?
31-
has_action_mailer? && defined?(::ActionMailer::Parameterized)
31+
has_action_mailer? && defined?(::ActionMailer::Parameterized::DeliveryJob)
3232
end
3333

3434
def has_action_mailer_unified_delivery?
3535
has_action_mailer? && defined?(::ActionMailer::MailDeliveryJob)
3636
end
3737

38+
def has_action_mailer_legacy_delivery_job?
39+
defined?(ActionMailer::DeliveryJob)
40+
end
41+
3842
def has_action_mailbox?
3943
defined?(::ActionMailbox)
4044
end

lib/rspec/rails/matchers/have_enqueued_mail.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def mail_job_message(job)
131131
end
132132

133133
def legacy_mail?(job)
134-
job[:job] <= ActionMailer::DeliveryJob
134+
RSpec::Rails::FeatureCheck.has_action_mailer_legacy_delivery_job? && job[:job] <= ActionMailer::DeliveryJob
135135
end
136136

137137
def parameterized_mail?(job)

spec/rspec/rails/matchers/have_enqueued_mail_spec.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ def test_email; end
2222
def email_with_args(arg1, arg2); end
2323
end
2424

25-
class DeliveryJobSubClass < ActionMailer::DeliveryJob
25+
if RSpec::Rails::FeatureCheck.has_action_mailer_legacy_delivery_job?
26+
class DeliveryJobSubClass < ActionMailer::DeliveryJob
27+
end
28+
else
29+
class DeliveryJobSubClass < ActionMailer::MailDeliveryJob
30+
end
2631
end
2732

2833
class UnifiedMailerWithDeliveryJobSubClass < ActionMailer::Base

0 commit comments

Comments
 (0)