Skip to content
Browse files

fisting after_rollback and after commit callbacks

  • Loading branch information...
1 parent ac66de4 commit 809a04ba8fb1087a8a6f2598431701512ac65d3f @tenderlove tenderlove committed Aug 20, 2010
View
2 activerecord/lib/active_record/callbacks.rb
@@ -235,7 +235,7 @@ module Callbacks
:after_initialize, :after_find, :after_touch, :before_validation, :after_validation,
:before_save, :around_save, :after_save, :before_create, :around_create,
:after_create, :before_update, :around_update, :after_update,
- :before_destroy, :around_destroy, :after_destroy
+ :before_destroy, :around_destroy, :after_destroy, :after_commit, :after_rollback
]
included do
View
7 activerecord/test/cases/callbacks_test.rb
@@ -461,7 +461,12 @@ def test_callback_returning_false
[ :before_validation, :proc ],
[ :before_validation, :object ],
[ :before_validation, :block ],
- [ :before_validation, :returning_false ]
+ [ :before_validation, :returning_false ],
+ [ :after_rollback, :block ],
+ [ :after_rollback, :object ],
+ [ :after_rollback, :proc ],
+ [ :after_rollback, :string ],
+ [ :after_rollback, :method ],
], david.history
end
View
12 activerecord/test/cases/transaction_callbacks_test.rb
@@ -260,29 +260,33 @@ def history
class TopicWithObserverAttachedObserver < ActiveRecord::Observer
def after_commit(record)
- record.history.push :"TopicWithObserverAttachedObserver#after_commit"
+ record.history.push "after_commit"
end
def after_rollback(record)
- record.history.push :"TopicWithObserverAttachedObserver#after_rollback"
+ record.history.push "after_rollback"
end
end
def test_after_commit_called
+ assert TopicWithObserverAttachedObserver.instance, 'should have observer'
+
topic = TopicWithObserverAttached.new
topic.save!
- assert_equal topic.history, [:"TopicWithObserverAttachedObserver#after_commit"]
+ assert_equal %w{ after_commit }, topic.history
end
def test_after_rollback_called
+ assert TopicWithObserverAttachedObserver.instance, 'should have observer'
+
topic = TopicWithObserverAttached.new
Topic.transaction do
topic.save!
raise ActiveRecord::Rollback
end
- assert_equal topic.history, [:"TopicWithObserverObserver#after_rollback"]
+ assert_equal %w{ after_rollback }, topic.history
end
end

0 comments on commit 809a04b

Please sign in to comment.
Something went wrong with that request. Please try again.