diff options
Diffstat (limited to 'railties/test/application/middleware_test.rb')
-rw-r--r-- | railties/test/application/middleware_test.rb | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index 4703a59326..d0a550d2f0 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -1,8 +1,9 @@ require 'isolation/abstract_unit' require 'stringio' +require 'rack/test' module ApplicationTests - class MiddlewareTest < Test::Unit::TestCase + class MiddlewareTest < ActiveSupport::TestCase include ActiveSupport::Testing::Isolation def setup @@ -33,6 +34,7 @@ module ApplicationTests "ActionDispatch::RequestId", "Rails::Rack::Logger", # must come after Rack::MethodOverride to properly log overridden methods "ActionDispatch::ShowExceptions", + "ActionDispatch::DebugExceptions", "ActionDispatch::RemoteIp", "Rack::Sendfile", "ActionDispatch::Reloader", @@ -74,7 +76,7 @@ module ApplicationTests add_to_config "config.force_ssl = true" add_to_config "config.ssl_options = { :host => 'example.com' }" boot! - + assert_equal AppTemplate::Application.middleware.first.args, [{:host => 'example.com'}] end @@ -104,10 +106,11 @@ module ApplicationTests assert !middleware.include?("ActionDispatch::Static") end - test "includes show exceptions even action_dispatch.show_exceptions is disabled" do + test "includes exceptions middlewares even if action_dispatch.show_exceptions is disabled" do add_to_config "config.action_dispatch.show_exceptions = false" boot! assert middleware.include?("ActionDispatch::ShowExceptions") + assert middleware.include?("ActionDispatch::DebugExceptions") end test "removes ActionDispatch::Reloader if cache_classes is true" do @@ -129,13 +132,13 @@ module ApplicationTests assert_equal "Rack::Config", middleware.second end - test "RAILS_CACHE does not respond to middleware" do + test "Rails.cache does not respond to middleware" do add_to_config "config.cache_store = :memory_store" boot! assert_equal "Rack::Runtime", middleware.third end - test "RAILS_CACHE does respond to middleware" do + test "Rails.cache does respond to middleware" do boot! assert_equal "Rack::Runtime", middleware.fourth end @@ -191,24 +194,12 @@ module ApplicationTests assert_equal nil, last_response.headers["Etag"] end - # Show exceptions middleware - test "show exceptions middleware filter backtrace before logging" do - my_middleware = Struct.new(:app) do - def call(env) - raise "Failure" - end - end - - make_basic_app do |app| - app.config.middleware.use my_middleware - end - - stringio = StringIO.new - Rails.logger = Logger.new(stringio) - - env = Rack::MockRequest.env_for("/") + test "ORIGINAL_FULLPATH is passed to env" do + boot! + env = ::Rack::MockRequest.env_for("/foo/?something") Rails.application.call(env) - assert_no_match(/action_dispatch/, stringio.string) + + assert_equal "/foo/?something", env["ORIGINAL_FULLPATH"] end private |