Add test for selected and disabled custom attributes in options_for_select

This commit is contained in:
Laura Paredes 2014-03-31 20:51:13 +02:00
parent be521ef6ac
commit 95692c6179
1 changed files with 21 additions and 1 deletions

View File

@ -119,6 +119,26 @@ class FormOptionsHelperTest < ActionView::TestCase
)
end
def test_array_options_for_select_with_custom_defined_selected
assert_dom_equal(
"<option selected=\"selected\" type=\"Coach\" value=\"1\">Richard Bandler</option>\n<option type=\"Coachee\" value=\"1\">Richard Bandler</option>",
options_for_select([
['Richard Bandler', 1, { type: 'Coach', selected: 'selected' }],
['Richard Bandler', 1, { type: 'Coachee' }]
])
)
end
def test_array_options_for_select_with_custom_defined_disabled
assert_dom_equal(
"<option disabled=\"disabled\" type=\"Coach\" value=\"1\">Richard Bandler</option>\n<option type=\"Coachee\" value=\"1\">Richard Bandler</option>",
options_for_select([
['Richard Bandler', 1, { type: 'Coach', disabled: 'disabled' }],
['Richard Bandler', 1, { type: 'Coachee' }]
])
)
end
def test_array_options_for_select_with_selection
assert_dom_equal(
"<option value=\"Denmark\">Denmark</option>\n<option value=\"&lt;USA&gt;\" selected=\"selected\">&lt;USA&gt;</option>\n<option value=\"Sweden\">Sweden</option>",
@ -813,7 +833,7 @@ class FormOptionsHelperTest < ActionView::TestCase
select("post", "category", %w( one two ), :selected => 'two', :prompt => true)
)
end
def test_select_with_disabled_array
@post = Post.new
@post.category = "<mus>"