1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #8002 from nashby/checkbox-include

check_box value can be not only an object of Array class
This commit is contained in:
Rafael Mendonça França 2012-10-20 12:43:03 -07:00
commit 3be9e8a0c2
2 changed files with 11 additions and 3 deletions

View file

@ -46,10 +46,12 @@ module ActionView
false
when String
value == @checked_value
when Array
value.include?(@checked_value)
else
value.to_i == @checked_value.to_i
if value.respond_to?(:include?)
value.include?(@checked_value)
else
value.to_i == @checked_value.to_i
end
end
end

View file

@ -400,6 +400,12 @@ class FormHelperTest < ActionView::TestCase
'<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
check_box("post", "secret")
)
@post.secret = Set.new(['1'])
assert_dom_equal(
'<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
check_box("post", "secret")
)
end
def test_check_box_with_include_hidden_false