Permalink
Browse files

No sort Hash options in #grouped_options_for_select

  • Loading branch information...
1 parent 0be0a97 commit 0195d6138b7e441283cbbded31ff4e94bcf61901 @skojin skojin committed Nov 27, 2012
View
@@ -1,5 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+* No sort Hash options in #grouped_options_for_select. *Sergey Kojin*
+
* Accept symbols as #send_data :disposition value *Elia Schito*
* Add i18n scope to distance_of_time_in_words. *Steve Klabnik*
@@ -482,15 +482,15 @@ def option_groups_from_collection_for_select(collection, group_method, group_lab
# grouped_options_for_select(grouped_options)
#
# Possible output:
+ # <optgroup label="North America">
+ # <option value="US">United States</option>
+ # <option value="Canada">Canada</option>
+ # </optgroup>
# <optgroup label="Europe">
# <option value="Denmark">Denmark</option>
# <option value="Germany">Germany</option>
# <option value="France">France</option>
# </optgroup>
- # <optgroup label="North America">
- # <option value="US">United States</option>
- # <option value="Canada">Canada</option>
- # </optgroup>
#
# Sample usage (divider):
# grouped_options = [
@@ -530,8 +530,6 @@ def grouped_options_for_select(grouped_options, selected_key = nil, options = {}
body.safe_concat content_tag(:option, prompt_text(prompt), :value => "")
end
- grouped_options = grouped_options.sort if grouped_options.is_a?(Hash)
-
grouped_options.each do |container|
if divider
label = divider
@@ -346,7 +346,7 @@ def test_grouped_options_for_select_with_prompt_returns_html_escaped_string
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>",
+ "<optgroup label=\"North America\"><option value=\"United States\">United States</option>\n<option value=\"Canada\">Canada</option></optgroup><optgroup label=\"Europe\"><option value=\"Denmark\">Denmark</option>\n<option value=\"Germany\">Germany</option></optgroup>",
grouped_options_for_select({'North America' => ['United States','Canada'], 'Europe' => ['Denmark','Germany']})
)
end

0 comments on commit 0195d61

Please sign in to comment.