Previewing email notifications during development is hard. Previously I've 
set up the [mailcatcher](https://mailcatcher.me/) gem and configured the app to 
send emails to the right place. But nowadays rails has a built-in option - 
[ActionMailer::Preview](https://guides.rubyonrails.org/action_mailer_basics.html#previewing-and-testing-mailers),
 so let's use that.

The previews run using the development database, which may or may not already 
contain sufficient records (e.g. diary comments). So to avoid failures, we 
generate content using factory bot, and to avoid filling your development 
database with duplicate data, we run the previews inside a transaction.

If you manually create records in the database that collide with factory bot 
(e.g. users with the same email pattern as the factory) then you'll need to 
update your manual records to avoid collisions.

My hope is that this will make it much easier for new contributors to work on 
the email notifications. If this PR is merged, then I intend to add an example 
of each outbound email to the previews.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/6449

-- Commit Summary --

  * Enable ActionMailer Previews

-- File Changes --

    M CONFIGURE.md (4)
    A test/mailers/previews/user_mailer_preview.rb (25)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/6449.patch
https://github.com/openstreetmap/openstreetmap-website/pull/6449.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6449
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/[email protected]>
_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to