| | 1 | require 'abstract_unit' |
|---|
| | 2 | |
|---|
| | 3 | class Post |
|---|
| | 4 | def id |
|---|
| | 5 | 45 |
|---|
| | 6 | end |
|---|
| | 7 | def body |
|---|
| | 8 | "What a wonderful world!" |
|---|
| | 9 | end |
|---|
| | 10 | end |
|---|
| | 11 | |
|---|
| | 12 | class RecordTagHelperTest < Test::Unit::TestCase |
|---|
| | 13 | include ActionView::Helpers::RecordTagHelper |
|---|
| | 14 | include ActionView::Helpers::CaptureHelper |
|---|
| | 15 | include ActionView::Helpers::RecordIdentificationHelper |
|---|
| | 16 | include ActionView::Helpers::TagHelper |
|---|
| | 17 | include ActionView::Helpers::TextHelper |
|---|
| | 18 | include ActionView::Helpers::UrlHelper |
|---|
| | 19 | |
|---|
| | 20 | def setup |
|---|
| | 21 | @post = Post.new |
|---|
| | 22 | end |
|---|
| | 23 | |
|---|
| | 24 | def test_content_tag_for |
|---|
| | 25 | _erbout = '' |
|---|
| | 26 | expected = %(<li class="post bar" id="post_45"></li>) |
|---|
| | 27 | actual = content_tag_for(:li, @post, :class => 'bar') { } |
|---|
| | 28 | assert_dom_equal expected, actual |
|---|
| | 29 | end |
|---|
| | 30 | |
|---|
| | 31 | def test_content_tag_for_prefix |
|---|
| | 32 | _erbout = '' |
|---|
| | 33 | expected = %(<ul class="post" id="archived_post_45"></ul>) |
|---|
| | 34 | actual = content_tag_for(:ul, @post, :archived) { } |
|---|
| | 35 | assert_dom_equal expected, actual |
|---|
| | 36 | end |
|---|
| | 37 | |
|---|
| | 38 | def test_content_tag_for_with_extra_html_tags |
|---|
| | 39 | _erbout = '' |
|---|
| | 40 | expected = %(<tr class="post bar" id="post_45" style='background-color: #f0f0f0'></tr>) |
|---|
| | 41 | actual = content_tag_for(:tr, @post, {:class => "bar", :style => "background-color: #f0f0f0"}) { } |
|---|
| | 42 | assert_dom_equal expected, actual |
|---|
| | 43 | end |
|---|
| | 44 | |
|---|
| | 45 | def test_block_works_with_content_tag_for |
|---|
| | 46 | _erbout = '' |
|---|
| | 47 | expected = %(<tr class="post" id="post_45">#{@post.body}</tr>) |
|---|
| | 48 | actual = content_tag_for(:tr, @post) { _erbout.concat @post.body } |
|---|
| | 49 | assert_dom_equal expected, actual |
|---|
| | 50 | end |
|---|
| | 51 | |
|---|
| | 52 | def test_div_for |
|---|
| | 53 | _erbout = '' |
|---|
| | 54 | expected = %(<div class="post bar" id="post_45">#{@post.body}</div>) |
|---|
| | 55 | actual = div_for(@post, :class => "bar") { _erbout.concat @post.body } |
|---|
| | 56 | assert_dom_equal expected, actual |
|---|
| | 57 | end |
|---|
| | 58 | |
|---|
| | 59 | end |