Commit dd73af2e authored by Matija Čupić's avatar Matija Čupić

Implement PipelineBridge worker

parent 38e49069
......@@ -44,6 +44,7 @@
- pipeline_default:store_security_reports
- pipeline_default:ci_create_cross_project_pipeline
- pipeline_default:ci_pipeline_bridge
- incident_management:incident_management_process_alert
......
# frozen_string_literal: true
module Ci
class PipelineBridgeWorker
include ::ApplicationWorker
include ::PipelineQueue
def perform(pipeline_id)
::Ci::Pipeline.find_by_id(pipeline_id).try do |pipeline|
::Ci::PipelineBridgeService
.new(pipeline.project, pipeline.user)
.execute(pipeline)
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Ci::PipelineBridgeWorker do
describe '#perform' do
subject { described_class.new.perform(pipeline_id) }
context 'when pipeline exists' do
let(:pipeline) { create(:ci_pipeline) }
let(:pipeline_id) { pipeline.id }
it 'calls the service' do
service = double('bridge status service')
expect(Ci::PipelineBridgeService)
.to receive(:new)
.with(pipeline.project, pipeline.user)
.and_return(service)
expect(service).to receive(:execute).with(pipeline)
subject
end
end
context 'when pipeline does not exist' do
let(:pipeline_id) { 1234 }
it 'does not call the service' do
expect(Ci::PipelineBridgeService)
.not_to receive(:new)
subject
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment