debian-mirror-gitlab/spec/workers/project_service_worker_spec.rb

28 lines
730 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe ProjectServiceWorker, '#perform' do
2018-12-05 23:21:45 +05:30
let(:worker) { described_class.new }
2021-09-30 23:02:18 +05:30
let(:integration) { Integrations::Jira.new }
2018-12-05 23:21:45 +05:30
before do
2021-09-30 23:02:18 +05:30
allow(Integration).to receive(:find).and_return(integration)
2018-12-05 23:21:45 +05:30
end
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' }
2021-09-30 23:02:18 +05:30
expect(integration).to receive(:execute).with(data)
2018-12-05 23:21:45 +05:30
worker.perform(1, data)
end
it 'logs error messages' do
2021-09-30 23:02:18 +05:30
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')
2018-12-05 23:21:45 +05:30
worker.perform(1, {})
end
end