blob: 10e290005cc50271786a91cc5a330ba3a412f151 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Integrations::ExecuteWorker, '#perform', feature_category: :integrations do
let_it_be(:integration) { create(:jira_integration) }
let(:worker) { described_class.new }
it 'executes integration with given data' do
data = { test: 'test' }
expect_next_found_instance_of(integration.class) do |integration|
expect(integration).to receive(:execute).with(data)
end
worker.perform(integration.id, data)
end
it 'logs error messages' do
error = StandardError.new('invalid URL')
expect_next_found_instance_of(integration.class) do |integration|
expect(integration).to receive(:execute).and_raise(error)
expect(integration).to receive(:log_exception).with(error)
end
worker.perform(integration.id, {})
end
context 'when integration cannot be found' do
it 'completes silently and does not log an error' do
expect(Gitlab::IntegrationsLogger).not_to receive(:error)
expect do
worker.perform(non_existing_record_id, {})
end.not_to raise_error
end
end
context 'when the Gitlab::SilentMode is enabled' do
before do
allow(Gitlab::SilentMode).to receive(:enabled?).and_return(true)
end
it 'completes silently and does not log an error' do
expect(Gitlab::IntegrationsLogger).not_to receive(:error)
expect do
worker.perform(non_existing_record_id, {})
end.not_to raise_error
end
end
end
|