Skip to content
This repository
Browse code

made sure that the possible new output_buffer created by CacheHelper …

…is of the same type as the original
  • Loading branch information...
commit 39a4f67b5d773078ae741803f78fe75f22563fb1 1 parent bc5ccd0
Lauri Hahne authored July 17, 2011
2  actionpack/lib/action_view/helpers/cache_helper.rb
@@ -56,7 +56,7 @@ def fragment_for(name = {}, options = nil, &block) #:nodoc:
56 56
           if output_buffer.html_safe?
57 57
             safe_output_buffer = output_buffer.to_str
58 58
             fragment = safe_output_buffer.slice!(pos..-1)
59  
-            self.output_buffer = ActionView::OutputBuffer.new(safe_output_buffer)
  59
+            self.output_buffer = output_buffer.class.new(safe_output_buffer)
60 60
           else
61 61
             fragment = output_buffer.slice!(pos..-1)
62 62
           end
8  actionpack/test/controller/caching_test.rb
@@ -809,8 +809,8 @@ def test_output_buffer
809 809
     cache_helper.extend(ActionView::Helpers::CacheHelper)
810 810
     cache_helper.expects(:controller).returns(controller).at_least(0)
811 811
     cache_helper.expects(:output_buffer).returns(output_buffer).at_least(0)
812  
-    # if the output_buffer is changed, the new one should be html_safe
813  
-    cache_helper.expects(:output_buffer=).with(responds_with(:html_safe?, true)).returns(true).at_least(0)
  812
+    # if the output_buffer is changed, the new one should be html_safe and of the same type
  813
+    cache_helper.expects(:output_buffer=).with(responds_with(:html_safe?, true)).with(instance_of(output_buffer.class)).at_least(0)
814 814
 
815 815
     assert_nothing_raised do
816 816
       cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }
@@ -825,8 +825,8 @@ def test_safe_buffer
825 825
     cache_helper.extend(ActionView::Helpers::CacheHelper)
826 826
     cache_helper.expects(:controller).returns(controller).at_least(0)
827 827
     cache_helper.expects(:output_buffer).returns(output_buffer).at_least(0)
828  
-    # if the output_buffer is changed, the new one should be html_safe
829  
-    cache_helper.expects(:output_buffer=).with(responds_with(:html_safe?, true)).returns(true).at_least(0)
  828
+    # if the output_buffer is changed, the new one should be html_safe and of the same type
  829
+    cache_helper.expects(:output_buffer=).with(responds_with(:html_safe?, true)).with(instance_of(output_buffer.class)).at_least(0)
830 830
 
831 831
     assert_nothing_raised do
832 832
       cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }

0 notes on commit 39a4f67

Please sign in to comment.
Something went wrong with that request. Please try again.