Commit 3a7245a4 authored by Kamil Trzciński's avatar Kamil Trzciński

Fix current spec failures

parent d7f8a0ce
......@@ -10,8 +10,6 @@ module Ci
prepend EE::Ci::Build
MissingDependenciesError = Class.new(StandardError)
belongs_to :project, inverse_of: :builds
belongs_to :runner
belongs_to :trigger_request
......@@ -585,15 +583,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?
......
......@@ -72,7 +72,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
......
......@@ -2411,18 +2411,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
......@@ -2432,7 +2432,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
......@@ -2440,12 +2440,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
......@@ -2455,7 +2455,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
......
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