diff options
-rw-r--r-- | actionpack/test/template/output_buffer_test.rb | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/actionpack/test/template/output_buffer_test.rb b/actionpack/test/template/output_buffer_test.rb index 171cfb63e1..f1df1c7a60 100644 --- a/actionpack/test/template/output_buffer_test.rb +++ b/actionpack/test/template/output_buffer_test.rb @@ -9,33 +9,41 @@ class OutputBufferTest < ActionController::TestCase tests TestController - def test_flush_output_buffer - pending - # TODO: This tests needs to be rewritten due - # The @response is not the same response object assigned - # to the @controller.template - - # Start with the default body parts - # --- - # get :index - # assert_equal ['foo'], @response.body_parts - # assert_nil @controller.template.output_buffer - # - # # Nil output buffer is skipped - # @controller.template.flush_output_buffer - # assert_nil @controller.template.output_buffer - # assert_equal ['foo'], @response.body_parts - # - # # Empty output buffer is skipped - # @controller.template.output_buffer = '' - # @controller.template.flush_output_buffer - # assert_equal '', @controller.template.output_buffer - # assert_equal ['foo'], @response.body_parts - # - # # Flushing appends the output buffer to the body parts - # @controller.template.output_buffer = 'bar' - # @controller.template.flush_output_buffer - # assert_equal '', @controller.template.output_buffer - # assert_equal ['foo', 'bar'], @response.body_parts + def setup + get :index + assert_equal ['foo'], body_parts end + + test 'output buffer is nil after rendering' do + assert_nil output_buffer + end + + test 'flushing ignores nil output buffer' do + @controller.template.flush_output_buffer + assert_nil output_buffer + assert_equal ['foo'], body_parts + end + + test 'flushing ignores empty output buffer' do + @controller.template.output_buffer = '' + @controller.template.flush_output_buffer + assert_equal '', output_buffer + assert_equal ['foo'], body_parts + end + + test 'flushing appends the output buffer to the body parts' do + @controller.template.output_buffer = 'bar' + @controller.template.flush_output_buffer + assert_equal '', output_buffer + assert_equal ['foo', 'bar'], body_parts + end + + protected + def output_buffer + @controller.template.output_buffer + end + + def body_parts + @controller.template.response.body_parts + end end |