Ensure mail_to helper does not modify the given html options hash
This commit is contained in:
parent
aa3b6837b2
commit
e936cf9c47
@ -451,7 +451,7 @@ def link_to_if(condition, name, options = {}, html_options = {}, &block)
|
||||
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)
|
||||
|
||||
|
@ -543,11 +543,17 @@ def test_mail_to_with_block
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user