aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2012-02-14 21:51:18 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2012-02-14 21:53:15 -0200
commit5843069e7ecca3e5f71f9b99280beb88b79e4c67 (patch)
tree4bdafd1aac3f30542ee91bdf8c6dced115fab825
parent4baaf0a0fec19eab68b3e39709f2b6856cee3b43 (diff)
downloadrails-5843069e7ecca3e5f71f9b99280beb88b79e4c67.tar.gz
rails-5843069e7ecca3e5f71f9b99280beb88b79e4c67.tar.bz2
rails-5843069e7ecca3e5f71f9b99280beb88b79e4c67.zip
Rack body respond to each and not to join
This fixes undef `to_str' for Rack::Chunked::Body when using caches_action + streaming on an action Closes #5027
-rw-r--r--actionpack/lib/action_controller/caching/actions.rb6
-rw-r--r--actionpack/test/controller/caching_test.rb12
2 files changed, 16 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb
index bd3b0b5df3..ba96735e56 100644
--- a/actionpack/lib/action_controller/caching/actions.rb
+++ b/actionpack/lib/action_controller/caching/actions.rb
@@ -103,8 +103,10 @@ module ActionController #:nodoc:
end
def _save_fragment(name, options)
- content = response_body
- content = content.join if content.is_a?(Array)
+ content = ""
+ response_body.each do |parts|
+ content << parts
+ end
if caching_allowed?
write_fragment(name, content, options)
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index bb4fb7bf07..10f73c3da3 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -237,6 +237,7 @@ class ActionCachingTestController < CachingController
caches_action :with_format_and_http_param, :cache_path => Proc.new { |c| { :key => 'value' } }
caches_action :layout_false, :layout => false
caches_action :record_not_found, :four_oh_four, :simple_runtime_error
+ caches_action :streaming
layout 'talk_from_action'
@@ -296,6 +297,10 @@ class ActionCachingTestController < CachingController
expire_action url_for(:controller => 'action_caching_test', :action => 'index')
render :nothing => true
end
+
+ def streaming
+ render :text => "streaming", :stream => true
+ end
end
class MockTime < Time
@@ -647,6 +652,13 @@ class ActionCacheTest < ActionController::TestCase
assert_response 500
end
+ def test_action_caching_plus_streaming
+ get :streaming
+ assert_response :success
+ assert_match(/streaming/, @response.body)
+ assert fragment_exist?('hostname.com/action_caching_test/streaming')
+ end
+
private
def content_to_cache
assigns(:cache_this)