Commit 8efa041a authored by Grzegorz Bizon's avatar Grzegorz Bizon

Do not process build success if project was removed

parent 03a8ed97
...@@ -4,13 +4,15 @@ class BuildSuccessWorker ...@@ -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 ...@@ -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
......
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