提交 6e3521e6 编写于 作者: E Erkki Eilonen 提交者: Pratik Naik

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

Signed-off-by: NPratik Naik <pratiknaik@gmail.com>
上级 19d7b1d2
......@@ -616,6 +616,8 @@ def check_box_checked?(value, checked_value)
value != 0
when String
value == checked_value
when Array
value.include?(checked_value)
else
value.to_i != 0
end
......
......@@ -181,6 +181,17 @@ def test_check_box
'<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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册