diff options
author | Jon Crawford <mail@joncrawford.com> | 2009-01-29 17:59:44 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-01-29 18:00:18 +0000 |
commit | 8761663a68bd7ddd918f78fb3def4697784024f2 (patch) | |
tree | f09b465c194d3848fe353551bc11a7269487857e /actionpack/test/template | |
parent | 306cc2b920203cfa51cee82d2fc452484efc72f8 (diff) | |
download | rails-8761663a68bd7ddd918f78fb3def4697784024f2.tar.gz rails-8761663a68bd7ddd918f78fb3def4697784024f2.tar.bz2 rails-8761663a68bd7ddd918f78fb3def4697784024f2.zip |
Added grouped_options_for_select helper method for wrapping option tags in optgroups. [#977 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/form_options_helper_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb index 78548864ff..86b321e6e5 100644 --- a/actionpack/test/template/form_options_helper_test.rb +++ b/actionpack/test/template/form_options_helper_test.rb @@ -143,6 +143,32 @@ uses_mocha "FormOptionsHelperTest" do ) end + def test_grouped_options_for_select_with_array + assert_dom_equal( + "<optgroup label=\"North America\"><option value=\"US\">United States</option>\n<option value=\"Canada\">Canada</option></optgroup><optgroup label=\"Europe\"><option value=\"GB\">Great Britain</option>\n<option value=\"Germany\">Germany</option></optgroup>", + grouped_options_for_select([ + ["North America", + [['United States','US'],"Canada"]], + ["Europe", + [["Great Britain","GB"], "Germany"]] + ]) + ) + end + + def test_grouped_options_for_select_with_selected_and_prompt + assert_dom_equal( + "<option value=\"\">Choose a product...</option><optgroup label=\"Hats\"><option value=\"Baseball Cap\">Baseball Cap</option>\n<option selected=\"selected\" value=\"Cowboy Hat\">Cowboy Hat</option></optgroup>", + grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]], "Cowboy Hat", "Choose a product...") + ) + end + + def test_optgroups_with_with_options_with_hash + assert_dom_equal( + "<optgroup label=\"Europe\"><option value=\"Denmark\">Denmark</option>\n<option value=\"Germany\">Germany</option></optgroup><optgroup label=\"North America\"><option value=\"United States\">United States</option>\n<option value=\"Canada\">Canada</option></optgroup>", + grouped_options_for_select({'North America' => ['United States','Canada'], 'Europe' => ['Denmark','Germany']}) + ) + end + def test_time_zone_options_no_parms opts = time_zone_options_for_select assert_dom_equal "<option value=\"A\">A</option>\n" + |