diff options
author | Genadi Samokovarov <gsamokovarov@gmail.com> | 2015-12-06 19:15:33 +0200 |
---|---|---|
committer | Genadi Samokovarov <gsamokovarov@gmail.com> | 2015-12-06 20:33:36 +0200 |
commit | 5a300b2ed6b603474a7ee44d081da9e69465ec10 (patch) | |
tree | 1b9374dba7a2f9bdfcb8987fcc3f7d7fa2e53830 /activerecord/test/cases | |
parent | 65443ceb0d55e1445b28e31e772629424e6755c3 (diff) | |
download | rails-5a300b2ed6b603474a7ee44d081da9e69465ec10.tar.gz rails-5a300b2ed6b603474a7ee44d081da9e69465ec10.tar.bz2 rails-5a300b2ed6b603474a7ee44d081da9e69465ec10.zip |
Introduce after_{create,update,delete}_commit callbacks
Those are actually shortcuts for `after_commit`.
Before:
after_commit :add_to_index_later, on: :create
after_commit :update_in_index_later, on: :update
after_commit :remove_from_index_later, on: :destroy
After:
after_create_commit :add_to_index_later
after_update_commit :update_in_index_later
after_destroy_commit :remove_from_index_later
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/transaction_callbacks_test.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/test/cases/transaction_callbacks_test.rb b/activerecord/test/cases/transaction_callbacks_test.rb index f2229939c8..637f89196e 100644 --- a/activerecord/test/cases/transaction_callbacks_test.rb +++ b/activerecord/test/cases/transaction_callbacks_test.rb @@ -35,9 +35,9 @@ class TransactionCallbacksTest < ActiveRecord::TestCase has_many :replies, class_name: "ReplyWithCallbacks", foreign_key: "parent_id" after_commit { |record| record.do_after_commit(nil) } - after_commit(on: :create) { |record| record.do_after_commit(:create) } - after_commit(on: :update) { |record| record.do_after_commit(:update) } - after_commit(on: :destroy) { |record| record.do_after_commit(:destroy) } + after_create_commit { |record| record.do_after_commit(:create) } + after_update_commit { |record| record.do_after_commit(:update) } + after_destroy_commit { |record| record.do_after_commit(:destroy) } after_rollback { |record| record.do_after_rollback(nil) } after_rollback(on: :create) { |record| record.do_after_rollback(:create) } after_rollback(on: :update) { |record| record.do_after_rollback(:update) } |