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

It supports have_enqueud_mail matcher sub class of DeliveryJob. #2305

Merged
merged 3 commits into from Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 3 additions & 3 deletions lib/rspec/rails/matchers/have_enqueued_mail.rb
Expand Up @@ -131,15 +131,15 @@ def mail_job_message(job)
end

def legacy_mail?(job)
job[:job] == ActionMailer::DeliveryJob
job[:job] <= ActionMailer::DeliveryJob
end

def parameterized_mail?(job)
RSpec::Rails::FeatureCheck.has_action_mailer_parameterized? && job[:job] == ActionMailer::Parameterized::DeliveryJob
RSpec::Rails::FeatureCheck.has_action_mailer_parameterized? && job[:job] <= ActionMailer::Parameterized::DeliveryJob
end

def unified_mail?(job)
RSpec::Rails::FeatureCheck.has_action_mailer_unified_delivery? && job[:job] == ActionMailer::MailDeliveryJob
RSpec::Rails::FeatureCheck.has_action_mailer_unified_delivery? && job[:job] <= ActionMailer::MailDeliveryJob
end
end
# @api public
Expand Down
15 changes: 15 additions & 0 deletions spec/rspec/rails/matchers/have_enqueued_mail_spec.rb
Expand Up @@ -21,6 +21,15 @@ class UnifiedMailer < ActionMailer::Base
def test_email; end
def email_with_args(arg1, arg2); end
end

class SubClassDeliveryJob < ActionMailer::DeliveryJob
JonRowe marked this conversation as resolved.
Show resolved Hide resolved
end

class SubClassUnifiedMailer < ActionMailer::Base
JonRowe marked this conversation as resolved.
Show resolved Hide resolved
self.delivery_job = SubClassDeliveryJob
JonRowe marked this conversation as resolved.
Show resolved Hide resolved

def test_email; end
end
end
end

Expand Down Expand Up @@ -397,6 +406,12 @@ def self.name; "NonMailerJob"; end
a_hash_including(params: {'foo' => 'bar'}, args: [1, 2])
)
end

it "passes subclass delivery_job" do
JonRowe marked this conversation as resolved.
Show resolved Hide resolved
expect {
SubClassUnifiedMailer.test_email.deliver_later
JonRowe marked this conversation as resolved.
Show resolved Hide resolved
}.to have_enqueued_mail(SubClassUnifiedMailer, :test_email)
JonRowe marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
end