1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #2872 from sikachu/content_tag_html_safe

Make sure that result from content_tag_for with collection is html_safe
This commit is contained in:
Santiago Pastorino 2011-09-05 07:08:39 -07:00
commit a23e3855c5
2 changed files with 13 additions and 1 deletions

View file

@ -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

View file

@ -83,4 +83,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