Allow radio buttons to work with booleans.
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
parent
1191e3ffaf
commit
c34d6279a0
@ -872,8 +872,8 @@ def radio_button_checked?(value, checked_value)
|
||||
|
||||
private
|
||||
def add_default_name_and_id_for_value(tag_value, options)
|
||||
if tag_value
|
||||
pretty_tag_value = tag_value.to_s.gsub(/\s/, "_").gsub(/\W/, "").downcase
|
||||
unless tag_value.nil?
|
||||
pretty_tag_value = tag_value.to_s.gsub(/\s/, "_").gsub(/\W/, "").downcase
|
||||
specified_id = options["id"]
|
||||
add_default_name_and_id(options)
|
||||
options["id"] += "_#{pretty_tag_value}" unless specified_id
|
||||
|
@ -307,6 +307,16 @@ def test_radio_button_respects_passed_in_id
|
||||
)
|
||||
end
|
||||
|
||||
def test_radio_button_with_booleans
|
||||
assert_dom_equal('<input id="post_secret_true" name="post[secret]" type="radio" value="true" />',
|
||||
radio_button("post", "secret", true)
|
||||
)
|
||||
|
||||
assert_dom_equal('<input id="post_secret_false" name="post[secret]" type="radio" value="false" />',
|
||||
radio_button("post", "secret", false)
|
||||
)
|
||||
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>',
|
||||
|
Loading…
Reference in New Issue
Block a user