From 89ee5d63d039af6770014a3bfdc4a743be9a429c Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 5 Mar 2008 01:26:24 +0000 Subject: Tests for div_for and content_tag_for helpers. Closes #11223 [thechrisoshow] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8980 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 + .../lib/action_view/helpers/record_tag_helper.rb | 2 +- actionpack/test/template/record_tag_helper_test.rb | 59 ++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 actionpack/test/template/record_tag_helper_test.rb diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 58792d9088..3bf04b5eba 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Tests for div_for and content_tag_for helpers. Closes #11223 [thechrisoshow] + * Allow file uploads in Integration Tests. Closes #11091 [RubyRedRick] * Refactor partial rendering into a PartialTemplate class. [Pratik] diff --git a/actionpack/lib/action_view/helpers/record_tag_helper.rb b/actionpack/lib/action_view/helpers/record_tag_helper.rb index 7b82c38a0e..40b66be79f 100644 --- a/actionpack/lib/action_view/helpers/record_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/record_tag_helper.rb @@ -24,7 +24,7 @@ module ActionView # <%=h @person.last_name %> # <% end %> # - # would produce hthe following HTML (assuming @person is an instance of + # would produce the following HTML (assuming @person is an instance of # a Person object, with an id value of 123): # # .... diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb new file mode 100644 index 0000000000..bb5440be20 --- /dev/null +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -0,0 +1,59 @@ +require 'abstract_unit' + +class Post + def id + 45 + end + def body + "What a wonderful world!" + end +end + +class RecordTagHelperTest < Test::Unit::TestCase + include ActionView::Helpers::RecordTagHelper + include ActionView::Helpers::CaptureHelper + include ActionView::Helpers::RecordIdentificationHelper + include ActionView::Helpers::TagHelper + include ActionView::Helpers::TextHelper + include ActionView::Helpers::UrlHelper + + def setup + @post = Post.new + end + + def test_content_tag_for + _erbout = '' + expected = %(
  • ) + actual = content_tag_for(:li, @post, :class => 'bar') { } + assert_dom_equal expected, actual + end + + def test_content_tag_for_prefix + _erbout = '' + expected = %() + actual = content_tag_for(:ul, @post, :archived) { } + assert_dom_equal expected, actual + end + + def test_content_tag_for_with_extra_html_tags + _erbout = '' + expected = %() + actual = content_tag_for(:tr, @post, {:class => "bar", :style => "background-color: #f0f0f0"}) { } + assert_dom_equal expected, actual + end + + def test_block_works_with_content_tag_for + _erbout = '' + expected = %(#{@post.body}) + actual = content_tag_for(:tr, @post) { _erbout.concat @post.body } + assert_dom_equal expected, actual + end + + def test_div_for + _erbout = '' + expected = %(
    #{@post.body}
    ) + actual = div_for(@post, :class => "bar") { _erbout.concat @post.body } + assert_dom_equal expected, actual + end + +end -- cgit v1.2.3