debian-mirror-gitlab/spec/workers/integrations/execute_worker_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.1 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
require 'spec_helper'
2022-07-23 23:45:48 +05:30
RSpec.describe Integrations::ExecuteWorker, '#perform' do
2022-07-16 23:28:13 +05:30
let_it_be(:integration) { create(:jira_integration) }
2018-12-05 23:21:45 +05:30
2022-07-16 23:28:13 +05:30
let(:worker) { described_class.new }
2018-12-05 23:21:45 +05:30
2021-09-30 23:02:18 +05:30
it 'executes integration with given data' do
2018-12-05 23:21:45 +05:30
data = { test: 'test' }
2022-07-16 23:28:13 +05:30
expect_next_found_instance_of(integration.class) do |integration|
expect(integration).to receive(:execute).with(data)
end
worker.perform(integration.id, data)
2018-12-05 23:21:45 +05:30
end
it 'logs error messages' do
2021-09-30 23:02:18 +05:30
error = StandardError.new('invalid URL')
2022-07-16 23:28:13 +05:30
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)
2018-12-05 23:21:45 +05:30
2022-07-16 23:28:13 +05:30
expect do
worker.perform(non_existing_record_id, {})
end.not_to raise_error
end
2018-12-05 23:21:45 +05:30
end
end