aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-01-17 22:51:27 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-01-18 00:44:25 -0200
commit53381be007785369f5f3c41a19693a2ec0d43e31 (patch)
treeee3db7859637af897016d6916d2520b371acd57f
parent5c997ccadd0014577c4b67d92fdeeb53bdad9637 (diff)
downloadrails-53381be007785369f5f3c41a19693a2ec0d43e31.tar.gz
rails-53381be007785369f5f3c41a19693a2ec0d43e31.tar.bz2
rails-53381be007785369f5f3c41a19693a2ec0d43e31.zip
Mimic AR models yielding when building new records, avoid using tap
-rw-r--r--actionpack/test/template/record_tag_helper_test.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb
index a349f803de..97dfb473d2 100644
--- a/actionpack/test/template/record_tag_helper_test.rb
+++ b/actionpack/test/template/record_tag_helper_test.rb
@@ -10,6 +10,8 @@ class Post
@id = nil
@body = nil
super
+
+ yield self if block_given?
end
def id
@@ -77,16 +79,16 @@ class RecordTagHelperTest < ActionView::TestCase
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 }
+ post_1 = Post.new { |post| post.id = 101; post.body = "Hello!"; post.persisted = true }
+ post_2 = Post.new { |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| post.body }
assert_dom_equal expected, actual
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 }
+ post_1 = Post.new { |post| post.id = 101; post.body = "Hello!"; post.persisted = true }
+ post_2 = Post.new { |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| post.body }
assert_dom_equal expected, actual
@@ -98,8 +100,8 @@ class RecordTagHelperTest < ActionView::TestCase
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 }
+ post_1 = Post.new { |post| post.id = 101; post.body = "Hello!"; post.persisted = true }
+ post_2 = Post.new { |post| post.id = 102; post.body = "World!"; post.persisted = true }
result = content_tag_for(:li, [post_1, post_2]) { |post| post.body }
assert result.html_safe?
end