Skip to content

Fix previewing emails in development

Brett Walker requested to merge bw-fix-premailer into master

What does this MR do and why?

During development, it's useful to be able to view emails that are being sent using localhost:3000/rails/letter_opener, or preview an email template using localhost:3000/rails/mailers. However this is generating an error. For example when visiting http://localhost:3000/rails/mailers/notify/closed_issue_email, we get the error File with URL "http://ee.gitlab.test:5100/assets/notify_enhanced-74e6f88f03519643ec6a113d0da2c2fbf045c726da22c78ec8371e0a05bec314.css" could not be loaded by any strategy.. When actually triggering an email, the Sidekiq job fails with the same error and never delivers the email to letter_opener

We're currently using the prevailer-rails gem to apply css styles to the HTML email. In order to do this, the gem pulls in a css file.

It uses different strategies to locate the css file. We currently only use :asset_pipeline. However it's not finding the file in asset pipeline. By adding the :filesystem strategy when in development, the proper css files can be found

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

Start your local instance and visit http://localhost:3000/rails/mailers/notify/closed_issue_email - you should see the closed issue email. You can also go to an issue with multiple participants and close or reopen it. You should then see the proper notification emails in http://localhost:3000/rails/letter_opener.

Remove the change from config/initializers/premailer.rb to see the error generated.

Edited by Brett Walker

Merge request reports