Commit c00d72b6 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Rename pipeline methods related to legacy stages

parent 5c2ce44b
......@@ -99,7 +99,7 @@ class Projects::PipelinesController < Projects::ApplicationController
end
def stage
@stage = pipeline.stage(params[:stage])
@stage = pipeline.legacy_stage(params[:stage])
return not_found unless @stage
respond_to do |format|
......
......@@ -151,21 +151,21 @@ module Ci
where.not(duration: nil).sum(:duration)
end
def stage(name)
stage = Ci::Stage.new(self, name: name)
stage unless stage.statuses_count.zero?
end
def stages_count
statuses.select(:stage).distinct.count
end
def stages_name
def stages_names
statuses.order(:stage_idx).distinct.
pluck(:stage, :stage_idx).map(&:first)
end
def stages
def legacy_stage(name)
stage = Ci::Stage.new(self, name: name)
stage unless stage.statuses_count.zero?
end
def legacy_stages
# TODO, this needs refactoring, see gitlab-ce#26481.
stages_query = statuses
......@@ -300,13 +300,13 @@ module Ci
seeds_scope = { ref: ref, tag: tag?, trigger: trigger_requests.first }
config_processor.stage_seeds(seeds_scope).tap do |seeds|
@seeds ||= config_processor.stage_seeds(seeds_scope).tap do |seeds|
seeds.pipeline = self
end
end
def has_stages?
stage_seeds.has_stages?
stage_seeds&.has_stages?
end
def has_warnings?
......
......@@ -118,7 +118,7 @@
%span.stage-selection More
= icon('chevron-down')
%ul.dropdown-menu
- @build.pipeline.stages.each do |stage|
- @build.pipeline.legacy_stages.each do |stage|
%li
%a.stage-item= stage.name
......
......@@ -72,8 +72,8 @@
Pipeline
= link_to "##{last_pipeline.id}", namespace_project_pipeline_path(@project.namespace, @project, last_pipeline.id)
= ci_label_for_status(last_pipeline.status)
- if last_pipeline.stages.any?
with #{"stage".pluralize(last_pipeline.stages.count)}
- if last_pipeline.stages_count.nonzero?
with #{"stage".pluralize(last_pipeline.stages_count)}
.mr-widget-pipeline-graph
= render 'shared/mini_pipeline_graph', pipeline: last_pipeline, klass: 'js-commit-pipeline-graph'
in
......
......@@ -46,7 +46,7 @@
%th
%th Coverage
%th
= render partial: "projects/stage/stage", collection: pipeline.stages, as: :stage
= render partial: "projects/stage/stage", collection: pipeline.legacy_stages, as: :stage
- if failed_builds.present?
#js-tab-failures.build-failures.tab-pane
- failed_builds.each_with_index do |build, index|
......
.stage-cell
- pipeline.stages.each do |stage|
- pipeline.legacy_stages.each do |stage|
- if stage.status
- detailed_status = stage.detailed_status(current_user)
- icon_status = "#{detailed_status.icon}_borderless"
......
......@@ -22,7 +22,7 @@ module Gitlab
sha: pipeline.sha,
before_sha: pipeline.before_sha,
status: pipeline.status,
stages: pipeline.stages_name,
stages: pipeline.stages_names,
created_at: pipeline.created_at,
finished_at: pipeline.finished_at,
duration: pipeline.duration
......
......@@ -213,8 +213,8 @@ describe Ci::Pipeline, models: true do
end
end
describe '#stages' do
subject { pipeline.stages }
describe '#legacy_stages' do
subject { pipeline.legacy_stages }
context 'stages list' do
it 'returns ordered list of stages' do
......@@ -263,7 +263,7 @@ describe Ci::Pipeline, models: true do
end
it 'populates stage with correct number of warnings' do
deploy_stage = pipeline.stages.third
deploy_stage = pipeline.legacy_stages.third
expect(deploy_stage).not_to receive(:statuses)
expect(deploy_stage).to have_warnings
......@@ -277,15 +277,15 @@ describe Ci::Pipeline, models: true do
end
end
describe '#stages_name' do
describe '#stages_names' do
it 'returns a valid names of stages' do
expect(pipeline.stages_name).to eq(%w(build test deploy))
expect(pipeline.stages_names).to eq(%w(build test deploy))
end
end
end
describe '#stage' do
subject { pipeline.stage('test') }
describe '#legacy_stage' do
subject { pipeline.legacy_stage('test') }
context 'with status in stage' do
before 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