Commit 571a934f authored by Shinya Maeda's avatar Shinya Maeda Committed by Alessio Caiazza

Fix spec. Create scheduled status entry for pipeline

parent f8e680b7
...@@ -114,7 +114,7 @@ module HasStatus ...@@ -114,7 +114,7 @@ module HasStatus
end end
def blocked? def blocked?
BLOCKED_STATUS == status BLOCKED_STATUS.include?(status)
end end
private private
......
...@@ -5,6 +5,7 @@ module Gitlab ...@@ -5,6 +5,7 @@ module Gitlab
class Factory < Status::Factory class Factory < Status::Factory
def self.extended_statuses def self.extended_statuses
[[Status::SuccessWarning, [[Status::SuccessWarning,
Status::Pipeline::Scheduled,
Status::Pipeline::Blocked]] Status::Pipeline::Blocked]]
end end
......
module Gitlab
module Ci
module Status
module Pipeline
class Scheduled < Status::Extended
def text
s_('CiStatusText|scheduled')
end
def label
s_('CiStatusLabel|waiting for scheduled job')
end
def self.matches?(pipeline, user)
pipeline.scheduled?
end
end
end
end
end
end
...@@ -11,8 +11,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do ...@@ -11,8 +11,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
end end
context 'when pipeline has a core status' do context 'when pipeline has a core status' do
(HasStatus::AVAILABLE_STATUSES - [HasStatus::BLOCKED_STATUS]) HasStatus::AVAILABLE_STATUSES.each do |simple_status|
.each do |simple_status|
context "when core status is #{simple_status}" do context "when core status is #{simple_status}" do
let(:pipeline) { create(:ci_pipeline, status: simple_status) } let(:pipeline) { create(:ci_pipeline, status: simple_status) }
...@@ -24,8 +23,15 @@ describe Gitlab::Ci::Status::Pipeline::Factory do ...@@ -24,8 +23,15 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
expect(factory.core_status).to be_a expected_status expect(factory.core_status).to be_a expected_status
end end
it 'does not match extended statuses' do if HasStatus::BLOCKED_STATUS.include?(simple_status)
expect(factory.extended_statuses).to be_empty it 'matches a correct extended statuses' do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Pipeline::Blocked]
end
else
it 'does not match extended statuses' do
expect(factory.extended_statuses).to be_empty
end
end end
it "fabricates a core status #{simple_status}" do it "fabricates a core status #{simple_status}" do
...@@ -40,27 +46,6 @@ describe Gitlab::Ci::Status::Pipeline::Factory do ...@@ -40,27 +46,6 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
end end
end 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 end
context 'when pipeline has warnings' do context 'when pipeline has warnings' do
......
...@@ -300,7 +300,7 @@ describe HasStatus do ...@@ -300,7 +300,7 @@ describe HasStatus do
describe '::BLOCKED_STATUS' do describe '::BLOCKED_STATUS' do
it 'is a status manual' do it 'is a status manual' do
expect(described_class::BLOCKED_STATUS).to eq 'manual' expect(described_class::BLOCKED_STATUS).to eq %w[manual scheduled]
end end
end end
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