aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-04-04 21:25:44 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-04-04 21:25:47 -0300
commite936cf9c47e716a32b75703cb1a8badf96be8a6b (patch)
tree0ea2471df0eeff401de009c63469ca0aa0134421 /actionpack
parentaa3b6837b250db0a0df4c9779e0370e55ef3eb7f (diff)
downloadrails-e936cf9c47e716a32b75703cb1a8badf96be8a6b.tar.gz
rails-e936cf9c47e716a32b75703cb1a8badf96be8a6b.tar.bz2
rails-e936cf9c47e716a32b75703cb1a8badf96be8a6b.zip
Ensure mail_to helper does not modify the given html options hash
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb6
-rw-r--r--actionpack/test/template/url_helper_test.rb8
2 files changed, 10 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index a1468b6e90..bfe11fc1d7 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -425,8 +425,8 @@ module ActionView
# * <tt>:bcc</tt> - Blind Carbon Copy additional recipients on the email.
#
# ==== Obfuscation
- # Prior to Rails 4.0, +mail_to+ provided options for encoding the address
- # in order to hinder email harvesters. To take advantage of these options,
+ # Prior to Rails 4.0, +mail_to+ provided options for encoding the address
+ # in order to hinder email harvesters. To take advantage of these options,
# install the +actionview-encoded_mail_to+ gem.
#
# ==== Examples
@@ -451,7 +451,7 @@ module ActionView
def mail_to(email_address, name = nil, html_options = {}, &block)
html_options, name = name, nil if block_given?
html_options ||= {}
- html_options.stringify_keys!
+ html_options = html_options.stringify_keys
email_address = ERB::Util.html_escape(email_address)
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index e7b04d40c0..9b4c419807 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -543,11 +543,17 @@ class UrlHelperTest < ActiveSupport::TestCase
mail_to('me@example.com') { content_tag(:span, 'Email me') }
end
- def test_link_tag_with_block_and_options
+ def test_mail_to_with_block_and_options
assert_dom_equal %{<a class="special" href="mailto:me@example.com?cc=ccaddress%40example.com"><span>Email me</span></a>},
mail_to('me@example.com', cc: "ccaddress@example.com", class: "special") { content_tag(:span, 'Email me') }
end
+ def test_mail_to_does_not_modify_html_options_hash
+ options = { class: 'special' }
+ mail_to 'me@example.com', 'ME!', options
+ assert_equal({ class: 'special' }, options)
+ end
+
def protect_against_forgery?
self.request_forgery
end