From f44362b1400f4ce38887c0b72e334ea145b4a365 Mon Sep 17 00:00:00 2001 From: Akshay Birajdar Date: Sat, 3 Sep 2022 03:02:24 +0530 Subject: [PATCH] Show BCC recipients in mailer preview --- railties/CHANGELOG.md | 4 +++ .../templates/rails/mailers/email.html.erb | 5 ++++ .../test/application/mailer_previews_test.rb | 30 +++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index ce539e6f66ab8..32d06d6bd55fa 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Show BCC recipients when present in Action Mailer previews. + + *Akshay Birajdar* + * Extend `routes --grep` to also filter routes by matching against path. Example: diff --git a/railties/lib/rails/templates/rails/mailers/email.html.erb b/railties/lib/rails/templates/rails/mailers/email.html.erb index 59c2f283df01a..0c5ff765d4f7e 100644 --- a/railties/lib/rails/templates/rails/mailers/email.html.erb +++ b/railties/lib/rails/templates/rails/mailers/email.html.erb @@ -80,6 +80,11 @@
<%= @email.header['cc'] %>
<% end %> + <% if @email.bcc %> +
BCC:
+
<%= @email.header['bcc'] %>
+ <% end %> +
Date:
<%= Time.current.rfc2822 %>
diff --git a/railties/test/application/mailer_previews_test.rb b/railties/test/application/mailer_previews_test.rb index 4651120b23ab4..354bf91182400 100644 --- a/railties/test/application/mailer_previews_test.rb +++ b/railties/test/application/mailer_previews_test.rb @@ -877,6 +877,36 @@ def foo assert_match "Mailer Preview for notifier#foo", last_response.body end + test "mailer preview sender tags" do + mailer "notifier", <<-RUBY + class Notifier < ActionMailer::Base + default from: "from@example.com" + def foo + mail to: "to@example.org", cc: "cc@example.com", bcc: "bcc@example.com" + end + end + RUBY + + text_template "notifier/foo", <<-RUBY + Hello, World! + RUBY + + mailer_preview "notifier", <<-RUBY + class NotifierPreview < ActionMailer::Preview + def foo + Notifier.foo + end + end + RUBY + + app("development") + + get "/rails/mailers/notifier/foo" + assert_match "
to@example.org
", last_response.body + assert_match "
cc@example.com
", last_response.body + assert_match "
bcc@example.com
", last_response.body + end + private def build_app super