Skip to content

Commit

Permalink
Remove passing the prompt to grouped_options_for_select as an argumen…
Browse files Browse the repository at this point in the history
…t, because it was deprecated.
  • Loading branch information
kennyj committed Jun 27, 2013
1 parent 4f1a7dc commit 94c72c4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 26 deletions.
5 changes: 5 additions & 0 deletions actionview/CHANGELOG.md
@@ -1,3 +1,8 @@
* Remove passing the prompt to `grouped_options_for_select` as an argument, because
it was deprecated.

*kennyj*

* Always escape the result of `link_to_unless` method. * Always escape the result of `link_to_unless` method.


Before: Before:
Expand Down
11 changes: 2 additions & 9 deletions actionview/lib/action_view/helpers/form_options_helper.rb
Expand Up @@ -510,15 +510,8 @@ def option_groups_from_collection_for_select(collection, group_method, group_lab
# <b>Note:</b> Only the <tt><optgroup></tt> and <tt><option></tt> tags are returned, so you still have to # <b>Note:</b> Only the <tt><optgroup></tt> and <tt><option></tt> tags are returned, so you still have to
# wrap the output in an appropriate <tt><select></tt> tag. # wrap the output in an appropriate <tt><select></tt> tag.
def grouped_options_for_select(grouped_options, selected_key = nil, options = {}) def grouped_options_for_select(grouped_options, selected_key = nil, options = {})
if options.is_a?(Hash) prompt = options[:prompt]
prompt = options[:prompt] divider = options[:divider]
divider = options[:divider]
else
prompt = options
message = "Passing the prompt to grouped_options_for_select as an argument is deprecated. " \
"Please use an options hash like `{ prompt: #{prompt.inspect} }`."
ActiveSupport::Deprecation.warn message
end


body = "".html_safe body = "".html_safe


Expand Down
17 changes: 0 additions & 17 deletions actionview/test/template/form_options_helper_test.rb
Expand Up @@ -310,15 +310,6 @@ def test_grouped_options_for_select_with_optional_divider
) )
end end


def test_grouped_options_for_select_with_selected_and_prompt_deprecated
assert_deprecated 'Passing the prompt to grouped_options_for_select as an argument is deprecated. Please use an options hash like `{ prompt: "Choose a product..." }`.' 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 def test_grouped_options_for_select_with_selected_and_prompt
assert_dom_equal( 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>", "<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>",
Expand All @@ -337,14 +328,6 @@ def test_grouped_options_for_select_returns_html_safe_string
assert grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]]).html_safe? assert grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]]).html_safe?
end end


def test_grouped_options_for_select_with_prompt_returns_html_escaped_string_deprecated
ActiveSupport::Deprecation.silence do
assert_dom_equal(
"<option value=\"\">&lt;Choose One&gt;</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 def test_grouped_options_for_select_with_prompt_returns_html_escaped_string
assert_dom_equal( assert_dom_equal(
"<option value=\"\">&lt;Choose One&gt;</option><optgroup label=\"Hats\"><option value=\"Baseball Cap\">Baseball Cap</option>\n<option value=\"Cowboy Hat\">Cowboy Hat</option></optgroup>", "<option value=\"\">&lt;Choose One&gt;</option><optgroup label=\"Hats\"><option value=\"Baseball Cap\">Baseball Cap</option>\n<option value=\"Cowboy Hat\">Cowboy Hat</option></optgroup>",
Expand Down

0 comments on commit 94c72c4

Please sign in to comment.