Skip to content

Commit d7be30e

Browse files
committed
Remove deprecated methods related to controller filters
`skip_action_callback`, `skip_filter`, `before_filter`, `prepend_before_filter`, `skip_before_filter`, `append_before_filter`, `around_filter` `prepend_around_filter`, `skip_around_filter`, `append_around_filter`, `after_filter`, `prepend_after_filter`, `skip_after_filter` and `append_after_filter`.
1 parent 02989ee commit d7be30e

File tree

4 files changed

+8
-116
lines changed

4 files changed

+8
-116
lines changed

‎actionpack/CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
* Remove deprecated methods `skip_action_callback`, `skip_filter`, `before_filter`,
2+
`prepend_before_filter`, `skip_before_filter`, `append_before_filter`, `around_filter`
3+
`prepend_around_filter`, `skip_around_filter`, `append_around_filter`, `after_filter`,
4+
`prepend_after_filter`, `skip_after_filter` and `append_after_filter`.
5+
6+
*Rafael Mendonça França*
7+
18
* Show an "unmatched constraints" error when params fail to match constraints
29
on a matched route, rather than a "missing keys" error.
310

‎actionpack/lib/abstract_controller/callbacks.rb‎

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,6 @@ def _normalize_callback_option(options, from, to) # :nodoc:
5454
end
5555
end
5656

57-
# Skip before, after, and around action callbacks matching any of the names.
58-
#
59-
# ==== Parameters
60-
# * <tt>names</tt> - A list of valid names that could be used for
61-
# callbacks. Note that skipping uses Ruby equality, so it's
62-
# impossible to skip a callback defined using an anonymous proc
63-
# using #skip_action_callback.
64-
def skip_action_callback(*names)
65-
ActiveSupport::Deprecation.warn("`skip_action_callback` is deprecated and will be removed in Rails 5.1. Please use skip_before_action, skip_after_action or skip_around_action instead.")
66-
skip_before_action(*names, raise: false)
67-
skip_after_action(*names, raise: false)
68-
skip_around_action(*names, raise: false)
69-
end
70-
71-
def skip_filter(*names)
72-
ActiveSupport::Deprecation.warn("`skip_filter` is deprecated and will be removed in Rails 5.1. Use skip_before_action, skip_after_action or skip_around_action instead.")
73-
skip_action_callback(*names)
74-
end
75-
7657
# Take callback names and an optional callback proc, normalize them,
7758
# then call the block with each callback. This allows us to abstract
7859
# the normalization across several methods that use it.
@@ -187,22 +168,12 @@ def _insert_callbacks(callbacks, block = nil)
187168
end
188169
end
189170

190-
define_method "#{callback}_filter" do |*names, &blk|
191-
ActiveSupport::Deprecation.warn("#{callback}_filter is deprecated and will be removed in Rails 5.1. Use #{callback}_action instead.")
192-
send("#{callback}_action", *names, &blk)
193-
end
194-
195171
define_method "prepend_#{callback}_action" do |*names, &blk|
196172
_insert_callbacks(names, blk) do |name, options|
197173
set_callback(:process_action, callback, name, options.merge(prepend: true))
198174
end
199175
end
200176

201-
define_method "prepend_#{callback}_filter" do |*names, &blk|
202-
ActiveSupport::Deprecation.warn("prepend_#{callback}_filter is deprecated and will be removed in Rails 5.1. Use prepend_#{callback}_action instead.")
203-
send("prepend_#{callback}_action", *names, &blk)
204-
end
205-
206177
# Skip a before, after or around callback. See _insert_callbacks
207178
# for details on the allowed parameters.
208179
define_method "skip_#{callback}_action" do |*names|
@@ -211,18 +182,8 @@ def _insert_callbacks(callbacks, block = nil)
211182
end
212183
end
213184

214-
define_method "skip_#{callback}_filter" do |*names, &blk|
215-
ActiveSupport::Deprecation.warn("skip_#{callback}_filter is deprecated and will be removed in Rails 5.1. Use skip_#{callback}_action instead.")
216-
send("skip_#{callback}_action", *names, &blk)
217-
end
218-
219185
# *_action is the same as append_*_action
220186
alias_method :"append_#{callback}_action", :"#{callback}_action"
221-
222-
define_method "append_#{callback}_filter" do |*names, &blk|
223-
ActiveSupport::Deprecation.warn("append_#{callback}_filter is deprecated and will be removed in Rails 5.1. Use append_#{callback}_action instead.")
224-
send("append_#{callback}_action", *names, &blk)
225-
end
226187
end
227188
end
228189
end

‎actionpack/test/abstract/callbacks_test.rb‎

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -264,53 +264,5 @@ class TestCallbacksWithArgs < ActiveSupport::TestCase
264264
assert_equal "Hello world Howdy!", controller.response_body
265265
end
266266
end
267-
268-
class AliasedCallbacks < ControllerWithCallbacks
269-
ActiveSupport::Deprecation.silence do
270-
before_filter :first
271-
after_filter :second
272-
around_filter :aroundz
273-
end
274-
275-
def first
276-
@text = "Hello world"
277-
end
278-
279-
def second
280-
@second = "Goodbye"
281-
end
282-
283-
def aroundz
284-
@aroundz = "FIRST"
285-
yield
286-
@aroundz << "SECOND"
287-
end
288-
289-
def index
290-
@text ||= nil
291-
self.response_body = @text.to_s
292-
end
293-
end
294-
295-
class TestAliasedCallbacks < ActiveSupport::TestCase
296-
def setup
297-
@controller = AliasedCallbacks.new
298-
end
299-
300-
test "before_filter works" do
301-
@controller.process(:index)
302-
assert_equal "Hello world", @controller.response_body
303-
end
304-
305-
test "after_filter works" do
306-
@controller.process(:index)
307-
assert_equal "Goodbye", @controller.instance_variable_get("@second")
308-
end
309-
310-
test "around_filter works" do
311-
@controller.process(:index)
312-
assert_equal "FIRSTSECOND", @controller.instance_variable_get("@aroundz")
313-
end
314-
end
315267
end
316268
end

‎actionpack/test/controller/filters_test.rb‎

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class ActionController::Base
44
class << self
5-
%w(append_around_action prepend_after_action prepend_around_action prepend_before_action skip_after_action skip_before_action skip_action_callback).each do |pending|
5+
%w(append_around_action prepend_after_action prepend_around_action prepend_before_action skip_after_action skip_before_action).each do |pending|
66
define_method(pending) do |*args|
77
$stderr.puts "#{pending} unimplemented: #{args.inspect}"
88
end unless method_defined?(pending)
@@ -956,13 +956,6 @@ class ControllerWithTwoLessFilters < ControllerWithAllTypesOfFilters
956956
skip_after_action :after
957957
end
958958

959-
class SkipFilterUsingSkipActionCallback < ControllerWithAllTypesOfFilters
960-
ActiveSupport::Deprecation.silence do
961-
skip_action_callback :around_again
962-
skip_action_callback :after
963-
end
964-
end
965-
966959
class YieldingAroundFiltersTest < ActionController::TestCase
967960
include PostsController::AroundExceptions
968961

@@ -1047,27 +1040,6 @@ def test_last_action_in_multiple_before_action_chain_halts
10471040
assert_equal 3, controller.instance_variable_get(:@try)
10481041
end
10491042

1050-
def test_skipping_with_skip_action_callback
1051-
test_process(SkipFilterUsingSkipActionCallback,"no_raise")
1052-
assert_equal "before around (before yield) around (after yield)", @controller.instance_variable_get(:@ran_filter).join(" ")
1053-
end
1054-
1055-
def test_deprecated_skip_action_callback
1056-
assert_deprecated do
1057-
Class.new(PostsController) do
1058-
skip_action_callback :clean_up
1059-
end
1060-
end
1061-
end
1062-
1063-
def test_deprecated_skip_filter
1064-
assert_deprecated do
1065-
Class.new(PostsController) do
1066-
skip_filter :clean_up
1067-
end
1068-
end
1069-
end
1070-
10711043
protected
10721044
def test_process(controller, action = "show")
10731045
@controller = controller.is_a?(Class) ? controller.new : controller

0 commit comments

Comments
 (0)