From 386ff66e5ed4fbe1e060610d4226a4eb22dca766 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 21 May 2009 21:48:26 +0200 Subject: Add Streaming to new base --- actionpack/lib/action_controller/base/streaming.rb | 1 + actionpack/lib/action_controller/new_base.rb | 2 +- actionpack/lib/action_controller/new_base/base.rb | 1 + actionpack/lib/action_controller/new_base/testing.rb | 9 +++++++-- actionpack/lib/action_controller/testing/process2.rb | 1 + 5 files changed, 11 insertions(+), 3 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_controller/base/streaming.rb b/actionpack/lib/action_controller/base/streaming.rb index 9f80f48c3d..b69b13eea8 100644 --- a/actionpack/lib/action_controller/base/streaming.rb +++ b/actionpack/lib/action_controller/base/streaming.rb @@ -88,6 +88,7 @@ module ActionController #:nodoc: head options[:status], X_SENDFILE_HEADER => path else if options[:stream] + # TODO : Make render :text => proc {} work with the new base render :status => options[:status], :text => Proc.new { |response, output| logger.info "Streaming file #{path}" unless logger.nil? len = options[:buffer_size] || 4096 diff --git a/actionpack/lib/action_controller/new_base.rb b/actionpack/lib/action_controller/new_base.rb index 93c54174b7..58c7382661 100644 --- a/actionpack/lib/action_controller/new_base.rb +++ b/actionpack/lib/action_controller/new_base.rb @@ -28,7 +28,7 @@ module ActionController autoload :Verification, 'action_controller/base/verification' autoload :Flash, 'action_controller/base/chained/flash' autoload :RequestForgeryProtection, 'action_controller/base/request_forgery_protection' - + autoload :Streaming, 'action_controller/base/streaming' require 'action_controller/routing' end diff --git a/actionpack/lib/action_controller/new_base/base.rb b/actionpack/lib/action_controller/new_base/base.rb index 3d8f785280..142699326e 100644 --- a/actionpack/lib/action_controller/new_base/base.rb +++ b/actionpack/lib/action_controller/new_base/base.rb @@ -27,6 +27,7 @@ module ActionController include ActionController::Flash include ActionController::Verification include ActionController::RequestForgeryProtection + include ActionController::Streaming # TODO: Extract into its own module # This should be moved together with other normalizing behavior diff --git a/actionpack/lib/action_controller/new_base/testing.rb b/actionpack/lib/action_controller/new_base/testing.rb index bc3bc70404..6a92c292bd 100644 --- a/actionpack/lib/action_controller/new_base/testing.rb +++ b/actionpack/lib/action_controller/new_base/testing.rb @@ -1,6 +1,6 @@ module ActionController module Testing - + # OMG MEGA HAX def process_with_new_base_test(request, response) @_request = request @@ -20,6 +20,11 @@ module ActionController @assigns[name] = value end end - + + # TODO : Rewrite tests using controller.headers= to use Rack env + def headers=(new_headers) + @_response ||= ActionDispatch::Response.new + @_response.headers.replace(new_headers) + end end end \ No newline at end of file diff --git a/actionpack/lib/action_controller/testing/process2.rb b/actionpack/lib/action_controller/testing/process2.rb index 2dafcaa5a9..6a95e638cd 100644 --- a/actionpack/lib/action_controller/testing/process2.rb +++ b/actionpack/lib/action_controller/testing/process2.rb @@ -54,6 +54,7 @@ module ActionController @controller.params.merge!(parameters) # Base.class_eval { include ProcessWithTest } unless Base < ProcessWithTest @controller.process_with_new_base_test(@request, @response) + @response end def build_request_uri(action, parameters) -- cgit v1.2.3