Commit 1dc2e185 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'feature/gb/verbosify-blocked-pipeline-status' into 'master'

Verbosify blocked pipeline status description

Closes #29134

See merge request !9800
parents 72e940df 82327ea7
......@@ -15,6 +15,8 @@ module CiStatusHelper
'passed'
when 'success_with_warnings'
'passed with warnings'
when 'manual'
'waiting for manual action'
else
status
end
......
module Gitlab
module Ci
module Status
module Pipeline
class Blocked < SimpleDelegator
include Status::Extended
def text
'blocked'
end
def label
'waiting for manual action'
end
def self.matches?(pipeline, user)
pipeline.blocked?
end
end
end
end
end
end
......@@ -4,7 +4,8 @@ module Gitlab
module Pipeline
class Factory < Status::Factory
def self.extended_statuses
[Status::SuccessWarning]
[[Status::SuccessWarning,
Status::Pipeline::Blocked]]
end
def self.common_helpers
......
......@@ -40,6 +40,14 @@ FactoryGirl.define do
trait :invalid do
config(rspec: nil)
end
trait :blocked do
status :manual
end
trait :success do
status :success
end
end
end
end
require 'spec_helper'
describe Gitlab::Ci::Status::Pipeline::Blocked do
let(:pipeline) { double('pipeline') }
subject do
described_class.new(pipeline)
end
describe '#text' do
it 'overrides status text' do
expect(subject.text).to eq 'blocked'
end
end
describe '#label' do
it 'overrides status label' do
expect(subject.label).to eq 'waiting for manual action'
end
end
describe '.matches?' do
let(:user) { double('user') }
subject { described_class.matches?(pipeline, user) }
context 'when pipeline is blocked' do
let(:pipeline) { create(:ci_pipeline, :blocked) }
it 'is a correct match' do
expect(subject).to be true
end
end
context 'when pipeline is not blocked' do
let(:pipeline) { create(:ci_pipeline, :success) }
it 'does not match' do
expect(subject).to be false
end
end
end
end
......@@ -11,7 +11,8 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
end
context 'when pipeline has a core status' do
HasStatus::AVAILABLE_STATUSES.each do |simple_status|
(HasStatus::AVAILABLE_STATUSES - [HasStatus::BLOCKED_STATUS])
.each do |simple_status|
context "when core status is #{simple_status}" do
let(:pipeline) { create(:ci_pipeline, status: simple_status) }
......@@ -23,7 +24,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
expect(factory.core_status).to be_a expected_status
end
it 'does not matche extended statuses' do
it 'does not match extended statuses' do
expect(factory.extended_statuses).to be_empty
end
......@@ -39,6 +40,27 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
end
end
end
context "when core status is manual" do
let(:pipeline) { create(:ci_pipeline, status: :manual) }
it "matches manual core status" do
expect(factory.core_status)
.to be_a Gitlab::Ci::Status::Manual
end
it 'matches a correct extended statuses' do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Pipeline::Blocked]
end
it 'extends core status with common pipeline methods' do
expect(status).to have_details
expect(status).not_to have_action
expect(status.details_path)
.to include "pipelines/#{pipeline.id}"
end
end
end
context 'when pipeline has warnings' do
......
......@@ -647,7 +647,7 @@ describe Ci::Pipeline, models: true do
let(:pipeline) { create(:ci_pipeline, status: :manual) }
it 'returns detailed status for blocked pipeline' do
expect(subject.text).to eq 'manual'
expect(subject.text).to eq 'blocked'
end
end
......
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