From 587dd7d56c1451c1d597535ede27c2163be72e0b Mon Sep 17 00:00:00 2001 From: Andrew Radev Date: Tue, 14 Jun 2011 22:45:22 +0300 Subject: Grouped select helper FormBuilder#select now works with a nested data structure. --- .../test/template/form_options_helper_test.rb | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb index a4599a3f00..6aea991f7c 100644 --- a/actionpack/test/template/form_options_helper_test.rb +++ b/actionpack/test/template/form_options_helper_test.rb @@ -385,6 +385,42 @@ class FormOptionsHelperTest < ActionView::TestCase ) end + def test_select_with_grouped_collection_as_nested_array + @post = Post.new + + countries_by_continent = [ + ["", [["", ""], ["Somalia", "so"]]], + ["Europe", [["Denmark", "dk"], ["Ireland", "ie"]]], + ] + + assert_dom_equal( + [ + %Q{}, + ].join("\n"), + select("post", "origin", countries_by_continent) + ) + end + + def test_select_with_grouped_collection_as_hash + @post = Post.new + + countries_by_continent = { + "" => [["", ""], ["Somalia", "so"]], + "Europe" => [["Denmark", "dk"], ["Ireland", "ie"]], + } + + assert_dom_equal( + [ + %Q{}, + ].join("\n"), + select("post", "origin", countries_by_continent) + ) + end + def test_select_with_boolean_method @post = Post.new @post.allow_comments = false -- cgit v1.2.3