aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-05-24 14:35:17 +0930
committerGitHub <noreply@github.com>2017-05-24 14:35:17 +0930
commite5a9d289b16592f395fb528c9688604c02bd2e33 (patch)
treeca72172b569ef13c8b261ad4c224ed9c6803aab1 /actionview/test
parent3a4c488a9d1872dc456e93eb7b0d834e05d9ecff (diff)
parentefe62b71d52c40849ead8855fb4f42fae91d4c54 (diff)
downloadrails-e5a9d289b16592f395fb528c9688604c02bd2e33.tar.gz
rails-e5a9d289b16592f395fb528c9688604c02bd2e33.tar.bz2
rails-e5a9d289b16592f395fb528c9688604c02bd2e33.zip
Merge pull request #29119 from spohlenz/fix-select-with-enumerable
Fix select tag helper used with Enumerable choices
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/template/form_options_helper_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/actionview/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb
index 258dcdb806..3247f20ba7 100644
--- a/actionview/test/template/form_options_helper_test.rb
+++ b/actionview/test/template/form_options_helper_test.rb
@@ -6,6 +6,15 @@ class Map < Hash
end
end
+class CustomEnumerable
+ include Enumerable
+
+ def each
+ yield "one"
+ yield "two"
+ end
+end
+
class FormOptionsHelperTest < ActionView::TestCase
tests ActionView::Helpers::FormOptionsHelper
@@ -904,6 +913,14 @@ class FormOptionsHelperTest < ActionView::TestCase
)
end
+ def test_select_with_enumerable
+ @post = Post.new
+ assert_dom_equal(
+ "<select id=\"post_category\" name=\"post[category]\"><option value=\"one\">one</option>\n<option value=\"two\">two</option></select>",
+ select("post", "category", CustomEnumerable.new)
+ )
+ end
+
def test_collection_select
@post = Post.new
@post.author_name = "Babe"