Fix weird test failure.

This commit is contained in:
Guo Xiang Tan 2017-03-20 12:06:37 +08:00
parent a567e6bec9
commit 6057e17ae7
2 changed files with 5 additions and 2 deletions

View File

@ -13,7 +13,10 @@ class Notification < ActiveRecord::Base
.where('topics.id IS NULL OR topics.deleted_at IS NULL') }
after_commit :send_email
after_commit :refresh_notification_count
# This is super weird because the tests fail if we don't specify `on: :destroy`
# TODO: Revert back to default in Rails 5
after_commit :refresh_notification_count, on: :destroy
after_commit :refresh_notification_count, on: [:create, :update]
def self.ensure_consistency!
Notification.exec_sql("

View File

@ -133,7 +133,7 @@ describe Notification do
it 'updates the notification count on destroy' do
Notification.any_instance.expects(:refresh_notification_count).returns(nil)
notification.destroy
notification.destroy!
end
end