Do not process build success if project was removed
This commit is contained in:
parent
03a8ed9711
commit
8efa041a73
2 changed files with 15 additions and 2 deletions
|
@ -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(
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue