Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility for have_enqueued_mail (rails 7) #2537

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/rspec/rails/feature_check.rb
Expand Up @@ -28,13 +28,17 @@ def has_action_cable_testing?
end

def has_action_mailer_parameterized?
has_action_mailer? && defined?(::ActionMailer::Parameterized)
has_action_mailer? && defined?(::ActionMailer::Parameterized::DeliveryJob)
end

def has_action_mailer_unified_delivery?
has_action_mailer? && defined?(::ActionMailer::MailDeliveryJob)
end

def has_action_mailer_legacy_delivery_job?
defined?(ActionMailer::DeliveryJob)
end

def has_action_mailbox?
defined?(::ActionMailbox)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/rails/matchers/have_enqueued_mail.rb
Expand Up @@ -131,7 +131,7 @@ def mail_job_message(job)
end

def legacy_mail?(job)
job[:job] <= ActionMailer::DeliveryJob
RSpec::Rails::FeatureCheck.has_action_mailer_legacy_delivery_job? && job[:job] <= ActionMailer::DeliveryJob
end

def parameterized_mail?(job)
Expand Down
7 changes: 6 additions & 1 deletion spec/rspec/rails/matchers/have_enqueued_mail_spec.rb
Expand Up @@ -22,7 +22,12 @@ def test_email; end
def email_with_args(arg1, arg2); end
end

class DeliveryJobSubClass < ActionMailer::DeliveryJob
if RSpec::Rails::FeatureCheck.has_action_mailer_legacy_delivery_job?
class DeliveryJobSubClass < ActionMailer::DeliveryJob
end
else
class DeliveryJobSubClass < ActionMailer::MailDeliveryJob
end
end

class UnifiedMailerWithDeliveryJobSubClass < ActionMailer::Base
Expand Down