From 83b767cef90abfc4c2ee9f4b451b0215501fae9a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 7 Aug 2015 14:26:21 -0700 Subject: Using strings or symbols for middleware class names is deprecated. Convert things like this: middleware.use "Foo::Bar" to this: middleware.use Foo::Bar --- .../dispatch/middleware_stack/middleware_test.rb | 6 ---- actionpack/test/dispatch/middleware_stack_test.rb | 36 ++++++++++++---------- 2 files changed, 19 insertions(+), 23 deletions(-) (limited to 'actionpack/test/dispatch') diff --git a/actionpack/test/dispatch/middleware_stack/middleware_test.rb b/actionpack/test/dispatch/middleware_stack/middleware_test.rb index 6366d37aa4..28f9fa317b 100644 --- a/actionpack/test/dispatch/middleware_stack/middleware_test.rb +++ b/actionpack/test/dispatch/middleware_stack/middleware_test.rb @@ -33,12 +33,6 @@ module ActionDispatch @stack = ActionDispatch::MiddlewareStack.new end - def test_string_class - stack = ActionDispatch::MiddlewareStack.new - stack.use Omg.name - assert_equal Omg, stack.first.klass - end - def test_double_equal_works_with_classes k = Class.new stack.use k diff --git a/actionpack/test/dispatch/middleware_stack_test.rb b/actionpack/test/dispatch/middleware_stack_test.rb index 948a690979..354e95cf30 100644 --- a/actionpack/test/dispatch/middleware_stack_test.rb +++ b/actionpack/test/dispatch/middleware_stack_test.rb @@ -25,17 +25,21 @@ class MiddlewareStackTest < ActiveSupport::TestCase end test "use should push middleware as a string onto the stack" do - assert_difference "@stack.size" do - @stack.use "MiddlewareStackTest::BazMiddleware" + assert_deprecated do + assert_difference "@stack.size" do + @stack.use "MiddlewareStackTest::BazMiddleware" + end + assert_equal BazMiddleware, @stack.last.klass end - assert_equal BazMiddleware, @stack.last.klass end test "use should push middleware as a symbol onto the stack" do - assert_difference "@stack.size" do - @stack.use :"MiddlewareStackTest::BazMiddleware" + assert_deprecated do + assert_difference "@stack.size" do + @stack.use :"MiddlewareStackTest::BazMiddleware" + end + assert_equal BazMiddleware, @stack.last.klass end - assert_equal BazMiddleware, @stack.last.klass end test "use should push middleware class with arguments onto the stack" do @@ -88,8 +92,10 @@ class MiddlewareStackTest < ActiveSupport::TestCase end test "unshift adds a new middleware at the beginning of the stack" do - @stack.unshift :"MiddlewareStackTest::BazMiddleware" - assert_equal BazMiddleware, @stack.first.klass + assert_deprecated do + @stack.unshift :"MiddlewareStackTest::BazMiddleware" + assert_equal BazMiddleware, @stack.first.klass + end end test "raise an error on invalid index" do @@ -103,15 +109,11 @@ class MiddlewareStackTest < ActiveSupport::TestCase end test "lazy evaluates middleware class" do - assert_difference "@stack.size" do - @stack.use "MiddlewareStackTest::BazMiddleware" + assert_deprecated do + assert_difference "@stack.size" do + @stack.use "MiddlewareStackTest::BazMiddleware" + end + assert_equal BazMiddleware, @stack.last.klass end - assert_equal BazMiddleware, @stack.last.klass - end - - test "lazy compares so unloaded constants are not loaded" do - @stack.use "UnknownMiddleware" - @stack.use :"MiddlewareStackTest::BazMiddleware" - assert @stack.include?("::MiddlewareStackTest::BazMiddleware") end end -- cgit v1.2.3