diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index c26e09d8ac..b19d1488de 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -12,7 +12,7 @@ class ActionController::Base def before_actions filters = _process_action_callbacks.select { |c| c.kind == :before } - filters.map!(&:raw_filter) + filters.map!(&:filter) end end end diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index a86af00527..a65ff5cf72 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -289,21 +289,17 @@ module ActiveSupport end attr_accessor :kind, :name - attr_reader :chain_config + attr_reader :chain_config, :filter def initialize(name, filter, kind, options, chain_config) @chain_config = chain_config @name = name @kind = kind @filter = filter - @key = compute_identifier filter @if = check_conditionals(options[:if]) @unless = check_conditionals(options[:unless]) end - def filter; @key; end - def raw_filter; @filter; end - def merge_conditional_options(chain, if_option:, unless_option:) options = { if: @if.dup, @@ -367,15 +363,6 @@ module ActiveSupport conditionals.freeze end - def compute_identifier(filter) - case filter - when ::Proc - filter.object_id - else - filter - end - end - def conditions_lambdas @if.map { |c| CallTemplate.build(c, self).make_lambda } + @unless.map { |c| CallTemplate.build(c, self).inverted_lambda } diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb index 499698c1a3..a1cba3ce45 100644 --- a/activesupport/test/callbacks_test.rb +++ b/activesupport/test/callbacks_test.rb @@ -1129,15 +1129,6 @@ module CallbacksTest } end - def test_skip_lambda # raises error - calls = [] - callback = ->(o) { calls << o } - klass = build_class(callback) - assert_raises(ArgumentError) { klass.skip callback } - klass.new.run - assert_equal 10, calls.length - end - def test_skip_symbol # removes all calls = [] klass = build_class(:bar) diff --git a/activesupport/test/test_case_test.rb b/activesupport/test/test_case_test.rb index ac2923a313..e6342e8382 100644 --- a/activesupport/test/test_case_test.rb +++ b/activesupport/test/test_case_test.rb @@ -325,9 +325,9 @@ class SetupAndTeardownTest < ActiveSupport::TestCase teardown :foo, :sentinel def test_inherited_setup_callbacks - assert_equal [:reset_callback_record, :foo], self.class._setup_callbacks.map(&:raw_filter) + assert_equal [:reset_callback_record, :foo], self.class._setup_callbacks.map(&:filter) assert_equal [:foo], @called_back - assert_equal [:foo, :sentinel], self.class._teardown_callbacks.map(&:raw_filter) + assert_equal [:foo, :sentinel], self.class._teardown_callbacks.map(&:filter) end def setup @@ -355,9 +355,9 @@ class SubclassSetupAndTeardownTest < SetupAndTeardownTest teardown :bar def test_inherited_setup_callbacks - assert_equal [:reset_callback_record, :foo, :bar], self.class._setup_callbacks.map(&:raw_filter) + assert_equal [:reset_callback_record, :foo, :bar], self.class._setup_callbacks.map(&:filter) assert_equal [:foo, :bar], @called_back - assert_equal [:foo, :sentinel, :bar], self.class._teardown_callbacks.map(&:raw_filter) + assert_equal [:foo, :sentinel, :bar], self.class._teardown_callbacks.map(&:filter) end private