aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-05-08 15:51:45 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-05-08 15:51:45 -0700
commit1d6ac2246255d33eb9e4f1b1237c3b5d59ad2bde (patch)
tree3ecb92be7a24ad2c677108f045717b7c1339dc59
parentfe7f4b4bba4addfe2bbcb32fa67a6d9930811386 (diff)
downloadrails-1d6ac2246255d33eb9e4f1b1237c3b5d59ad2bde.tar.gz
rails-1d6ac2246255d33eb9e4f1b1237c3b5d59ad2bde.tar.bz2
rails-1d6ac2246255d33eb9e4f1b1237c3b5d59ad2bde.zip
add test for object conditional with scope
-rw-r--r--activesupport/test/callbacks_test.rb19
1 files changed, 19 insertions, 0 deletions
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
@@ -815,6 +815,25 @@ module CallbacksTest
# 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
z = []
klass = build_class Class.new {