aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG.md4
-rw-r--r--actionpack/lib/action_controller/metal.rb2
-rw-r--r--actionpack/lib/action_dispatch/middleware/stack.rb21
-rw-r--r--actionpack/test/dispatch/middleware_stack_test.rb41
4 files changed, 8 insertions, 60 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 4cb56160fd..edb43172f6 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Remove deprecated support to passing strings or symbols to the middleware stack.
+
+ *Rafael Mendonça França*
+
* Change HSTS subdomain to true.
*Rafael Mendonça França*
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb
index 075e4504c2..ed93a2f09c 100644
--- a/actionpack/lib/action_controller/metal.rb
+++ b/actionpack/lib/action_controller/metal.rb
@@ -55,7 +55,7 @@ module ActionController
list = except
end
- Middleware.new(get_class(klass), args, list, strategy, block)
+ Middleware.new(klass, args, list, strategy, block)
end
end
diff --git a/actionpack/lib/action_dispatch/middleware/stack.rb b/actionpack/lib/action_dispatch/middleware/stack.rb
index 466eb8b3f1..6949b31e75 100644
--- a/actionpack/lib/action_dispatch/middleware/stack.rb
+++ b/actionpack/lib/action_dispatch/middleware/stack.rb
@@ -88,7 +88,6 @@ module ActionDispatch
end
def delete(target)
- target = get_class target
middlewares.delete_if { |m| m.klass == target }
end
@@ -103,31 +102,13 @@ module ActionDispatch
private
def assert_index(index, where)
- index = get_class index
i = index.is_a?(Integer) ? index : middlewares.index { |m| m.klass == index }
raise "No such middleware to insert #{where}: #{index.inspect}" unless i
i
end
- def get_class(klass)
- if klass.is_a?(String) || klass.is_a?(Symbol)
- classcache = ActiveSupport::Dependencies::Reference
- converted_klass = classcache[klass.to_s]
- ActiveSupport::Deprecation.warn <<-eowarn
-Passing strings or symbols to the middleware builder is deprecated, please change
-them to actual class references. For example:
-
- "#{klass}" => #{converted_klass}
-
- eowarn
- converted_klass
- else
- klass
- end
- end
-
def build_middleware(klass, args, block)
- Middleware.new(get_class(klass), args, block)
+ Middleware.new(klass, args, block)
end
end
end
diff --git a/actionpack/test/dispatch/middleware_stack_test.rb b/actionpack/test/dispatch/middleware_stack_test.rb
index 27da5935b5..481aa22b10 100644
--- a/actionpack/test/dispatch/middleware_stack_test.rb
+++ b/actionpack/test/dispatch/middleware_stack_test.rb
@@ -18,14 +18,6 @@ class MiddlewareStackTest < ActiveSupport::TestCase
@stack.use BarMiddleware
end
- def test_delete_with_string_is_deprecated
- assert_deprecated do
- assert_difference "@stack.size", -1 do
- @stack.delete FooMiddleware.name
- end
- end
- end
-
def test_delete_works
assert_difference "@stack.size", -1 do
@stack.delete FooMiddleware
@@ -39,24 +31,6 @@ class MiddlewareStackTest < ActiveSupport::TestCase
assert_equal BazMiddleware, @stack.last.klass
end
- test "use should push middleware as a string onto the stack" do
- assert_deprecated do
- assert_difference "@stack.size" do
- @stack.use "MiddlewareStackTest::BazMiddleware"
- end
- assert_equal BazMiddleware, @stack.last.klass
- end
- end
-
- test "use should push middleware as a symbol onto the stack" do
- assert_deprecated do
- assert_difference "@stack.size" do
- @stack.use :"MiddlewareStackTest::BazMiddleware"
- end
- assert_equal BazMiddleware, @stack.last.klass
- end
- end
-
test "use should push middleware class with arguments onto the stack" do
assert_difference "@stack.size" do
@stack.use BazMiddleware, true, foo: "bar"
@@ -107,10 +81,8 @@ class MiddlewareStackTest < ActiveSupport::TestCase
end
test "unshift adds a new middleware at the beginning of the stack" do
- assert_deprecated do
- @stack.unshift :"MiddlewareStackTest::BazMiddleware"
- assert_equal BazMiddleware, @stack.first.klass
- end
+ @stack.unshift MiddlewareStackTest::BazMiddleware
+ assert_equal BazMiddleware, @stack.first.klass
end
test "raise an error on invalid index" do
@@ -123,15 +95,6 @@ class MiddlewareStackTest < ActiveSupport::TestCase
end
end
- test "lazy evaluates middleware class" do
- assert_deprecated do
- assert_difference "@stack.size" do
- @stack.use "MiddlewareStackTest::BazMiddleware"
- end
- assert_equal BazMiddleware, @stack.last.klass
- end
- end
-
test "can check if Middleware are equal - Class" do
assert_equal @stack.last, BarMiddleware
end