mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Make sure that result from content_tag_for with collection is html_safe
Thank you @spastorino for catching the empty test in b84cee0, as I totally forgot that I still have to make it html_safe.
This commit is contained in:
@@ -84,7 +84,7 @@ module ActionView
|
||||
if single_or_multiple_records.respond_to?(:to_ary)
|
||||
single_or_multiple_records.to_ary.map do |single_record|
|
||||
capture { content_tag_for_single_record(tag_name, single_record, prefix, options, &block) }
|
||||
end.join("\n")
|
||||
end.join("\n").html_safe
|
||||
else
|
||||
content_tag_for_single_record(tag_name, single_or_multiple_records, prefix, options, &block)
|
||||
end
|
||||
|
||||
@@ -80,4 +80,16 @@ class RecordTagHelperTest < ActionView::TestCase
|
||||
actual = div_for([post_1, post_2]) { |post| concat post.body }
|
||||
assert_dom_equal expected, actual
|
||||
end
|
||||
|
||||
def test_content_tag_for_single_record_is_html_safe
|
||||
result = div_for(@post, :class => "bar") { concat @post.body }
|
||||
assert result.html_safe?
|
||||
end
|
||||
|
||||
def test_content_tag_for_collection_is_html_safe
|
||||
post_1 = Post.new.tap { |post| post.id = 101; post.body = "Hello!"; post.persisted = true }
|
||||
post_2 = Post.new.tap { |post| post.id = 102; post.body = "World!"; post.persisted = true }
|
||||
result = content_tag_for(:li, [post_1, post_2]) { |post| concat post.body }
|
||||
assert result.html_safe?
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user