1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #11147 from kennyj/remove_prompt_argument_was_deprecated

Remove passing the prompt to grouped_options_for_select as an argument, because it was deprecated.
This commit is contained in:
Carlos Antonio da Silva 2013-06-27 11:32:14 -07:00
commit 2f7253c6e9
3 changed files with 7 additions and 26 deletions

View file

@ -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.
Before:

View file

@ -510,15 +510,8 @@ module ActionView
# <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.
def grouped_options_for_select(grouped_options, selected_key = nil, options = {})
if options.is_a?(Hash)
prompt = options[:prompt]
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
prompt = options[:prompt]
divider = options[:divider]
body = "".html_safe

View file

@ -310,15 +310,6 @@ class FormOptionsHelperTest < ActionView::TestCase
)
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
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>",
@ -337,14 +328,6 @@ 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=\"\">&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
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>",