Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #14835 from zzak/test_form_helper_label_with_block…

…_and_html

Add test for using ActionView::Helpers::FormHelper.label with block and html
  • Loading branch information...
commit 673cacef0d06c600527b0f0763a255ce184ba549 2 parents 6e6c76d + 1161d10
@rafaelfranca rafaelfranca authored
View
1  actionview/lib/action_view/helpers/form_helper.rb
@@ -746,6 +746,7 @@ def fields_for(record_name, record_object = nil, options = {}, &block)
# label(:post, :terms) do
# 'Accept <a href="/terms">Terms</a>.'.html_safe
# end
+ # # => <label for="post_terms">Accept <a href="/terms">Terms</a>.</label>
def label(object_name, method, content_or_options = nil, options = nil, &block)
Tags::Label.new(object_name, method, self, content_or_options, options).render(&block)
end
View
7 actionview/test/template/form_helper_test.rb
@@ -265,6 +265,13 @@ def test_label_with_block
)
end
+ def test_label_with_block_and_html
+ assert_dom_equal(
+ '<label for="post_terms">Accept <a href="/terms">Terms</a>.</label>',
+ label(:post, :terms) { 'Accept <a href="/terms">Terms</a>.'.html_safe }
+ )
+ end
+
def test_label_with_block_and_options
assert_dom_equal(
'<label for="my_for">The title, please:</label>',
Please sign in to comment.
Something went wrong with that request. Please try again.