Test deprecation and fix the documentation of grouped_options_for_select

This commit is contained in:
Rafael Mendonça França 2012-05-16 20:51:33 -03:00
parent 7aa96a130b
commit 6f04975272
2 changed files with 6 additions and 3 deletions

@ -460,8 +460,11 @@ def option_groups_from_collection_for_select(collection, group_method, group_lab
# * +selected_key+ - A value equal to the +value+ attribute for one of the <tt><option></tt> tags,
# which will have the +selected+ attribute set. Note: It is possible for this value to match multiple options
# as you might have the same option in multiple groups. Each will then get <tt>selected="selected"</tt>.
# * +prompt+ - set to true or a prompt string. When the select element doesn't have a value yet, this
#
# Options:
# * <tt>:prompt</tt> - set to true or a prompt string. When the select element doesn't have a value yet, this
# prepends an option with a generic prompt - "Please select" - or the given prompt string.
# * <tt>:delimiter</tt> - the delimiter for the options groups.
#
# Sample usage (Array):
# grouped_options = [

@ -305,7 +305,7 @@ def test_grouped_options_for_select_with_optional_divider
end
def test_grouped_options_for_select_with_selected_and_prompt_deprecated
ActiveSupport::Deprecation.silence do
assert_deprecated 'Passing the prompt to grouped_options_for_select as an argument is deprecated. Please pass it in an options hash.' 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...")