Expose stage model attributes from pipeline object
This commit is contained in:
parent
96cd422879
commit
6113ff992c
3 changed files with 26 additions and 2 deletions
|
@ -292,6 +292,16 @@ module Ci
|
|||
sort_by { |build| build[:stage_idx] }
|
||||
end
|
||||
|
||||
def config_stages_attributes
|
||||
return [] unless config_processor
|
||||
|
||||
config_processor.stages_for_ref(ref, tag?, trigger_requests.first)
|
||||
end
|
||||
|
||||
def has_stages?
|
||||
config_stages_attributes.any?
|
||||
end
|
||||
|
||||
def has_warnings?
|
||||
builds.latest.failed_but_allowed.any?
|
||||
end
|
||||
|
|
|
@ -42,8 +42,8 @@ module Ci
|
|||
return pipeline
|
||||
end
|
||||
|
||||
unless pipeline.config_builds_attributes.present?
|
||||
return error('No builds for this pipeline.')
|
||||
unless pipeline.has_stages?
|
||||
return error('No stages / jobs for this pipeline.')
|
||||
end
|
||||
|
||||
Ci::Pipeline.transaction do
|
||||
|
|
|
@ -502,6 +502,20 @@ describe Ci::Pipeline, models: true do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#has_stages?' do
|
||||
context 'when pipeline has stages' do
|
||||
subject { create(:ci_pipeline_with_one_job) }
|
||||
|
||||
it { is_expected.to have_stages }
|
||||
end
|
||||
|
||||
context 'when pipeline does not have stages' do
|
||||
subject { create(:ci_pipeline_without_jobs) }
|
||||
|
||||
it { is_expected.not_to have_stages }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#has_warnings?' do
|
||||
subject { pipeline.has_warnings? }
|
||||
|
||||
|
|
Loading…
Reference in a new issue