aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/callbacks_test.rb
diff options
context:
space:
mode:
authorSubba Rao Pasupuleti <subbarao.pasupuleti@gmail.com>2010-08-03 17:04:41 -0400
committerJosé Valim <jose.valim@gmail.com>2010-08-12 13:12:26 -0300
commitef0da581e94be1c938202cfa7ed39fb29614e570 (patch)
tree6e9686d405a549d7b1bf1152b91e8d28fa0bbdfe /activemodel/test/cases/callbacks_test.rb
parente82b38cd578aa316a03dae55df8076c4b2111bb6 (diff)
downloadrails-ef0da581e94be1c938202cfa7ed39fb29614e570.tar.gz
rails-ef0da581e94be1c938202cfa7ed39fb29614e570.tar.bz2
rails-ef0da581e94be1c938202cfa7ed39fb29614e570.zip
no callbacks should be created for empty array [#5289 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activemodel/test/cases/callbacks_test.rb')
-rw-r--r--activemodel/test/cases/callbacks_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activemodel/test/cases/callbacks_test.rb b/activemodel/test/cases/callbacks_test.rb
index 9675b5d450..64dc7b5026 100644
--- a/activemodel/test/cases/callbacks_test.rb
+++ b/activemodel/test/cases/callbacks_test.rb
@@ -16,6 +16,8 @@ class CallbacksTest < ActiveModel::TestCase
define_model_callbacks :create
define_model_callbacks :initialize, :only => :after
+ define_model_callbacks :multiple, :only => [:before, :around]
+ define_model_callbacks :empty, :only => []
before_create :before_create
around_create CallbackValidator.new
@@ -67,4 +69,16 @@ class CallbacksTest < ActiveModel::TestCase
assert !ModelCallbacks.respond_to?(:around_initialize)
assert_respond_to ModelCallbacks, :after_initialize
end
+
+ test "only selects which types of callbacks should be created from an array list" do
+ assert_respond_to ModelCallbacks, :before_multiple
+ assert_respond_to ModelCallbacks, :around_multiple
+ assert !ModelCallbacks.respond_to?(:after_multiple)
+ end
+
+ test "no callbacks should be created" do
+ assert !ModelCallbacks.respond_to?(:before_empty)
+ assert !ModelCallbacks.respond_to?(:around_empty)
+ assert !ModelCallbacks.respond_to?(:after_empty)
+ end
end