From 39d461703361834c2e51dd9179afce0f8a0a83ff Mon Sep 17 00:00:00 2001 From: kennyj Date: Fri, 10 Feb 2012 20:55:10 +0900 Subject: Fix some warnings on 3-2-stable --- actionpack/test/template/record_tag_helper_test.rb | 41 ++++++++++++---------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb index ec777d15c4..80d6f130ed 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -1,15 +1,15 @@ require 'abstract_unit' require 'controller/fake_models' -class Post +class RecordTagPost extend ActiveModel::Naming include ActiveModel::Conversion - attr_writer :id, :body + attr_writer :id, :body, :persisted def initialize @id = nil @body = nil - super + @persisted = false end def id @@ -17,8 +17,11 @@ class Post end def body - super || @body || "What a wonderful world!" + @body || "What a wonderful world!" end + + def persisted?; @persisted end + end class RecordTagHelperTest < ActionView::TestCase @@ -28,30 +31,30 @@ class RecordTagHelperTest < ActionView::TestCase def setup super - @post = Post.new + @post = RecordTagPost.new @post.persisted = true end def test_content_tag_for - expected = %(
  • ) + expected = %(
  • ) actual = content_tag_for(:li, @post, :class => 'bar') { } assert_dom_equal expected, actual end def test_content_tag_for_prefix - expected = %() + expected = %() actual = content_tag_for(:ul, @post, :archived) { } assert_dom_equal expected, actual end def test_content_tag_for_with_extra_html_tags - expected = %() + expected = %() actual = content_tag_for(:tr, @post, {:class => "bar", :style => "background-color: #f0f0f0"}) { } assert_dom_equal expected, actual end def test_block_not_in_erb_multiple_calls - expected = %(
    #{@post.body}
    ) + expected = %(
    #{@post.body}
    ) actual = div_for(@post, :class => "bar") { @post.body } assert_dom_equal expected, actual actual = div_for(@post, :class => "bar") { @post.body } @@ -59,29 +62,29 @@ class RecordTagHelperTest < ActionView::TestCase end def test_block_works_with_content_tag_for_in_erb - expected = %(#{@post.body}) + expected = %(#{@post.body}) actual = render_erb("<%= content_tag_for(:tr, @post) do %><%= @post.body %><% end %>") assert_dom_equal expected, actual end def test_div_for_in_erb - expected = %(
    #{@post.body}
    ) + expected = %(
    #{@post.body}
    ) actual = render_erb("<%= div_for(@post, :class => 'bar') do %><%= @post.body %><% end %>") 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 = %(
  • Hello!
  • \n
  • World!
  • ) + post_1 = RecordTagPost.new.tap { |post| post.id = 101; post.body = "Hello!"; post.persisted = true } + post_2 = RecordTagPost.new.tap { |post| post.id = 102; post.body = "World!"; post.persisted = true } + expected = %(
  • Hello!
  • \n
  • World!
  • ) actual = content_tag_for(:li, [post_1, post_2]) { |post| concat 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 } - expected = %(
    Hello!
    \n
    World!
    ) + post_1 = RecordTagPost.new.tap { |post| post.id = 101; post.body = "Hello!"; post.persisted = true } + post_2 = RecordTagPost.new.tap { |post| post.id = 102; post.body = "World!"; post.persisted = true } + expected = %(
    Hello!
    \n
    World!
    ) actual = div_for([post_1, post_2]) { |post| concat post.body } assert_dom_equal expected, actual end @@ -92,8 +95,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 = RecordTagPost.new.tap { |post| post.id = 101; post.body = "Hello!"; post.persisted = true } + post_2 = RecordTagPost.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 -- cgit v1.2.3