Merge pull request #45935 from the-spectator/add_bcc_to_mailer_preview

Show BCC field in mailer preview
This commit is contained in:
Jonathan Hefner 2022-09-08 12:00:26 -05:00 committed by GitHub
commit bee6167977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 0 deletions

View File

@ -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:

View File

@ -80,6 +80,11 @@
<dd id="cc"><%= @email.header['cc'] %></dd>
<% end %>
<% if @email.bcc %>
<dt>BCC:</dt>
<dd id="bcc"><%= @email.header['bcc'] %></dd>
<% end %>
<dt>Date:</dt>
<dd id="date"><%= Time.current.rfc2822 %></dd>

View File

@ -877,6 +877,36 @@ module ApplicationTests
assert_match "<title>Mailer Preview for notifier#foo</title>", 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 "<dd id=\"to\">to@example.org</dd>", last_response.body
assert_match "<dd id=\"cc\">cc@example.com</dd>", last_response.body
assert_match "<dd id=\"bcc\">bcc@example.com</dd>", last_response.body
end
private
def build_app
super