debian-mirror-gitlab/spec/workers/deployments/success_worker_spec.rb

39 lines
935 B
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2018-12-13 13:39:08 +05:30
require 'spec_helper'
describe Deployments::SuccessWorker do
subject { described_class.new.perform(deployment&.id) }
context 'when successful deployment' do
let(:deployment) { create(:deployment, :success) }
2019-12-21 20:55:43 +05:30
it 'executes Deployments::AfterCreateService' do
expect(Deployments::AfterCreateService)
2018-12-13 13:39:08 +05:30
.to receive(:new).with(deployment).and_call_original
subject
end
end
context 'when canceled deployment' do
let(:deployment) { create(:deployment, :canceled) }
2019-12-21 20:55:43 +05:30
it 'does not execute Deployments::AfterCreateService' do
expect(Deployments::AfterCreateService).not_to receive(:new)
2018-12-13 13:39:08 +05:30
subject
end
end
context 'when deploy record does not exist' do
let(:deployment) { nil }
2019-12-21 20:55:43 +05:30
it 'does not execute Deployments::AfterCreateService' do
expect(Deployments::AfterCreateService).not_to receive(:new)
2018-12-13 13:39:08 +05:30
subject
end
end
end