diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/workers/project_service_worker_spec.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/workers/project_service_worker_spec.rb')
-rw-r--r-- | spec/workers/project_service_worker_spec.rb | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/spec/workers/project_service_worker_spec.rb b/spec/workers/project_service_worker_spec.rb index 7813d011274..55ec07ff79c 100644 --- a/spec/workers/project_service_worker_spec.rb +++ b/spec/workers/project_service_worker_spec.rb @@ -2,26 +2,38 @@ require 'spec_helper' RSpec.describe ProjectServiceWorker, '#perform' do - let(:worker) { described_class.new } - let(:integration) { Integrations::Jira.new } + let_it_be(:integration) { create(:jira_integration) } - before do - allow(Integration).to receive(:find).and_return(integration) - end + let(:worker) { described_class.new } it 'executes integration with given data' do data = { test: 'test' } - expect(integration).to receive(:execute).with(data) - worker.perform(1, data) + 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') - allow(integration).to receive(:execute).and_raise(error) - expect(Gitlab::ErrorTracking).to receive(:log_exception).with(error, integration_class: 'Integrations::Jira') + 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) - worker.perform(1, {}) + expect do + worker.perform(non_existing_record_id, {}) + end.not_to raise_error + end end end |