diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-08 15:51:45 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-08 15:51:45 -0700 |
commit | 1d6ac2246255d33eb9e4f1b1237c3b5d59ad2bde (patch) | |
tree | 3ecb92be7a24ad2c677108f045717b7c1339dc59 /activesupport | |
parent | fe7f4b4bba4addfe2bbcb32fa67a6d9930811386 (diff) | |
download | rails-1d6ac2246255d33eb9e4f1b1237c3b5d59ad2bde.tar.gz rails-1d6ac2246255d33eb9e4f1b1237c3b5d59ad2bde.tar.bz2 rails-1d6ac2246255d33eb9e4f1b1237c3b5d59ad2bde.zip |
add test for object conditional with scope
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/test/callbacks_test.rb | 19 |
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 { |