Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix Action caching bug where an action that has a non-cacheable respo…

…nse always renders a nil response body. It now correctly renders the response body.

Note that only GET and HTTP 200 responses can be cached.

[#6480 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information...
commit beec6c8b2abfd3286bd7c0a1c7ecb04686af6448 1 parent cdfee85
@chuyeow chuyeow authored spastorino committed
View
8 actionpack/lib/action_controller/caching/actions.rb
@@ -103,12 +103,14 @@ def caches_action(*actions)
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)
+ if caching_allowed?
+ write_fragment(name, content, options)
+ else
+ content
+ end
end
protected
View
5 actionpack/test/controller/caching_test.rb
@@ -547,6 +547,11 @@ def test_four_oh_four_returns_404_for_multiple_requests
assert_response 404
end
+ def test_four_oh_four_renders_content
+ get :four_oh_four
+ assert_equal "404'd!", @response.body
+ end
+
def test_simple_runtime_error_returns_500_for_multiple_requests
get :simple_runtime_error
assert_response 500
Please sign in to comment.
Something went wrong with that request. Please try again.