aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-09-25 18:31:43 -0400
committerJosé Valim <jose.valim@gmail.com>2010-09-27 23:12:10 +0200
commitbfc986811c5cbcfcc856916a1b09fcbf6551ecf5 (patch)
treef784fc84b516a54fd190995f1ab9fb5efd57e580 /activesupport/test
parent72c1e19c33ca06008d5d64619a533bdf34e3fc2b (diff)
downloadrails-bfc986811c5cbcfcc856916a1b09fcbf6551ecf5.tar.gz
rails-bfc986811c5cbcfcc856916a1b09fcbf6551ecf5.tar.bz2
rails-bfc986811c5cbcfcc856916a1b09fcbf6551ecf5.zip
Test for after_create callback order in ActiveSupport [#5703 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/callbacks_test.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb
index 292383e3d8..51b28b6a43 100644
--- a/activesupport/test/callbacks_test.rb
+++ b/activesupport/test/callbacks_test.rb
@@ -149,6 +149,27 @@ module CallbacksTest
end
end
+ class AfterSaveConditionalPerson < Record
+ after_save Proc.new { |r| r.history << [:after_save, :string1] }
+ after_save Proc.new { |r| r.history << [:after_save, :string2] }
+ def save
+ run_callbacks :save
+ end
+ end
+
+ class AfterSaveConditionalPersonCallbackTest < Test::Unit::TestCase
+ def test_after_save_runs_in_the_reverse_order
+ person = AfterSaveConditionalPerson.new
+ person.save
+ assert_equal [
+ [:after_save, :string2],
+ [:after_save, :string1]
+ ], person.history
+ end
+ end
+
+
+
class ConditionalPerson < Record
# proc
before_save Proc.new { |r| r.history << [:before_save, :proc] }, :if => Proc.new { |r| true }
@@ -352,6 +373,8 @@ module CallbacksTest
end
end
+
+
class ResetCallbackTest < Test::Unit::TestCase
def test_save_conditional_person
person = CleanPerson.new