summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/ci/stage.rb4
-rw-r--r--app/views/projects/commit/_pipeline.html.haml5
-rw-r--r--app/views/projects/pipelines/_graph.html.haml4
-rw-r--r--app/views/projects/pipelines/_with_tabs.html.haml5
-rw-r--r--app/views/projects/stage/_graph.html.haml11
-rw-r--r--spec/lib/gitlab/ci/status/factory_spec.rb6
-rw-r--r--spec/lib/gitlab/ci/status/pipeline/factory_spec.rb4
7 files changed, 18 insertions, 21 deletions
diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb
index fe1c5c642e1..d2a37c0a827 100644
--- a/app/models/ci/stage.rb
+++ b/app/models/ci/stage.rb
@@ -9,7 +9,9 @@ module Ci
delegate :project, to: :pipeline
def initialize(pipeline, name:, status: nil)
- @pipeline, @name, @status = pipeline, name, status
+ @pipeline = pipeline
+ @name = name
+ @status = status
end
def to_param
diff --git a/app/views/projects/commit/_pipeline.html.haml b/app/views/projects/commit/_pipeline.html.haml
index 4fc5e15592a..a677e859a15 100644
--- a/app/views/projects/commit/_pipeline.html.haml
+++ b/app/views/projects/commit/_pipeline.html.haml
@@ -25,7 +25,7 @@
= time_interval_in_words pipeline.duration
.row-content-block.build-content.middle-block.pipeline-graph.hidden
- = render "projects/pipelines/graph", subject: pipeline
+ = render "projects/pipelines/graph", subject: pipeline, as: :pipeline
- if pipeline.yaml_errors.present?
.bs-callout.bs-callout-danger
@@ -50,5 +50,4 @@
- if pipeline.project.build_coverage_enabled?
%th Coverage
%th
- - pipeline.stages.each do |stage|
- = render "projects/stage/stage", subject: stage
+ = render partial: "projects/stage/stage", collection: pipeline.stages, as: :stage
diff --git a/app/views/projects/pipelines/_graph.html.haml b/app/views/projects/pipelines/_graph.html.haml
index 3bb6426c156..16297b93d31 100644
--- a/app/views/projects/pipelines/_graph.html.haml
+++ b/app/views/projects/pipelines/_graph.html.haml
@@ -1,4 +1,4 @@
+- pipeline = local_assigns.fetch(:pipeline)
.pipeline-visualization
%ul.stage-column-list
- - subject.stages.each do |stage|
- = render "projects/stage/graph", subject: stage
+ = render partial: "projects/stage/graph", collection: pipeline.stages, as: :stage
diff --git a/app/views/projects/pipelines/_with_tabs.html.haml b/app/views/projects/pipelines/_with_tabs.html.haml
index 2ace9339af3..a58bcb38b18 100644
--- a/app/views/projects/pipelines/_with_tabs.html.haml
+++ b/app/views/projects/pipelines/_with_tabs.html.haml
@@ -13,7 +13,7 @@
.tab-content
#js-tab-pipeline.tab-pane
.build-content.middle-block.pipeline-graph
- = render "projects/pipelines/graph", subject: pipeline
+ = render "projects/pipelines/graph", subject: pipeline, as: :pipeline
#js-tab-builds.tab-pane
- if pipeline.yaml_errors.present?
@@ -39,5 +39,4 @@
- if pipeline.project.build_coverage_enabled?
%th Coverage
%th
- - pipeline.stages.each do |stage|
- = render "projects/stage/stage", subject: stage
+ = render partial: "projects/stage/stage", collection: pipeline.stages, as: :stage
diff --git a/app/views/projects/stage/_graph.html.haml b/app/views/projects/stage/_graph.html.haml
index f1d11db58ab..d8c87fae5a1 100644
--- a/app/views/projects/stage/_graph.html.haml
+++ b/app/views/projects/stage/_graph.html.haml
@@ -1,12 +1,13 @@
+- stage = local_assigns.fetch(:stage)
+- statuses = stage.statuses.latest
+- status_groups = statuses.sort_by(&:name).group_by(&:group_name)
%li.stage-column
.stage-name
- %a{ name: subject.name }
- - if subject.name
- = subject.name.titleize
+ %a{ name: stage.name }
+ - if stage.name
+ = stage.name.titleize
.builds-container
%ul
- - statuses = subject.statuses.latest
- - status_groups = statuses.sort_by(&:name).group_by(&:group_name)
- status_groups.each do |group_name, grouped_statuses|
- if grouped_statuses.one?
- status = grouped_statuses.first
diff --git a/spec/lib/gitlab/ci/status/factory_spec.rb b/spec/lib/gitlab/ci/status/factory_spec.rb
index 8ebdbddb001..d5bd7f7102b 100644
--- a/spec/lib/gitlab/ci/status/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/factory_spec.rb
@@ -1,15 +1,11 @@
require 'spec_helper'
describe Gitlab::Ci::Status::Factory do
- let(:object) { double(status: :created) }
-
subject do
described_class.new(object)
end
- let(:status) do
- subject.fabricate!
- end
+ let(:status) { subject.fabricate! }
context 'when object has a core status' do
HasStatus::AVAILABLE_STATUSES.each do |core_status|
diff --git a/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb b/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
index 939ad2edf04..d6243940f2e 100644
--- a/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
@@ -21,7 +21,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
Gitlab::Ci::Status.const_get(core_status.capitalize))
end
- it 'extends core status with common stage methods' do
+ it 'extends core status with common pipeline methods' do
expect(status).to have_details
expect(status).not_to have_action
expect(status.details_path)
@@ -45,7 +45,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
.to be_a Gitlab::Ci::Status::Pipeline::SuccessWithWarnings
end
- it 'extends core status with common stage methods' do
+ it 'extends core status with common pipeline methods' do
expect(status).to have_details
end
end