made sure that the possible new output_buffer created by CacheHelper is of the same type as the original

This commit is contained in:
Lauri Hahne
2011-07-17 18:55:39 +03:00
parent bc5ccd0179
commit 39a4f67b5d
2 changed files with 5 additions and 5 deletions

View File

@@ -56,7 +56,7 @@ module ActionView
if output_buffer.html_safe?
safe_output_buffer = output_buffer.to_str
fragment = safe_output_buffer.slice!(pos..-1)
self.output_buffer = ActionView::OutputBuffer.new(safe_output_buffer)
self.output_buffer = output_buffer.class.new(safe_output_buffer)
else
fragment = output_buffer.slice!(pos..-1)
end

View File

@@ -809,8 +809,8 @@ class CacheHelperOutputBufferTest < ActionController::TestCase
cache_helper.extend(ActionView::Helpers::CacheHelper)
cache_helper.expects(:controller).returns(controller).at_least(0)
cache_helper.expects(:output_buffer).returns(output_buffer).at_least(0)
# if the output_buffer is changed, the new one should be html_safe
cache_helper.expects(:output_buffer=).with(responds_with(:html_safe?, true)).returns(true).at_least(0)
# if the output_buffer is changed, the new one should be html_safe and of the same type
cache_helper.expects(:output_buffer=).with(responds_with(:html_safe?, true)).with(instance_of(output_buffer.class)).at_least(0)
assert_nothing_raised do
cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }
@@ -825,8 +825,8 @@ class CacheHelperOutputBufferTest < ActionController::TestCase
cache_helper.extend(ActionView::Helpers::CacheHelper)
cache_helper.expects(:controller).returns(controller).at_least(0)
cache_helper.expects(:output_buffer).returns(output_buffer).at_least(0)
# if the output_buffer is changed, the new one should be html_safe
cache_helper.expects(:output_buffer=).with(responds_with(:html_safe?, true)).returns(true).at_least(0)
# if the output_buffer is changed, the new one should be html_safe and of the same type
cache_helper.expects(:output_buffer=).with(responds_with(:html_safe?, true)).with(instance_of(output_buffer.class)).at_least(0)
assert_nothing_raised do
cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }