aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/callbacks_test.rb
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-09-25 18:30:56 -0400
committerJosé Valim <jose.valim@gmail.com>2010-09-27 23:11:31 +0200
commit72c1e19c33ca06008d5d64619a533bdf34e3fc2b (patch)
treedba67d430b40d7e65e6baca4bc97381c3c279897 /activemodel/test/cases/callbacks_test.rb
parent72f37bd8bc5b3beb1e8a2d1ac2de2c045cd0cfd2 (diff)
downloadrails-72c1e19c33ca06008d5d64619a533bdf34e3fc2b.tar.gz
rails-72c1e19c33ca06008d5d64619a533bdf34e3fc2b.tar.bz2
rails-72c1e19c33ca06008d5d64619a533bdf34e3fc2b.zip
after_create in ActiveModel should in the order specified
[#5650 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.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/activemodel/test/cases/callbacks_test.rb b/activemodel/test/cases/callbacks_test.rb
index 64dc7b5026..069d907fb2 100644
--- a/activemodel/test/cases/callbacks_test.rb
+++ b/activemodel/test/cases/callbacks_test.rb
@@ -81,4 +81,34 @@ class CallbacksTest < ActiveModel::TestCase
assert !ModelCallbacks.respond_to?(:around_empty)
assert !ModelCallbacks.respond_to?(:after_empty)
end
+
+ class Violin
+ attr_reader :history
+ def initialize
+ @history = []
+ end
+ extend ActiveModel::Callbacks
+ define_model_callbacks :create
+ def callback1; self.history << 'callback1'; end
+ def callback2; self.history << 'callback2'; end
+ def create
+ _run_create_callbacks {}
+ self
+ end
+ end
+ class Violin1 < Violin
+ after_create :callback1, :callback2
+ end
+ class Violin2 < Violin
+ after_create :callback1
+ after_create :callback2
+ end
+
+ test "after_create callbacks with both callbacks declared in one line" do
+ assert_equal ["callback1", "callback2"], Violin1.new.create.history
+ end
+ test "after_create callbacks with both callbacks declared in differnt lines" do
+ assert_equal ["callback1", "callback2"], Violin2.new.create.history
+ end
+
end