diff options
author | wycats <wycats@gmail.com> | 2010-06-02 15:53:10 +0200 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-06-02 15:53:10 +0200 |
commit | 26c5680bd01bd0e525eccc5d47a2e7126d9383f7 (patch) | |
tree | c655c56511ef89ba55c554a0aa7d82b1cd062f78 /actionpack/test | |
parent | b870daba5ff71973b237616fb95f90bb321ae7fb (diff) | |
parent | 4b91daff13be43ed913a97ffc8ad1b3f77fd9690 (diff) | |
download | rails-26c5680bd01bd0e525eccc5d47a2e7126d9383f7.tar.gz rails-26c5680bd01bd0e525eccc5d47a2e7126d9383f7.tar.bz2 rails-26c5680bd01bd0e525eccc5d47a2e7126d9383f7.zip |
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/new_base/middleware_test.rb | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/actionpack/test/controller/new_base/middleware_test.rb b/actionpack/test/controller/new_base/middleware_test.rb index 65942ebc15..26a66c91a6 100644 --- a/actionpack/test/controller/new_base/middleware_test.rb +++ b/actionpack/test/controller/new_base/middleware_test.rb @@ -28,7 +28,6 @@ module MiddlewareTest class MyController < ActionController::Metal use MyMiddleware - middleware.insert_before MyMiddleware, ExclaimerMiddleware def index @@ -39,8 +38,23 @@ module MiddlewareTest class InheritedController < MyController end - module MiddlewareTests - extend ActiveSupport::Testing::Declarative + class ActionsController < ActionController::Metal + use MyMiddleware, :only => :show + middleware.insert_before MyMiddleware, ExclaimerMiddleware, :except => :index + + def index + self.response_body = "index" + end + + def show + self.response_body = "show" + end + end + + class TestMiddleware < ActiveSupport::TestCase + def setup + @app = MyController.action(:index) + end test "middleware that is 'use'd is called as part of the Rack application" do result = @app.call(env_for("/")) @@ -52,13 +66,13 @@ module MiddlewareTest result = @app.call(env_for("/")) assert_equal "First!", result[1]["Middleware-Order"] end - end - class TestMiddleware < ActiveSupport::TestCase - include MiddlewareTests + test "middleware stack accepts only and except as options" do + result = ActionsController.action(:show).call(env_for("/")) + assert_equal "First!", result[1]["Middleware-Order"] - def setup - @app = MyController.action(:index) + result = ActionsController.action(:index).call(env_for("/")) + assert_nil result[1]["Middleware-Order"] end def env_for(url) @@ -70,8 +84,5 @@ module MiddlewareTest def setup @app = InheritedController.action(:index) end - - test "middleware inherits" do - end end end |