Skip to content
Snippets Groups Projects
Commit 8efa041a authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Do not process build success if project was removed

parent 03a8ed97
No related branches found
No related tags found
No related merge requests found
Loading
@@ -4,13 +4,15 @@ class BuildSuccessWorker
Loading
@@ -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(
Loading
Loading
Loading
@@ -13,6 +13,17 @@ describe BuildSuccessWorker do
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment