diff options
Diffstat (limited to 'actionpack/test/template/record_tag_helper_test.rb')
-rw-r--r-- | actionpack/test/template/record_tag_helper_test.rb | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb index edc2689896..7f23629e05 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -5,9 +5,17 @@ class Post extend ActiveModel::Naming include ActiveModel::Conversion attr_writer :id, :body + + def initialize + @id = nil + @body = nil + super + end + def id @id || 45 end + def body super || @body || "What a wonderful world!" end @@ -68,9 +76,6 @@ class RecordTagHelperTest < ActionView::TestCase assert_dom_equal expected, actual end - def test_content_tag_for_collection_is_html_safe - end - def test_div_for_collection 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 } @@ -78,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 |