diff options
Diffstat (limited to 'actionpack/test/template/record_tag_helper_test.rb')
-rw-r--r-- | actionpack/test/template/record_tag_helper_test.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb index 1ba14e8bc9..edc2689896 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -4,11 +4,12 @@ require 'controller/fake_models' class Post extend ActiveModel::Naming include ActiveModel::Conversion + attr_writer :id, :body def id - 45 + @id || 45 end def body - super || "What a wonderful world!" + super || @body || "What a wonderful world!" end end @@ -58,4 +59,23 @@ class RecordTagHelperTest < ActionView::TestCase actual = div_for(@post, :class => "bar") { concat @post.body } assert_dom_equal expected, actual end + + def test_content_tag_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 } + expected = %(<li class="post" id="post_101">Hello!</li>\n<li class="post" id="post_102">World!</li>) + actual = content_tag_for(:li, [post_1, post_2]) { |post| concat post.body } + 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 } + expected = %(<div class="post" id="post_101">Hello!</div>\n<div class="post" id="post_102">World!</div>) + actual = div_for([post_1, post_2]) { |post| concat post.body } + assert_dom_equal expected, actual + end end |