diff options
author | Laura Paredes <laura@wearepeople.io> | 2014-03-31 20:51:13 +0200 |
---|---|---|
committer | Laura Paredes <laura@wearepeople.io> | 2014-03-31 20:51:13 +0200 |
commit | 95692c6179f987db84bb358de9091cc51a2736e0 (patch) | |
tree | 24b45e98a89d1ea9a4c76ea0c80feb00f67eeae5 | |
parent | be521ef6acaf13be027065e24b83461043fb0237 (diff) | |
download | rails-95692c6179f987db84bb358de9091cc51a2736e0.tar.gz rails-95692c6179f987db84bb358de9091cc51a2736e0.tar.bz2 rails-95692c6179f987db84bb358de9091cc51a2736e0.zip |
Add test for selected and disabled custom attributes in options_for_select
-rw-r--r-- | actionview/test/template/form_options_helper_test.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/actionview/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb index 50e9d132a7..fbafb7aa08 100644 --- a/actionview/test/template/form_options_helper_test.rb +++ b/actionview/test/template/form_options_helper_test.rb @@ -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=\"<USA>\" selected=\"selected\"><USA></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>" |