2009-03-13 06:23:13 -04:00
|
|
|
require 'abstract_unit'
|
|
|
|
|
|
|
|
class OutputBufferTest < ActionController::TestCase
|
|
|
|
class TestController < ActionController::Base
|
|
|
|
def index
|
|
|
|
render :text => 'foo'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tests TestController
|
|
|
|
|
|
|
|
def test_flush_output_buffer
|
|
|
|
# Start with the default body parts
|
|
|
|
get :index
|
|
|
|
assert_equal ['foo'], @response.body_parts
|
2009-04-29 00:29:29 -04:00
|
|
|
assert_nil @controller.template.output_buffer
|
2009-03-13 06:23:13 -04:00
|
|
|
|
|
|
|
# Nil output buffer is skipped
|
2009-04-29 00:29:29 -04:00
|
|
|
@controller.template.flush_output_buffer
|
|
|
|
assert_nil @controller.template.output_buffer
|
2009-03-13 06:23:13 -04:00
|
|
|
assert_equal ['foo'], @response.body_parts
|
|
|
|
|
|
|
|
# Empty output buffer is skipped
|
2009-04-29 00:29:29 -04:00
|
|
|
@controller.template.output_buffer = ''
|
|
|
|
@controller.template.flush_output_buffer
|
|
|
|
assert_equal '', @controller.template.output_buffer
|
2009-03-13 06:23:13 -04:00
|
|
|
assert_equal ['foo'], @response.body_parts
|
|
|
|
|
|
|
|
# Flushing appends the output buffer to the body parts
|
2009-04-29 00:29:29 -04:00
|
|
|
@controller.template.output_buffer = 'bar'
|
|
|
|
@controller.template.flush_output_buffer
|
|
|
|
assert_equal '', @controller.template.output_buffer
|
2009-03-13 06:23:13 -04:00
|
|
|
assert_equal ['foo', 'bar'], @response.body_parts
|
|
|
|
end
|
|
|
|
end
|