diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-09-05 06:10:12 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-09-05 10:11:43 -0300 |
commit | c255e0eed5849ed7866d3c5999a4e04a0e625b9c (patch) | |
tree | 04b62427864147473bdfbbea15be9c7fceb4043a /actionpack/test/template | |
parent | e221108c141fa564b7da6378478b762b356e0084 (diff) | |
download | rails-c255e0eed5849ed7866d3c5999a4e04a0e625b9c.tar.gz rails-c255e0eed5849ed7866d3c5999a4e04a0e625b9c.tar.bz2 rails-c255e0eed5849ed7866d3c5999a4e04a0e625b9c.zip |
Merge pull request #2799 from tomstuart/3-1-stable
Never return stored content from content_for when a block is given
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/capture_helper_test.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/actionpack/test/template/capture_helper_test.rb b/actionpack/test/template/capture_helper_test.rb index a9157e711c..13e2d5b595 100644 --- a/actionpack/test/template/capture_helper_test.rb +++ b/actionpack/test/template/capture_helper_test.rb @@ -46,6 +46,42 @@ class CaptureHelperTest < ActionView::TestCase assert_equal "bar", content_for(:bar) end + def test_content_for_with_multiple_calls + assert ! content_for?(:title) + content_for :title, 'foo' + content_for :title, 'bar' + assert_equal 'foobar', content_for(:title) + end + + def test_content_for_with_block + assert ! content_for?(:title) + content_for :title do + output_buffer << 'foo' + output_buffer << 'bar' + nil + end + assert_equal 'foobar', content_for(:title) + end + + def test_content_for_with_whitespace_block + assert ! content_for?(:title) + content_for :title, 'foo' + content_for :title do + output_buffer << " \n " + nil + end + content_for :title, 'bar' + assert_equal 'foobar', content_for(:title) + end + + def test_content_for_returns_nil_when_writing + assert ! content_for?(:title) + assert_equal nil, content_for(:title, 'foo') + assert_equal nil, content_for(:title) { output_buffer << 'bar'; nil } + assert_equal nil, content_for(:title) { output_buffer << " \n "; nil } + assert_equal 'foobar', content_for(:title) + end + def test_content_for_question_mark assert ! content_for?(:title) content_for :title, 'title' |