diff options
author | Collin Miller <collintmiller@gmail.com> | 2010-09-12 05:30:21 +0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-09-12 07:35:54 +0800 |
commit | 96650f704a7a36097d634972484a305a639143c7 (patch) | |
tree | bcb08700c195984bb0e7a882bf42da8dcbc9588d /actionpack/test/dispatch | |
parent | 0aa66f04e4b4698718023cacb18612e04a4c5eb1 (diff) | |
download | rails-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')
-rw-r--r-- | actionpack/test/dispatch/middleware_stack_test.rb | 17 |
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 |