aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/middleware_stack_test.rb
diff options
context:
space:
mode:
authorCollin Miller <collintmiller@gmail.com>2010-09-12 05:30:21 +0800
committerJosé Valim <jose.valim@gmail.com>2010-09-12 07:35:54 +0800
commit96650f704a7a36097d634972484a305a639143c7 (patch)
treebcb08700c195984bb0e7a882bf42da8dcbc9588d /actionpack/test/dispatch/middleware_stack_test.rb
parent0aa66f04e4b4698718023cacb18612e04a4c5eb1 (diff)
downloadrails-96650f704a7a36097d634972484a305a639143c7.tar.gz
rails-96650f704a7a36097d634972484a305a639143c7.tar.bz2
rails-96650f704a7a36097d634972484a305a639143c7.zip
added block arguments to ActionController::Metal#use
Useful for cases such as warden, where a block configuration is taken. class SomeController < ApplicationController use RailsWarden::Manager do |manager| manager.default_strategies :facebook_oauth manager.failure_app = SomeController.action(:authorize) end end
Diffstat (limited to 'actionpack/test/dispatch/middleware_stack_test.rb')
-rw-r--r--actionpack/test/dispatch/middleware_stack_test.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/actionpack/test/dispatch/middleware_stack_test.rb b/actionpack/test/dispatch/middleware_stack_test.rb
index 6a1a4f556f..831f3db3e2 100644
--- a/actionpack/test/dispatch/middleware_stack_test.rb
+++ b/actionpack/test/dispatch/middleware_stack_test.rb
@@ -4,6 +4,12 @@ class MiddlewareStackTest < ActiveSupport::TestCase
class FooMiddleware; end
class BarMiddleware; end
class BazMiddleware; end
+ class BlockMiddleware
+ attr_reader :block
+ def initialize(&block)
+ @block = block
+ end
+ end
def setup
@stack = ActionDispatch::MiddlewareStack.new
@@ -39,7 +45,16 @@ class MiddlewareStackTest < ActiveSupport::TestCase
assert_equal BazMiddleware, @stack.last.klass
assert_equal([true, {:foo => "bar"}], @stack.last.args)
end
-
+
+ test "use should push middleware class with block arguments onto the stack" do
+ proc = Proc.new {}
+ assert_difference "@stack.size" do
+ @stack.use(BlockMiddleware, &proc)
+ end
+ assert_equal BlockMiddleware, @stack.last.klass
+ assert_equal proc, @stack.last.block
+ end
+
test "insert inserts middleware at the integer index" do
@stack.insert(1, BazMiddleware)
assert_equal BazMiddleware, @stack[1].klass