aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-05-21 21:48:26 +0200
committerPratik Naik <pratiknaik@gmail.com>2009-05-21 21:48:42 +0200
commit386ff66e5ed4fbe1e060610d4226a4eb22dca766 (patch)
tree4ada983959c4072a2f37c83a3317c4291c36171b /actionpack
parent59b32f2883b58a1e7bf2c246801a605b673e3fb6 (diff)
downloadrails-386ff66e5ed4fbe1e060610d4226a4eb22dca766.tar.gz
rails-386ff66e5ed4fbe1e060610d4226a4eb22dca766.tar.bz2
rails-386ff66e5ed4fbe1e060610d4226a4eb22dca766.zip
Add Streaming to new base
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/Rakefile2
-rw-r--r--actionpack/lib/action_controller/base/streaming.rb1
-rw-r--r--actionpack/lib/action_controller/new_base.rb2
-rw-r--r--actionpack/lib/action_controller/new_base/base.rb1
-rw-r--r--actionpack/lib/action_controller/new_base/testing.rb9
-rw-r--r--actionpack/lib/action_controller/testing/process2.rb1
-rw-r--r--actionpack/test/controller/send_file_test.rb24
7 files changed, 25 insertions, 15 deletions
diff --git a/actionpack/Rakefile b/actionpack/Rakefile
index 84b42b4eb3..5968317c60 100644
--- a/actionpack/Rakefile
+++ b/actionpack/Rakefile
@@ -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
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)
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb
index 6007ebef7a..3a99774ae0 100644
--- a/actionpack/test/controller/send_file_test.rb
+++ b/actionpack/test/controller/send_file_test.rb
@@ -40,17 +40,19 @@ class SendFileTest < ActionController::TestCase
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