From c52edf2319eccf0feafcec7ac4fd0164011a06db Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 3 Jul 2005 12:23:16 +0000 Subject: Added :prompt option to FormOptions#select (and the users of it, like FormOptions#select_country etc) to create "Please select" style descriptors #1181 [Michael Schuerig] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1646 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../test/template/form_options_helper_test.rb | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb index 2d96bc8099..7a83f57341 100644 --- a/actionpack/test/template/form_options_helper_test.rb +++ b/actionpack/test/template/form_options_helper_test.rb @@ -221,6 +221,42 @@ class FormOptionsHelperTest < Test::Unit::TestCase ) end + def test_select_with_default_prompt + @post = Post.new + @post.category = "" + assert_equal( + "", + select("post", "category", %w( abe hest), :prompt => true) + ) + end + + def test_select_no_prompt_when_select_has_value + @post = Post.new + @post.category = "" + assert_equal( + "", + select("post", "category", %w( abe hest), :prompt => true) + ) + end + + def test_select_with_given_prompt + @post = Post.new + @post.category = "" + assert_equal( + "", + select("post", "category", %w( abe hest), :prompt => 'The prompt') + ) + end + + def test_select_with_prompt_and_blank + @post = Post.new + @post.category = "" + assert_equal( + "", + select("post", "category", %w( abe hest), :prompt => true, :include_blank => true) + ) + end + def test_collection_select @posts = [ Post.new(" went home", "", "To a little house", "shh!"), -- cgit v1.2.3