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