mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #41451 from jonathanhefner/mail_to-support-options-when-no-name
Support mail_to options when name not specified
This commit is contained in:
commit
3c63f57a5c
2 changed files with 8 additions and 3 deletions
|
@ -468,9 +468,9 @@ module ActionView
|
|||
# mail_to "me@domain.com", "My email"
|
||||
# # => <a href="mailto:me@domain.com">My email</a>
|
||||
#
|
||||
# mail_to "me@domain.com", "My email", cc: "ccaddress@domain.com",
|
||||
# mail_to "me@domain.com", cc: "ccaddress@domain.com",
|
||||
# subject: "This is an example email"
|
||||
# # => <a href="mailto:me@domain.com?cc=ccaddress@domain.com&subject=This%20is%20an%20example%20email">My email</a>
|
||||
# # => <a href="mailto:me@domain.com?cc=ccaddress@domain.com&subject=This%20is%20an%20example%20email">me@domain.com</a>
|
||||
#
|
||||
# You can use a block as well if your link target is hard to fit into the name parameter. ERB example:
|
||||
#
|
||||
|
@ -481,7 +481,7 @@ module ActionView
|
|||
# <strong>Email me:</strong> <span>me@domain.com</span>
|
||||
# </a>
|
||||
def mail_to(email_address, name = nil, html_options = {}, &block)
|
||||
html_options, name = name, nil if block_given?
|
||||
html_options, name = name, nil if name.is_a?(Hash)
|
||||
html_options = (html_options || {}).stringify_keys
|
||||
|
||||
extras = %w{ cc bcc body subject reply_to }.map! { |item|
|
||||
|
|
|
@ -705,6 +705,11 @@ class UrlHelperTest < ActiveSupport::TestCase
|
|||
mail_to("me@example.com", "My email", cc: "ccaddress@example.com", bcc: "bccaddress@example.com", subject: "This is an example email", body: "This is the body of the message.", reply_to: "foo@bar.com")
|
||||
)
|
||||
|
||||
assert_dom_equal(
|
||||
%{<a href="mailto:me@example.com?cc=ccaddress%40example.com&bcc=bccaddress%40example.com&body=This%20is%20the%20body%20of%20the%20message.&subject=This%20is%20an%20example%20email&reply-to=foo%40bar.com">me@example.com</a>},
|
||||
mail_to("me@example.com", cc: "ccaddress@example.com", bcc: "bccaddress@example.com", subject: "This is an example email", body: "This is the body of the message.", reply_to: "foo@bar.com")
|
||||
)
|
||||
|
||||
assert_dom_equal(
|
||||
%{<a href="mailto:me@example.com?body=This%20is%20the%20body%20of%20the%20message.&subject=This%20is%20an%20example%20email">My email</a>},
|
||||
mail_to("me@example.com", "My email", cc: "", bcc: "", subject: "This is an example email", body: "This is the body of the message.")
|
||||
|
|
Loading…
Reference in a new issue