提交 9003a422 编写于 作者: S Sean Walbran

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

上级 3043d45e
......@@ -133,7 +133,7 @@ def next_id
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)
......
......@@ -102,6 +102,9 @@ def yes; true; end
def no; false; end
end
class PersonForProgrammaticSkipping < Person
end
class ParentController
include ActiveSupport::Callbacks
......@@ -449,6 +452,25 @@ def test_skip_person
[: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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册