2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Deployments::FinishedWorker do
|
2019-07-31 22:56:46 +05:30
|
|
|
let(:worker) { described_class.new }
|
|
|
|
|
|
|
|
describe '#perform' do
|
|
|
|
before do
|
|
|
|
allow(ProjectServiceWorker).to receive(:perform_async)
|
|
|
|
end
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
it 'links merge requests to the deployment' do
|
|
|
|
deployment = create(:deployment)
|
|
|
|
service = instance_double(Deployments::LinkMergeRequestsService)
|
|
|
|
|
|
|
|
expect(Deployments::LinkMergeRequestsService)
|
|
|
|
.to receive(:new)
|
|
|
|
.with(deployment)
|
|
|
|
.and_return(service)
|
|
|
|
|
|
|
|
expect(service).to receive(:execute)
|
|
|
|
|
|
|
|
worker.perform(deployment.id)
|
|
|
|
end
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
it 'executes project services for deployment_hooks' do
|
|
|
|
deployment = create(:deployment)
|
|
|
|
project = deployment.project
|
|
|
|
service = create(:service, type: 'SlackService', project: project, deployment_events: true, active: true)
|
|
|
|
|
|
|
|
worker.perform(deployment.id)
|
|
|
|
|
|
|
|
expect(ProjectServiceWorker).to have_received(:perform_async).with(service.id, an_instance_of(Hash))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not execute an inactive service' do
|
|
|
|
deployment = create(:deployment)
|
|
|
|
project = deployment.project
|
|
|
|
create(:service, type: 'SlackService', project: project, deployment_events: true, active: false)
|
|
|
|
|
|
|
|
worker.perform(deployment.id)
|
|
|
|
|
|
|
|
expect(ProjectServiceWorker).not_to have_received(:perform_async)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does nothing if a deployment with the given id does not exist' do
|
|
|
|
worker.perform(0)
|
|
|
|
|
|
|
|
expect(ProjectServiceWorker).not_to have_received(:perform_async)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|