2022-05-09 08:53:19 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe ChatwootExceptionTracker do
|
2022-06-02 06:08:58 +00:00
|
|
|
it 'use rails logger if no tracker is configured' do
|
|
|
|
expect(Rails.logger).to receive(:error).with('random')
|
|
|
|
described_class.new('random').capture_exception
|
2022-05-09 08:53:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with sentry DSN' do
|
|
|
|
before do
|
|
|
|
# since sentry is not initated in test, we need to do it manually
|
|
|
|
Sentry.init do |config|
|
|
|
|
config.dsn = 'test'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'will call sentry capture exception' do
|
|
|
|
with_modified_env SENTRY_DSN: 'random dsn' do
|
|
|
|
expect(Sentry).to receive(:capture_exception).with('random')
|
|
|
|
described_class.new('random').capture_exception
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|