Deprecate AbstractController::Callbacks#skip_action_callback

As part of #19029, in future `skip_before_action`, `skip_after_action` and
`skip_around_action` will raise an ArgumentError if the specified
callback does not exist. `skip_action_callback` calls all three of these
methods and will almost certainly result in an ArgumentError. If anyone
wants to remove all three callbacks then they can still call the three
individual methods. Therefore let's deprecate `skip_action_callback` now
and remove it when #19029 is merged.
This commit is contained in:
Iain Beeston 2015-02-23 20:33:04 +00:00
parent 43fb818266
commit 3fbc632843
3 changed files with 28 additions and 2 deletions

@ -1,3 +1,8 @@
* Deprecate AbstractController#skip_action_callback in favor of individual skip_callback methods
(which can be made to raise an error if no callback was removed).
*Iain Beeston*
* Alias the `ActionDispatch::Request#uuid` method to `ActionDispatch::Request#request_id`. * Alias the `ActionDispatch::Request#uuid` method to `ActionDispatch::Request#request_id`.
Due to implementation, `config.log_tags = [:request_id]` also works in substitute Due to implementation, `config.log_tags = [:request_id]` also works in substitute
for `config.log_tags = [:uuid]`. for `config.log_tags = [:uuid]`.

@ -63,6 +63,7 @@ def _normalize_callback_option(options, from, to) # :nodoc:
# impossible to skip a callback defined using an anonymous proc # impossible to skip a callback defined using an anonymous proc
# using #skip_action_callback # using #skip_action_callback
def skip_action_callback(*names) def skip_action_callback(*names)
ActiveSupport::Deprecation.warn('`skip_action_callback` is deprecated and will be removed in the next major version of Rails. Please use skip_before_action, skip_after_action or skip_around_action instead.')
skip_before_action(*names) skip_before_action(*names)
skip_after_action(*names) skip_after_action(*names)
skip_around_action(*names) skip_around_action(*names)

@ -967,8 +967,15 @@ def around_again
end end
class ControllerWithTwoLessFilters < ControllerWithAllTypesOfFilters class ControllerWithTwoLessFilters < ControllerWithAllTypesOfFilters
skip_action_callback :around_again skip_around_action :around_again
skip_action_callback :after skip_after_action :after
end
class SkipFilterUsingSkipActionCallback < ControllerWithAllTypesOfFilters
ActiveSupport::Deprecation.silence do
skip_action_callback :around_again
skip_action_callback :after
end
end end
class YieldingAroundFiltersTest < ActionController::TestCase class YieldingAroundFiltersTest < ActionController::TestCase
@ -1055,6 +1062,19 @@ def test_last_action_in_multiple_before_action_chain_halts
assert_equal 3, controller.instance_variable_get(:@try) assert_equal 3, controller.instance_variable_get(:@try)
end end
def test_skipping_with_skip_action_callback
test_process(SkipFilterUsingSkipActionCallback,'no_raise')
assert_equal 'before around (before yield) around (after yield)', assigns['ran_filter'].join(' ')
end
def test_deprecated_skip_action_callback
assert_deprecated do
Class.new(TestController) do
skip_action_callback :clean_up
end
end
end
protected protected
def test_process(controller, action = "show") def test_process(controller, action = "show")
@controller = controller.is_a?(Class) ? controller.new : controller @controller = controller.is_a?(Class) ? controller.new : controller