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:
parent
19d7b1d22b
commit
6e3521e613
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue