do not generate blank options in mailTo

when mail_to generate blank options for any passed options(cc, bcc, body, subject)
then MICROSOFT OUTLOOK treats it differently and set wrong values in different options.
This commit is contained in:
Kuldeep Aggarwal 2014-09-13 00:57:53 +05:30
parent 7b740f31cc
commit a13ad4a6c1
2 changed files with 8 additions and 2 deletions

@ -458,8 +458,9 @@ def mail_to(email_address, name = nil, html_options = {}, &block)
html_options = (html_options || {}).stringify_keys html_options = (html_options || {}).stringify_keys
extras = %w{ cc bcc body subject }.map! { |item| extras = %w{ cc bcc body subject }.map! { |item|
option = html_options.delete(item) || next if option = html_options.delete(item).presence
"#{item}=#{Rack::Utils.escape_path(option)}" "#{item}=#{Rack::Utils.escape_path(option)}"
end
}.compact }.compact
extras = extras.empty? ? '' : '?' + extras.join('&') extras = extras.empty? ? '' : '?' + extras.join('&')

@ -496,6 +496,11 @@ def test_mail_with_options
%{<a href="mailto:me@example.com?cc=ccaddress%40example.com&amp;bcc=bccaddress%40example.com&amp;body=This%20is%20the%20body%20of%20the%20message.&amp;subject=This%20is%20an%20example%20email">My email</a>}, %{<a href="mailto:me@example.com?cc=ccaddress%40example.com&amp;bcc=bccaddress%40example.com&amp;body=This%20is%20the%20body%20of%20the%20message.&amp;subject=This%20is%20an%20example%20email">My email</a>},
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.") 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.")
) )
assert_dom_equal(
%{<a href="mailto:me@example.com?body=This%20is%20the%20body%20of%20the%20message.&amp;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.")
)
end end
def test_mail_to_with_img def test_mail_to_with_img