aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Walbran <swalbran@socialcast.com>2013-05-07 13:22:52 -0500
committerSean Walbran <swalbran@socialcast.com>2013-05-07 13:22:52 -0500
commit9003a422f2a717ef11409245bfb8e81018be56c4 (patch)
tree0406cdecdd979676fdb38d52fed2f375e619f9f0
parent3043d45eefc3776d5f3a9e7d212a01f99d869ef8 (diff)
downloadrails-9003a422f2a717ef11409245bfb8e81018be56c4.tar.gz
rails-9003a422f2a717ef11409245bfb8e81018be56c4.tar.bz2
rails-9003a422f2a717ef11409245bfb8e81018be56c4.zip
fix issue #10502, do not recompute method name for already-stringified object filter
-rw-r--r--activesupport/lib/active_support/callbacks.rb2
-rw-r--r--activesupport/test/callbacks_test.rb22
2 files changed, 23 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 893c2500d7..1dcacf0b12 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -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)
diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb
index edc8edd8a6..f71e780c42 100644
--- a/activesupport/test/callbacks_test.rb
+++ b/activesupport/test/callbacks_test.rb
@@ -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