aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-08-11 14:13:54 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-08-11 14:17:01 -0300
commita513cc1862cc61fd9605352a58c5e36cc40cb574 (patch)
tree3206b4cf54ffcfb7c0800d6f2ba6b1315b12d6fc /actionpack/test
parente8e8617c390776e6d7b21ca79b99503a8afb19ae (diff)
downloadrails-a513cc1862cc61fd9605352a58c5e36cc40cb574.tar.gz
rails-a513cc1862cc61fd9605352a58c5e36cc40cb574.tar.bz2
rails-a513cc1862cc61fd9605352a58c5e36cc40cb574.zip
Ensure option_html_attributes does not modify the given option hashes
We can avoid creating extra hashes with #merge, and use #merge! instead.
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/form_options_helper_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb
index e1ce5c5568..f908de865e 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -1193,6 +1193,15 @@ class FormOptionsHelperTest < ActionView::TestCase
)
end
+ def test_option_html_attributes_with_multiple_hashes_does_not_modify_them
+ options1 = { class: 'fancy' }
+ options2 = { onclick: "alert('Hello World');" }
+ option_html_attributes([ 'foo', 'bar', options1, options2 ])
+
+ assert_equal({ class: 'fancy' }, options1)
+ assert_equal({ onclick: "alert('Hello World');" }, options2)
+ end
+
def test_grouped_collection_select
@post = Post.new
@post.origin = 'dk'