class CallbacksOnMultipleActionsTest

Public Instance Methods

test_after_commit_on_multiple_actions() click to toggle source
# File activerecord/test/cases/transaction_callbacks_test.rb, line 421
def test_after_commit_on_multiple_actions
  topic = TopicWithCallbacksOnMultipleActions.new
  topic.save
  assert_equal [:create_and_update, :create_and_destroy], topic.history

  topic.clear_history
  topic.approved = true
  topic.save
  assert_equal [:update_and_destroy, :create_and_update], topic.history

  topic.clear_history
  topic.destroy
  assert_equal [:update_and_destroy, :create_and_destroy], topic.history
end
test_before_commit_actions() click to toggle source
# File activerecord/test/cases/transaction_callbacks_test.rb, line 436
def test_before_commit_actions
  topic = TopicWithCallbacksOnMultipleActions.new
  topic.save_before_commit_history = true
  topic.save

  assert_equal [:before_commit, :create_and_update, :create_and_destroy], topic.history
end
test_before_commit_update_in_same_transaction() click to toggle source
# File activerecord/test/cases/transaction_callbacks_test.rb, line 444
def test_before_commit_update_in_same_transaction
  topic = TopicWithCallbacksOnMultipleActions.new
  topic.update_title = true
  topic.save

  assert_equal "before commit title", topic.title
  assert_equal "before commit title", topic.reload.title
end