From c279c82e1b481bcbd021337a47dc6fa5c8a8d996 Mon Sep 17 00:00:00 2001 From: Wayne See Date: Sat, 12 Feb 2011 23:24:39 +0800 Subject: [PATCH] prevent caches_action from setting response body to nil --- .../lib/action_controller/caching/actions.rb | 4 +--- actionpack/test/controller/caching_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index a4bac3c..432cd75 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -103,12 +103,10 @@ module ActionController #:nodoc: end def _save_fragment(name, options) - return unless caching_allowed? - content = response_body content = content.join if content.is_a?(Array) - write_fragment(name, content, options) + caching_allowed? ? write_fragment(name, content, options) : content end protected diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index cc393d3..6e14e97 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -476,6 +476,11 @@ class ActionCacheTest < ActionController::TestCase assert_response :forbidden end + def test_response_body_not_nil_for_not_cached_response + get :forbidden + assert_not_nil @response.body + end + def test_xml_version_of_resource_is_treated_as_different_cache with_routing do |set| set.draw do -- 1.7.3.5