diff options
author | Brian Rose <brian@heimidal.net> | 2011-12-20 13:19:55 -0700 |
---|---|---|
committer | Brian Rose <brian@heimidal.net> | 2011-12-20 13:26:10 -0700 |
commit | bd89946dd3ededc5850f1b9754cb39cf0331637a (patch) | |
tree | 06315682509d34fec7c72df3d9703c622b5c05ad /actionpack/test/template | |
parent | cf2d31ab0b07e1c5b124209c85993df303c961f1 (diff) | |
download | rails-bd89946dd3ededc5850f1b9754cb39cf0331637a.tar.gz rails-bd89946dd3ededc5850f1b9754cb39cf0331637a.tar.bz2 rails-bd89946dd3ededc5850f1b9754cb39cf0331637a.zip |
Ensure option for select helper responds to `#first` before comparison.
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/form_options_helper_test.rb | 18 |
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 469718e1bd..4a889beadd 100644 --- a/actionpack/test/template/form_options_helper_test.rb +++ b/actionpack/test/template/form_options_helper_test.rb @@ -596,6 +596,24 @@ class FormOptionsHelperTest < ActionView::TestCase ) end + def test_select_with_nil + @post = Post.new + @post.category = "othervalue" + assert_dom_equal( + "<select id=\"post_category\" name=\"post[category]\"><option value=\"\"></option>\n<option value=\"othervalue\" selected=\"selected\">othervalue</option></select>", + select("post", "category", [nil, "othervalue"]) + ) + end + + def test_select_with_fixnum + @post = Post.new + @post.category = "" + assert_dom_equal( + "<select id=\"post_category\" name=\"post[category]\"><option value=\"\">Please select</option>\n<option value=\"\"></option>\n<option value=\"1\">1</option></select>", + select("post", "category", [1], :prompt => true, :include_blank => true) + ) + end + def test_list_of_lists @post = Post.new @post.category = "" |