Posted 5 months ago. Visible to the public.

Do not forget mailer previews

When changing code in mailers, updating the corresponding mailer preview is easily forgotten.

Mailer previews can be tested like other code as well and I sometimes add the following test to test suites:

Copy
# Make sure to require the previews Dir[Rails.root.join('test/mailers/previews/*.rb')].sort.each { |file| require(file) } ActionMailer::Preview.all.index_with(&:emails).each do |preview, mails| mails.each do |mail| it "#{preview}##{mail} works" do expect { preview.call(mail) }.not_to raise_error end end end

This reminder solves the problem of broken mailer previews.

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for unsupported versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2).

Owner of this card:

Avatar
NiklasH
Last edit:
4 months ago
by Arne Hartherz
Keywords:
previews, actionmailer
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by NiklasH to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more