mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 10:58:38 +08:00
25 lines
564 B
Ruby
25 lines
564 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
require 'rails_helper'
|
||
|
|
||
|
describe UserStatCountUpdater do
|
||
|
fab!(:user) { Fabricate(:user) }
|
||
|
fab!(:user_stat) { user.user_stat }
|
||
|
fab!(:post) { Fabricate(:post) }
|
||
|
|
||
|
before do
|
||
|
@orig_logger = Rails.logger
|
||
|
Rails.logger = @fake_logger = FakeLogger.new
|
||
|
end
|
||
|
|
||
|
after do
|
||
|
Rails.logger = @orig_logger
|
||
|
end
|
||
|
|
||
|
it 'should log the exception when a negative count is inserted' do
|
||
|
UserStatCountUpdater.decrement!(post, user_stat: user_stat)
|
||
|
|
||
|
expect(@fake_logger.warnings.first).to include("PG::CheckViolation")
|
||
|
end
|
||
|
end
|