Improve check_box_checked? to use include? for Array values. [#193 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
Erkki Eilonen 2008-05-14 17:07:21 +03:00 committed by Pratik Naik
parent 19d7b1d22b
commit 6e3521e613
2 changed files with 13 additions and 0 deletions

View File

@ -616,6 +616,8 @@ module ActionView
value != 0
when String
value == checked_value
when Array
value.include?(checked_value)
else
value.to_i != 0
end

View File

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