Permalink
Browse files

Merge pull request #5234 from benpickles/allow-empty-fieldsets

Allow empty fieldsets  to be created without a block.
  • Loading branch information...
2 parents fcef728 + 81d3493 commit 9078dba7de7e703f1558b03502791b16225d18eb @drogus drogus committed Mar 2, 2012
@@ -525,10 +525,9 @@ def image_submit_tag(source, options = {})
# <% end %>
# # => <fieldset class="format"><p><input id="name" name="name" type="text" /></p></fieldset>
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("</fieldset>")
end
@@ -513,6 +513,16 @@ def test_field_set_tag_in_erb
expected = %(<fieldset class="format">Hello world!</fieldset>)
assert_dom_equal expected, output_buffer
+
+ output_buffer = render_erb("<%= field_set_tag %>")
+
+ expected = %(<fieldset></fieldset>)
+ assert_dom_equal expected, output_buffer
+
+ output_buffer = render_erb("<%= field_set_tag('You legend!') %>")
+
+ expected = %(<fieldset><legend>You legend!</legend></fieldset>)
+ assert_dom_equal expected, output_buffer
end
def test_text_area_tag_options_symbolize_keys_side_effects

0 comments on commit 9078dba

Please sign in to comment.