diff options
-rw-r--r-- | actionview/lib/action_view/helpers/url_helper.rb | 5 | ||||
-rw-r--r-- | actionview/test/template/url_helper_test.rb | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index 364414da05..4c53b5df9e 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -458,8 +458,9 @@ module ActionView html_options = (html_options || {}).stringify_keys extras = %w{ cc bcc body subject }.map! { |item| - option = html_options.delete(item) || next - "#{item}=#{Rack::Utils.escape_path(option)}" + if option = html_options.delete(item).presence + "#{item}=#{Rack::Utils.escape_path(option)}" + end }.compact extras = extras.empty? ? '' : '?' + extras.join('&') diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index e0678ae1f7..caff0dc6f6 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -496,6 +496,11 @@ class UrlHelperTest < ActiveSupport::TestCase %{<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">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.") ) + + 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.") + ) end def test_mail_to_with_img |