diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-07 14:26:21 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-07 15:37:31 -0700 |
commit | 83b767cef90abfc4c2ee9f4b451b0215501fae9a (patch) | |
tree | 1655677c718b8f33665c106dd631c42f798d2926 /actionpack/test/dispatch | |
parent | 435b224e7ec42194d974a90b89a4562ee876aafc (diff) | |
download | rails-83b767cef90abfc4c2ee9f4b451b0215501fae9a.tar.gz rails-83b767cef90abfc4c2ee9f4b451b0215501fae9a.tar.bz2 rails-83b767cef90abfc4c2ee9f4b451b0215501fae9a.zip |
Using strings or symbols for middleware class names is deprecated.
Convert things like this:
middleware.use "Foo::Bar"
to this:
middleware.use Foo::Bar
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r-- | actionpack/test/dispatch/middleware_stack/middleware_test.rb | 6 | ||||
-rw-r--r-- | actionpack/test/dispatch/middleware_stack_test.rb | 36 |
2 files changed, 19 insertions, 23 deletions
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 |