From 1e1f5ae1d98f9a8e9aec40271c49f9ec21440376 Mon Sep 17 00:00:00 2001 From: Kieran Pilkington Date: Sun, 4 Apr 2010 16:31:52 +1200 Subject: [PATCH] Mark the result of grouped_options_for_select as HTML safe --- .../lib/action_view/helpers/form_options_helper.rb | 2 +- .../test/template/form_options_helper_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index 11c6351..04a199d 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -446,7 +446,7 @@ module ActionView body << content_tag(:optgroup, options_for_select(group[1], selected_key), :label => group[0]) end - body + body.html_safe end # Returns a string of option tags for pretty much any time zone in the diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb index 5799e3d..98503c3 100644 --- a/actionpack/test/template/form_options_helper_test.rb +++ b/actionpack/test/template/form_options_helper_test.rb @@ -207,6 +207,10 @@ class FormOptionsHelperTest < ActionView::TestCase ) end + def test_grouped_options_for_select_returns_html_safe_string + assert grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]]).html_safe? + end + def test_optgroups_with_with_options_with_hash assert_dom_equal( "\n\n", -- 1.6.6