Permalink
Browse files

Ensure radio_button works as expected with values other than strings.

Thanks to:
*  grant.mcinnes@utoronto.ca
*  rails@jeffcole.net



git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2573 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent acb80e3 commit 59709d9188b7afff3ee53a4a20b9e40a7699e298 @NZKoz NZKoz committed Oct 14, 2005
@@ -174,7 +174,7 @@ def to_radio_button_tag(tag_value, options = {})
options = DEFAULT_RADIO_OPTIONS.merge(options.stringify_keys)
options["type"] = "radio"
options["value"] = tag_value
- options["checked"] = "checked" if value == tag_value
+ options["checked"] = "checked" if value.to_s == tag_value.to_s
pretty_tag_value = tag_value.to_s.gsub(/\s/, "_").gsub(/\W/, "").downcase
options["id"] = @auto_index ?
"#{@object_name}_#{@auto_index}_#{@method_name}_#{pretty_tag_value}" :
@@ -98,6 +98,12 @@ def test_radio_button
)
end
+ def test_radio_button_is_checked_with_integers
+ assert_dom_equal('<input checked="checked" id="post_secret_1" name="post[secret]" type="radio" value="1" />',
+ radio_button("post", "secret", "1")
+ )
+ end
+
def test_text_area
assert_dom_equal(
'<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea>',

0 comments on commit 59709d9

Please sign in to comment.