Permalink
Browse files

Add Streaming to new base

  • Loading branch information...
1 parent 59b32f2 commit 386ff66e5ed4fbe1e060610d4226a4eb22dca766 @lifo lifo committed May 21, 2009
View
@@ -63,7 +63,7 @@ Rake::TestTask.new(:test_new_base_on_old_tests) do |t|
t.test_files = %w(
addresses_render base benchmark caching capture content_type dispatcher
flash mime_responds record_identifier redirect render rescue url_rewriter
- webservice verification request_forgery_protection
+ webservice verification request_forgery_protection send_file
).map { |name| "test/controller/#{name}_test.rb" }
end
@@ -88,6 +88,7 @@ def send_file(path, options = {}) #:doc:
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
@@ -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
@@ -27,6 +27,7 @@ class Base < Http
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
@@ -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 @@ def set_test_assigns
@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
@@ -54,6 +54,7 @@ def process(action, parameters = nil, session = nil, flash = nil, http_method =
@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)
@@ -40,17 +40,19 @@ def test_file_nostream
assert_equal file_data, response.body
end
- def test_file_stream
- response = nil
- assert_nothing_raised { response = process('file') }
- assert_not_nil response
- assert_kind_of Array, response.body_parts
-
- require 'stringio'
- output = StringIO.new
- output.binmode
- assert_nothing_raised { response.body_parts.each { |part| output << part.to_s } }
- assert_equal file_data, output.string
+ for_tag(:old_base) do
+ def test_file_stream
+ response = nil
+ assert_nothing_raised { response = process('file') }
+ assert_not_nil response
+ assert_kind_of Array, response.body_parts
+
+ require 'stringio'
+ output = StringIO.new
+ output.binmode
+ assert_nothing_raised { response.body_parts.each { |part| output << part.to_s } }
+ assert_equal file_data, output.string
+ end
end
def test_file_url_based_filename

0 comments on commit 386ff66

Please sign in to comment.