aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-11-23 21:59:20 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-11-23 21:59:20 +0000
commitd933627044ff4aeaf81087902e0e8e3cff1dd356 (patch)
tree69ebc78e0df31ad19f13479a3c9887c79c4fe8b0 /actionpack/test
parent26f2fbf35f1e761c59323174dddce3c2314c8a3d (diff)
downloadrails-d933627044ff4aeaf81087902e0e8e3cff1dd356.tar.gz
rails-d933627044ff4aeaf81087902e0e8e3cff1dd356.tar.bz2
rails-d933627044ff4aeaf81087902e0e8e3cff1dd356.zip
Introduce :selected option to the select helper. Allows you to specify a selection other than the current value of object.method. Specify :selected => nil to leave all options unselected. Closes #2991.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3174 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/form_options_helper_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb
index 4d22f0cfef..76c556606c 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -283,6 +283,24 @@ class FormOptionsHelperTest < Test::Unit::TestCase
select("post", "category", %w( abe <mus> hest), :prompt => true, :include_blank => true)
)
end
+
+ def test_select_with_selected_value
+ @post = Post.new
+ @post.category = "<mus>"
+ assert_dom_equal(
+ "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\" selected=\"selected\">abe</option>\n<option value=\"&lt;mus&gt;\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>",
+ select("post", "category", %w( abe <mus> hest ), :selected => 'abe')
+ )
+ end
+
+ def test_select_with_selected_nil
+ @post = Post.new
+ @post.category = "<mus>"
+ assert_dom_equal(
+ "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>",
+ select("post", "category", %w( abe <mus> hest ), :selected => nil)
+ )
+ end
def test_collection_select
@posts = [