aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorDaniel Rodríguez Troitiño <drodrigueztroitino@yahoo.es>2008-09-12 23:56:56 +0200
committerPratik Naik <pratiknaik@gmail.com>2009-01-28 19:35:18 +0000
commit9a8e2a059c823498e0fb318f25b926a6d015ef87 (patch)
treebae72e71d9e754500f56688aef61e27ba88dc52d /actionpack/test
parent32eeb3e5211a4a7bfc7a1d0aa0cab1486bed3581 (diff)
downloadrails-9a8e2a059c823498e0fb318f25b926a6d015ef87.tar.gz
rails-9a8e2a059c823498e0fb318f25b926a6d015ef87.tar.bz2
rails-9a8e2a059c823498e0fb318f25b926a6d015ef87.zip
Ensure selected option is not ignored for collection_select. [#1037 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/form_options_helper_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb
index 86a0bb6a79..78548864ff 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -473,6 +473,22 @@ uses_mocha "FormOptionsHelperTest" do
assert_dom_equal expected, collection_select("post", "author_name", @posts, "author_name", "author_name", { :include_blank => true, :name => 'post[author_name][]' }, :multiple => true)
end
+ def test_collection_select_with_blank_and_selected
+ @posts = [
+ Post.new("<Abe> went home", "<Abe>", "To a little house", "shh!"),
+ Post.new("Babe went home", "Babe", "To a little house", "shh!"),
+ Post.new("Cabe went home", "Cabe", "To a little house", "shh!")
+ ]
+
+ @post = Post.new
+ @post.author_name = "Babe"
+
+ assert_dom_equal(
+ %{<select id="post_author_name" name="post[author_name]"><option value=""></option>\n<option value="&lt;Abe&gt;" selected="selected">&lt;Abe&gt;</option>\n<option value="Babe">Babe</option>\n<option value="Cabe">Cabe</option></select>},
+ collection_select("post", "author_name", @posts, "author_name", "author_name", {:include_blank => true, :selected => "<Abe>"})
+ )
+ end
+
def test_time_zone_select
@firm = Firm.new("D")
html = time_zone_select( "firm", "time_zone" )