Do not process build success if project was removed

This commit is contained in:
Grzegorz Bizon 2016-10-13 14:55:44 +02:00
parent 03a8ed9711
commit 8efa041a73
2 changed files with 15 additions and 2 deletions

View file

@ -4,13 +4,15 @@ class BuildSuccessWorker
def perform(build_id) def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build| Ci::Build.find_by(id: build_id).try do |build|
perform_deloyment(build) return unless build.project
create_deloyment(build)
end end
end end
private private
def perform_deloyment(build) def create_deloyment(build)
return if build.environment.blank? return if build.environment.blank?
service = CreateDeploymentService.new( service = CreateDeploymentService.new(

View file

@ -13,6 +13,17 @@ describe BuildSuccessWorker do
described_class.new.perform(build.id) described_class.new.perform(build.id)
end end
end end
context 'when build is not associated with project' do
let!(:build) { create(:ci_build, project: nil) }
it 'does not create deployment' do
expect_any_instance_of(CreateDeploymentService)
.not_to receive(:execute)
described_class.new.perform(build.id)
end
end
end end
context 'when build does not exist' do context 'when build does not exist' do