Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created Aug 25, 2015
Embed
What would you like to do?
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb
index d68fa16..fe4f7a6 100644
--- a/actionpack/lib/action_controller/metal.rb
+++ b/actionpack/lib/action_controller/metal.rb
@@ -259,5 +259,13 @@ module ActionController
lambda { |env| new.dispatch(name, ActionDispatch::Request.new(env)) }
end
end
+
+ 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 c026d0e..3e3a424 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 1a61139..39ae8cf 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment