1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

fix issue #10502, do not recompute method name for already-stringified object filter

This commit is contained in:
Sean Walbran 2013-05-07 13:22:52 -05:00
parent 3043d45eef
commit 9003a422f2
2 changed files with 23 additions and 1 deletions

View file

@ -133,7 +133,7 @@ module ActiveSupport
end
def matches?(_kind, _filter)
if @_is_object_filter
if @_is_object_filter && !_filter.is_a?(String)
_filter_matches = @filter.to_s.start_with?(_method_name_for_object_filter(_kind, _filter, false))
else
_filter_matches = (@filter == _filter)

View file

@ -102,6 +102,9 @@ module CallbacksTest
def no; false; end
end
class PersonForProgrammaticSkipping < Person
end
class ParentController
include ActiveSupport::Callbacks
@ -449,6 +452,25 @@ module CallbacksTest
[:after_save, :symbol]
], person.history
end
def test_skip_person_programmatically
PersonForProgrammaticSkipping._save_callbacks.each do |save_callback|
if "before" == save_callback.kind.to_s
PersonForProgrammaticSkipping.skip_callback("save", save_callback.kind, save_callback.filter)
end
end
person = PersonForProgrammaticSkipping.new
assert_equal [], person.history
person.save
assert_equal [
[:after_save, :block],
[:after_save, :class],
[:after_save, :object],
[:after_save, :proc],
[:after_save, :string],
[:after_save, :symbol]
], person.history
end
end
class CallbacksTest < ActiveSupport::TestCase