3.2 KiB
-
Deprecate passing params to
assert_enqueued_email_with
via the:args
kwarg.assert_enqueued_email_with
now supports a:params
kwarg, so use that to pass params:# BEFORE assert_enqueued_email_with MyMailer, :my_method, args: { my_param: "value" } # AFTER assert_enqueued_email_with MyMailer, :my_method, params: { my_param: "value" }
To specify named mailer args as a Hash, wrap the Hash in an array:
assert_enqueued_email_with MyMailer, :my_method, args: [{ my_arg: "value" }] # OR assert_enqueued_email_with MyMailer, :my_method, args: [my_arg: "value"]
Jonathan Hefner
-
Accept procs for args and params in
assert_enqueued_email_with
assert_enqueued_email_with DeliveryJob, params: -> p { p[:token] =~ /\w+/ } do UserMailer.with(token: user.generate_token).email_verification.deliver_later end
Max Chernyak
-
Added
*_deliver
callbacks toActionMailer::Base
that wrap mail message delivery.Example:
class EventsMailer < ApplicationMailer after_deliver do User.find_by(email: message.to.first).update(email_provider_id: message.message_id, emailed_at: Time.current) end end
Ben Sheldon
-
Added
deliver_enqueued_emails
toActionMailer::TestHelper
. This method delivers all enqueued email jobs.Example:
def test_deliver_enqueued_emails deliver_enqueued_emails do ContactMailer.welcome.deliver_later end assert_emails 1 end
Andrew Novoselac
-
The
deliver_later_queue_name
used by the default mailer job can now be configured on a per-mailer basis. Previously this was only configurable for all mailers viaActionMailer::Base
.Example:
class EventsMailer < ApplicationMailer self.deliver_later_queue_name = :throttled_mailer end
Jeffrey Hardy
-
Email previews now include an expandable section to show all headers.
Headers like
Message-ID
for threading or email service provider specific features like analytics tags or account metadata can now be viewed directly in the mailer preview.Matt Swanson
-
Default
ActionMailer::Parameterized#params
to an emptyHash
Sean Doyle
-
Introduce the
capture_emails
test helper.Returns all emails that are sent in a block.
def test_emails emails = capture_emails do ContactMailer.welcome.deliver_now ContactMailer.welcome.deliver_later end assert_email "Hi there", emails.first.subject end
Alex Ghiculescu
-
Added ability to download
.eml
file for the email preview.Igor Kasyanchuk
-
Support multiple preview paths for mailers.
Option
config.action_mailer.preview_path
is deprecated in favor ofconfig.action_mailer.preview_paths
. Appending paths to this configuration option will cause those paths to be used in the search for mailer previews.fatkodima
Please check 7-0-stable for previous changes.