aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template
diff options
context:
space:
mode:
authorLaura Paredes <laura@wearepeople.io>2014-03-31 20:51:13 +0200
committerLaura Paredes <laura@wearepeople.io>2014-03-31 20:51:13 +0200
commit95692c6179f987db84bb358de9091cc51a2736e0 (patch)
tree24b45e98a89d1ea9a4c76ea0c80feb00f67eeae5 /actionview/test/template
parentbe521ef6acaf13be027065e24b83461043fb0237 (diff)
downloadrails-95692c6179f987db84bb358de9091cc51a2736e0.tar.gz
rails-95692c6179f987db84bb358de9091cc51a2736e0.tar.bz2
rails-95692c6179f987db84bb358de9091cc51a2736e0.zip
Add test for selected and disabled custom attributes in options_for_select
Diffstat (limited to 'actionview/test/template')
-rw-r--r--actionview/test/template/form_options_helper_test.rb22
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=\"&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>"