From 81d3493c172dc717a86e81a855f4983a3774b846 Mon Sep 17 00:00:00 2001 From: Ben Pickles Date: Thu, 1 Mar 2012 19:07:28 +0000 Subject: [PATCH] Allow fieldsets to be created without a block. --- actionpack/lib/action_view/helpers/form_tag_helper.rb | 3 +-- actionpack/test/template/form_tag_helper_test.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 2cf1c9055c..9fad30a48f 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -525,10 +525,9 @@ def image_submit_tag(source, options = {}) # <% end %> # # =>

def field_set_tag(legend = nil, options = nil, &block) - content = capture(&block) output = tag(:fieldset, options, true) output.safe_concat(content_tag(:legend, legend)) unless legend.blank? - output.concat(content) + output.concat(capture(&block)) if block_given? output.safe_concat("") end diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 6ef4cf4dd2..590a1967c5 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -513,6 +513,16 @@ def test_field_set_tag_in_erb expected = %(
Hello world!
) assert_dom_equal expected, output_buffer + + output_buffer = render_erb("<%= field_set_tag %>") + + expected = %(
) + assert_dom_equal expected, output_buffer + + output_buffer = render_erb("<%= field_set_tag('You legend!') %>") + + expected = %(
You legend!
) + assert_dom_equal expected, output_buffer end def test_text_area_tag_options_symbolize_keys_side_effects