module ActionMailer::TestHelper
def deliver_enqueued_emails(queue: nil, at: nil, &block)
If the +:at+ option is specified, then only delivers emails enqueued to deliver
end
assert_emails 1
end
EmployeeMailer.welcome.deliver_later # will not be performed
EmployeeMailer.deliver_later_queue_name = :internal_mailers
CustomerMailer.welcome.deliver_later # will be performed
CustomerMailer.deliver_later_queue_name = :external_mailers
deliver_enqueued_emails queue: :external_mailers do
def test_deliver_enqueued_emails_with_queue
then only the emails(s) enqueued to a specific queue will be performed.
If the +:queue+ option is specified,
end
assert_emails 1
deliver_enqueued_emails
ContactMailer.welcome.deliver_later
def test_deliver_enqueued_emails_without_block
end
assert_emails 1
end
ContactMailer.welcome.deliver_later
deliver_enqueued_emails do
def test_deliver_enqueued_emails
not given, delivers all the enqueued emails up to this point in the test.
that were enqueued throughout the duration of the block. If a block is
Delivers all enqueued emails. If a block is given, delivers all of the emails
def deliver_enqueued_emails(queue: nil, at: nil, &block) perform_enqueued_jobs(only: ->(job) { delivery_job_filter(job) }, queue: queue, at: at, &block) end