From 9003a422f2a717ef11409245bfb8e81018be56c4 Mon Sep 17 00:00:00 2001
From: Sean Walbran <swalbran@socialcast.com>
Date: Tue, 7 May 2013 13:22:52 -0500
Subject: fix issue #10502, do not recompute method name for
 already-stringified object filter

---
 activesupport/lib/active_support/callbacks.rb |  2 +-
 activesupport/test/callbacks_test.rb          | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

(limited to 'activesupport')

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
-- 
cgit v1.2.3