aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-05-02 15:21:19 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-05-02 15:21:19 -0700
commit186fee48c796b104b76ef69decb32ef396f435db (patch)
tree9f8b8c8c83af7bd2913c1283f51fd3c3492fea82 /actionpack/lib/action_controller
parent945bf9c254b5bfb56df874c1a3f7f0f1e89dc8b8 (diff)
parent24affdc88c4a4af03ce1ec5b23c3def18b90effe (diff)
downloadrails-186fee48c796b104b76ef69decb32ef396f435db.tar.gz
rails-186fee48c796b104b76ef69decb32ef396f435db.tar.bz2
rails-186fee48c796b104b76ef69decb32ef396f435db.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/base/base.rb14
-rw-r--r--actionpack/lib/action_controller/base/redirect.rb4
-rw-r--r--actionpack/lib/action_controller/dispatch/dispatcher.rb2
-rw-r--r--actionpack/lib/action_controller/dispatch/rescue.rb2
-rw-r--r--actionpack/lib/action_controller/routing/route_set.rb2
-rw-r--r--actionpack/lib/action_controller/testing/process.rb34
6 files changed, 35 insertions, 23 deletions
diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb
index 99b5963891..60567454b1 100644
--- a/actionpack/lib/action_controller/base/base.rb
+++ b/actionpack/lib/action_controller/base/base.rb
@@ -371,14 +371,12 @@ module ActionController #:nodoc:
class << self
def call(env)
- # HACK: For global rescue to have access to the original request and response
- request = env["action_controller.rescue.request"] ||= ActionDispatch::Request.new(env)
- response = env["action_controller.rescue.response"] ||= ActionDispatch::Response.new
- process(request, response)
+ new.call(env)
end
# Factory for the standard create, process loop where the controller is discarded after processing.
def process(request, response) #:nodoc:
+ ActiveSupport::Deprecation.warn("Controller.process has been deprecated. Use Controller.call instead", caller)
new.process(request, response)
end
@@ -511,6 +509,13 @@ module ActionController #:nodoc:
end
public
+ def call(env)
+ # HACK: For global rescue to have access to the original request and response
+ request = env["action_dispatch.rescue.request"] ||= ActionDispatch::Request.new(env)
+ response = env["action_dispatch.rescue.response"] ||= ActionDispatch::Response.new
+ process(request, response).to_a
+ end
+
# Extracts the action_name from the request parameters and performs that action.
def process(request, response, method = :perform_action, *arguments) #:nodoc:
response.request = request
@@ -820,7 +825,6 @@ module ActionController #:nodoc:
@template = ActionView::Base.new(self.class.view_paths, {}, self, formats)
response.template = @template if response.respond_to?(:template=)
@template.helpers.send :include, self.class.master_helper_module
- response.redirected_to = nil
@performed_render = @performed_redirect = false
end
diff --git a/actionpack/lib/action_controller/base/redirect.rb b/actionpack/lib/action_controller/base/redirect.rb
index 2e92117e7c..4849caac0a 100644
--- a/actionpack/lib/action_controller/base/redirect.rb
+++ b/actionpack/lib/action_controller/base/redirect.rb
@@ -48,8 +48,6 @@ module ActionController
status = 302
end
- response.redirected_to = options
-
case options
# The scheme name consist of a letter followed by any combination of
# letters, digits, and the plus ("+"), period ("."), or hyphen ("-")
@@ -82,8 +80,6 @@ module ActionController
# The response body is not reset here, see +erase_render_results+
def erase_redirect_results #:nodoc:
@performed_redirect = false
- response.redirected_to = nil
- response.redirected_to_method_params = nil
response.status = DEFAULT_RENDER_STATUS_CODE
response.headers.delete('Location')
end
diff --git a/actionpack/lib/action_controller/dispatch/dispatcher.rb b/actionpack/lib/action_controller/dispatch/dispatcher.rb
index bb9d8bd063..25844bf2a2 100644
--- a/actionpack/lib/action_controller/dispatch/dispatcher.rb
+++ b/actionpack/lib/action_controller/dispatch/dispatcher.rb
@@ -80,7 +80,7 @@ module ActionController
Routing::Routes.call(env)
rescue Exception => exception
if controller ||= (::ApplicationController rescue Base)
- controller.call_with_exception(env, exception).to_a
+ controller.call_with_exception(env, exception)
else
raise exception
end
diff --git a/actionpack/lib/action_controller/dispatch/rescue.rb b/actionpack/lib/action_controller/dispatch/rescue.rb
index df80ac0909..2f3b40c231 100644
--- a/actionpack/lib/action_controller/dispatch/rescue.rb
+++ b/actionpack/lib/action_controller/dispatch/rescue.rb
@@ -62,7 +62,7 @@ module ActionController #:nodoc:
def call_with_exception(env, exception) #:nodoc:
request = env["action_controller.rescue.request"] ||= ActionDispatch::Request.new(env)
response = env["action_controller.rescue.response"] ||= ActionDispatch::Response.new
- new.process(request, response, :rescue_action, exception)
+ new.process(request, response, :rescue_action, exception).to_a
end
end
diff --git a/actionpack/lib/action_controller/routing/route_set.rb b/actionpack/lib/action_controller/routing/route_set.rb
index 70cd1f642d..172b867bf0 100644
--- a/actionpack/lib/action_controller/routing/route_set.rb
+++ b/actionpack/lib/action_controller/routing/route_set.rb
@@ -430,7 +430,7 @@ module ActionController
def call(env)
request = ActionDispatch::Request.new(env)
app = Routing::Routes.recognize(request)
- app.call(env).to_a
+ app.call(env)
end
def recognize(request)
diff --git a/actionpack/lib/action_controller/testing/process.rb b/actionpack/lib/action_controller/testing/process.rb
index 8315a160ad..49e8322491 100644
--- a/actionpack/lib/action_controller/testing/process.rb
+++ b/actionpack/lib/action_controller/testing/process.rb
@@ -35,27 +35,27 @@ module ActionController #:nodoc:
end
data = params.to_query
- @env['CONTENT_LENGTH'] = data.length
+ @env['CONTENT_LENGTH'] = data.length.to_s
@env['rack.input'] = StringIO.new(data)
end
def recycle!
@env.delete_if { |k, v| k =~ /^(action_dispatch|rack)\.request/ }
+ @env.delete_if { |k, v| k =~ /^action_dispatch\.rescue/ }
@env['action_dispatch.request.query_parameters'] = {}
end
end
- # Integration test methods such as ActionController::Integration::Session#get
- # and ActionController::Integration::Session#post return objects of class
- # TestResponse, which represent the HTTP response results of the requested
- # controller actions.
- #
- # See Response for more information on controller response objects.
class TestResponse < ActionDispatch::TestResponse
def recycle!
- body_parts.clear
- headers.delete('ETag')
- headers.delete('Last-Modified')
+ @status = 200
+ @header = Rack::Utils::HeaderHash.new(DEFAULT_HEADERS)
+ @writer = lambda { |x| @body << x }
+ @block = nil
+ @length = 0
+ @body = []
+
+ @request = @template = nil
end
end
@@ -132,7 +132,19 @@ module ActionController #:nodoc:
build_request_uri(action, parameters)
Base.class_eval { include ProcessWithTest } unless Base < ProcessWithTest
- @controller.process(@request, @response)
+
+ env = @request.env
+ app = @controller
+
+ # TODO: Enable Lint
+ # app = Rack::Lint.new(app)
+
+ status, headers, body = app.call(env)
+ response = Rack::MockResponse.new(status, headers, body)
+
+ @response.request, @response.template = @request, @controller.template
+ @response.status, @response.headers, @response.body = response.status, response.headers, response.body
+ @response
end
def xml_http_request(request_method, action, parameters = nil, session = nil, flash = nil)