Skip to content
Snippets Groups Projects
Commit 8ce03988 authored by Kamil Trzcińśki's avatar Kamil Trzcińśki
Browse files

Fix current spec failures

parent c0abcc68
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Loading
Loading
@@ -8,8 +8,6 @@ module Ci
include Importable
include Gitlab::Utils::StrongMemoize
 
MissingDependenciesError = Class.new(StandardError)
belongs_to :project, inverse_of: :builds
belongs_to :runner
belongs_to :trigger_request
Loading
Loading
@@ -581,15 +579,13 @@ module Ci
options[:dependencies]&.empty?
end
 
def valid_build_dependencies?
return unless Feature.enabled?('ci_disable_validates_dependencies')
def has_valid_build_dependencies?
return true unless Feature.enabled?('ci_disable_validates_dependencies')
 
dependencies.each do |dependency|
raise MissingDependenciesError unless dependency.valid_dependency?
end
dependencies.all?(&:is_valid_dependency?)
end
 
def valid_dependency?
def is_valid_dependency?
return false if artifacts_expired?
return false if erased?
 
Loading
Loading
Loading
Loading
@@ -70,7 +70,7 @@ module Ci
build.runner_id = runner.id
build.runner_session_attributes = params[:session] if params[:session].present?
 
unless build.valid_build_dependencies?
unless build.has_valid_build_dependencies?
build.drop!(:missing_dependency_failure)
return false
end
Loading
Loading
Loading
Loading
@@ -2409,18 +2409,18 @@ describe Ci::Build do
end
end
 
describe 'state transition: any => [:running]' do
describe '#has_valid_build_dependencies?' do
shared_examples 'validation is active' do
context 'when depended job has not been completed yet' do
let!(:pre_stage_job) { create(:ci_build, :manual, pipeline: pipeline, name: 'test', stage_idx: 0) }
 
it { expect { job.run! }.not_to raise_error }
it { expect { job.run! }.to have_valid_build_dependencies }
end
 
context 'when artifacts of depended job has been expired' do
let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test', stage_idx: 0) }
 
it { expect { job.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
it { expect { job.run! }.not_to have_valid_build_dependencies }
end
 
context 'when artifacts of depended job has been erased' do
Loading
Loading
@@ -2430,7 +2430,7 @@ describe Ci::Build do
pre_stage_job.erase
end
 
it { expect { job.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
it { expect { job.run! }.not_to have_valid_build_dependencies }
end
end
 
Loading
Loading
@@ -2438,12 +2438,12 @@ describe Ci::Build do
context 'when depended job has not been completed yet' do
let!(:pre_stage_job) { create(:ci_build, :manual, pipeline: pipeline, name: 'test', stage_idx: 0) }
 
it { expect { job.run! }.not_to raise_error }
it { expect { job.run! }.to have_valid_build_dependencies }
end
context 'when artifacts of depended job has been expired' do
let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test', stage_idx: 0) }
 
it { expect { job.run! }.not_to raise_error }
it { expect { job.run! }.to have_valid_build_dependencies }
end
 
context 'when artifacts of depended job has been erased' do
Loading
Loading
@@ -2453,7 +2453,7 @@ describe Ci::Build do
pre_stage_job.erase
end
 
it { expect { job.run! }.not_to raise_error }
it { expect { job.run! }.to have_valid_build_dependencies }
end
end
 
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