summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-01 11:55:18 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-01 11:55:18 +0200
commitc00d72b6f33d50b1c5cd6948d54b3addf11f9104 (patch)
tree6ce71c98e7fa46f2fb85078409936bccea1f31df
parent5c2ce44baf5205c038759c4779a74e3381183e8a (diff)
downloadgitlab-ce-c00d72b6f33d50b1c5cd6948d54b3addf11f9104.tar.gz
Rename pipeline methods related to legacy stages
-rw-r--r--app/controllers/projects/pipelines_controller.rb2
-rw-r--r--app/models/ci/pipeline.rb18
-rw-r--r--app/views/projects/builds/_sidebar.html.haml2
-rw-r--r--app/views/projects/commit/_commit_box.html.haml4
-rw-r--r--app/views/projects/pipelines/_with_tabs.html.haml2
-rw-r--r--app/views/shared/_mini_pipeline_graph.html.haml2
-rw-r--r--lib/gitlab/data_builder/pipeline.rb2
-rw-r--r--spec/models/ci/pipeline_spec.rb14
8 files changed, 23 insertions, 23 deletions
diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb
index 602d3dd8c1c..d351e773cd7 100644
--- a/app/controllers/projects/pipelines_controller.rb
+++ b/app/controllers/projects/pipelines_controller.rb
@@ -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|
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 155fefcc9c3..8e687fd5c08 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -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?
diff --git a/app/views/projects/builds/_sidebar.html.haml b/app/views/projects/builds/_sidebar.html.haml
index 8032d81cd91..a71b6493ce7 100644
--- a/app/views/projects/builds/_sidebar.html.haml
+++ b/app/views/projects/builds/_sidebar.html.haml
@@ -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
diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml
index 0aef5822f81..aab50310234 100644
--- a/app/views/projects/commit/_commit_box.html.haml
+++ b/app/views/projects/commit/_commit_box.html.haml
@@ -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
diff --git a/app/views/projects/pipelines/_with_tabs.html.haml b/app/views/projects/pipelines/_with_tabs.html.haml
index 075ddc0025c..a1604ca039e 100644
--- a/app/views/projects/pipelines/_with_tabs.html.haml
+++ b/app/views/projects/pipelines/_with_tabs.html.haml
@@ -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|
diff --git a/app/views/shared/_mini_pipeline_graph.html.haml b/app/views/shared/_mini_pipeline_graph.html.haml
index 07970ad9cba..aa93572bf94 100644
--- a/app/views/shared/_mini_pipeline_graph.html.haml
+++ b/app/views/shared/_mini_pipeline_graph.html.haml
@@ -1,5 +1,5 @@
.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"
diff --git a/lib/gitlab/data_builder/pipeline.rb b/lib/gitlab/data_builder/pipeline.rb
index 182a30fd74d..e47fb85b5ee 100644
--- a/lib/gitlab/data_builder/pipeline.rb
+++ b/lib/gitlab/data_builder/pipeline.rb
@@ -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
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 3a1fe666ff0..46dfa90218d 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -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