diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-05-16 16:15:50 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-05-16 16:15:50 -0700 |
commit | 66cbde016c5c457f25c45a71ef8839608ef77299 (patch) | |
tree | cb813763bdf421914aa2c4e9e9330002680c001d /actionpack/test/template/form_options_helper_test.rb | |
parent | 8e5f07dabcb2d917105aa7ae678072ab44bd5ad4 (diff) | |
parent | a1ae17e32797c1e0607c08bbcce1f257eecedf7d (diff) | |
download | rails-66cbde016c5c457f25c45a71ef8839608ef77299.tar.gz rails-66cbde016c5c457f25c45a71ef8839608ef77299.tar.bz2 rails-66cbde016c5c457f25c45a71ef8839608ef77299.zip |
Merge pull request #5369 from Greenie0506/add_separator_to_grouped_options_for_select
Add separator option to grouped_options_for_select
Diffstat (limited to 'actionpack/test/template/form_options_helper_test.rb')
-rw-r--r-- | actionpack/test/template/form_options_helper_test.rb | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb index 2cff91adda..d6262a5ba1 100644 --- a/actionpack/test/template/form_options_helper_test.rb +++ b/actionpack/test/template/form_options_helper_test.rb @@ -296,10 +296,27 @@ class FormOptionsHelperTest < ActionView::TestCase ) end - def test_grouped_options_for_select_with_selected_and_prompt + def test_grouped_options_for_select_with_optional_divider assert_dom_equal( + "<optgroup label=\"----------\"><option value=\"US\">US</option>\n<option value=\"Canada\">Canada</option></optgroup><optgroup label=\"----------\"><option value=\"GB\">GB</option>\n<option value=\"Germany\">Germany</option></optgroup>", + + grouped_options_for_select([['US',"Canada"] , ["GB", "Germany"]], divider:"----------") + ) + end + + def test_grouped_options_for_select_with_selected_and_prompt_deprecated + ActiveSupport::Deprecation.silence do + 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 + 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", prompt: "Choose a product...") ) end @@ -307,10 +324,18 @@ class FormOptionsHelperTest < ActionView::TestCase assert grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]]).html_safe? end + def test_grouped_options_for_select_with_prompt_returns_html_escaped_string_deprecated + ActiveSupport::Deprecation.silence do + assert_dom_equal( + "<option value=\"\"><Choose One></option><optgroup label=\"Hats\"><option value=\"Baseball Cap\">Baseball Cap</option>\n<option value=\"Cowboy Hat\">Cowboy Hat</option></optgroup>", + grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]], nil, '<Choose One>')) + end + end + def test_grouped_options_for_select_with_prompt_returns_html_escaped_string assert_dom_equal( "<option value=\"\"><Choose One></option><optgroup label=\"Hats\"><option value=\"Baseball Cap\">Baseball Cap</option>\n<option value=\"Cowboy Hat\">Cowboy Hat</option></optgroup>", - grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]], nil, '<Choose One>')) + grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]], nil, prompt: '<Choose One>')) end def test_optgroups_with_with_options_with_hash |