From ef0da581e94be1c938202cfa7ed39fb29614e570 Mon Sep 17 00:00:00 2001 From: Subba Rao Pasupuleti Date: Tue, 3 Aug 2010 17:04:41 -0400 Subject: no callbacks should be created for empty array [#5289 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activemodel/test/cases/callbacks_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'activemodel/test/cases') 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 -- cgit v1.2.3