From 1d6ac2246255d33eb9e4f1b1237c3b5d59ad2bde Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 8 May 2013 15:51:45 -0700 Subject: add test for object conditional with scope --- activesupport/test/callbacks_test.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb index 0a29dd21c8..9659f141cb 100644 --- a/activesupport/test/callbacks_test.rb +++ b/activesupport/test/callbacks_test.rb @@ -813,6 +813,25 @@ module CallbacksTest } end + # FIXME: do we really want to support classes as conditionals? There were + # no tests for it previous to this. + def test_class_conditional_with_scope + z = [] + callback = Class.new { + define_singleton_method(:foo) { |o| z << o } + } + klass = Class.new { + include ActiveSupport::Callbacks + define_callbacks :foo, :scope => [:name] + set_callback :foo, :before, :foo, :if => callback + def foo; end + def run; run_callbacks :foo; end + } + object = klass.new + object.run + assert_equal [object], z + end + # FIXME: do we really want to support classes as conditionals? There were # no tests for it previous to this. def test_class -- cgit v1.2.3