From 0195d6138b7e441283cbbded31ff4e94bcf61901 Mon Sep 17 00:00:00 2001 From: Sergey Kojin Date: Tue, 27 Nov 2012 20:00:31 +0400 Subject: [PATCH] No sort Hash options in #grouped_options_for_select --- actionpack/CHANGELOG.md | 2 ++ .../lib/action_view/helpers/form_options_helper.rb | 10 ++++------ actionpack/test/template/form_options_helper_test.rb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index a8ac9081ec..1e47c7d66a 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -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* diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index 46ebe60ec2..9310a90f0f 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -482,15 +482,15 @@ def option_groups_from_collection_for_select(collection, group_method, group_lab # grouped_options_for_select(grouped_options) # # Possible output: + # + # + # + # # # # # # - # - # - # - # # # 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 diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb index 54ab8b4d3a..c5efed3195 100644 --- a/actionpack/test/template/form_options_helper_test.rb +++ b/actionpack/test/template/form_options_helper_test.rb @@ -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( - "\n\n", + "\n\n", grouped_options_for_select({'North America' => ['United States','Canada'], 'Europe' => ['Denmark','Germany']}) ) end -- GitLab