aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorWaynn Lue <waynnlue@gmail.com>2011-08-11 00:30:45 -0700
committerWaynn Lue <waynnlue@gmail.com>2011-08-11 00:30:45 -0700
commit895d64531d25a76c1de2d4fec9aba68c0ee8c104 (patch)
tree97ae9ac48bbd5b50d6287284f328bef72429cbd6 /actionpack
parent54b83566ccb55ae4a9bdb163a6224fa946814457 (diff)
downloadrails-895d64531d25a76c1de2d4fec9aba68c0ee8c104.tar.gz
rails-895d64531d25a76c1de2d4fec9aba68c0ee8c104.tar.bz2
rails-895d64531d25a76c1de2d4fec9aba68c0ee8c104.zip
fix destructive stringify_keys for label_tag
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb4
-rw-r--r--actionpack/test/template/form_tag_helper_test.rb6
2 files changed, 8 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 2bbe0c175f..92349508e6 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -179,9 +179,9 @@ module ActionView
def label_tag(name = nil, content_or_options = nil, options = nil, &block)
options = content_or_options if block_given? && content_or_options.is_a?(Hash)
options ||= {}
- options.stringify_keys!
+ options = options.stringify_keys
options["for"] = sanitize_to_id(name) unless name.blank? || options.has_key?("for")
- content_tag :label, content_or_options || name.to_s.humanize, options, &block
+ content_tag :label, content_or_options.is_a?(Hash) ? options : (content_or_options || name.to_s.humanize), options, &block
end
# Creates a hidden form input field used to transmit data that would be lost due to HTTP's statelessness or
diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb
index ad31812273..c8e47e4f71 100644
--- a/actionpack/test/template/form_tag_helper_test.rb
+++ b/actionpack/test/template/form_tag_helper_test.rb
@@ -530,6 +530,12 @@ class FormTagHelperTest < ActionView::TestCase
assert_equal options, { :option => "random_option" }
end
+ def test_image_label_tag_options_symbolize_keys_side_effects
+ options = { :option => "random_option" }
+ actual = label_tag "submit source", "title", options
+ assert_equal options, { :option => "random_option" }
+ end
+
def protect_against_forgery?
false
end