diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/metal.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 2 | ||||
-rw-r--r-- | actionpack/test/abstract_unit.rb | 10 |
3 files changed, 13 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index d68fa16847..54980aa453 100644 --- a/actionpack/lib/action_controller/metal.rb +++ b/actionpack/lib/action_controller/metal.rb @@ -259,5 +259,15 @@ module ActionController lambda { |env| new.dispatch(name, ActionDispatch::Request.new(env)) } end end + + # Direct dispatch to the controller. Instantiates the controller, then + # executes the action named +name+. + def self.dispatch(name, req) + if middleware_stack.any? + middleware_stack.build(name) { |env| new.dispatch(name, req) }.call req.env + else + new.dispatch(name, req) + end + end end end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index c026d0e2d9..3e3a424df3 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -44,7 +44,7 @@ module ActionDispatch end def dispatch(controller, action, req) - controller.action(action).call(req.env) + controller.dispatch(action, req) end end diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 1a61139dfe..39ae8cf899 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -124,16 +124,10 @@ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase class NullController def initialize(controller_name) @controller = controller_name - @action = nil end - def action(action_name) - @action = action_name - self - end - - def call(env) - [200, {'Content-Type' => 'text/html'}, ["#{@controller}##{@action}"]] + def dispatch(action, req) + [200, {'Content-Type' => 'text/html'}, ["#{@controller}##{action}"]] end end |