diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-09-24 13:12:11 +0900 |
---|---|---|
committer | Alessio Caiazza <acaiazza@gitlab.com> | 2018-10-02 17:02:12 +0200 |
commit | 571a934f29bee7af9569176e62e5376b471e35fb (patch) | |
tree | b380dc4345cf3e44c438f23481bbf2730926f2fb | |
parent | f8e680b786377443471780d9a096dfb2b873de4a (diff) | |
download | gitlab-ce-571a934f29bee7af9569176e62e5376b471e35fb.tar.gz |
Fix spec. Create scheduled status entry for pipeline
-rw-r--r-- | app/models/concerns/has_status.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/status/pipeline/factory.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/ci/status/pipeline/scheduled.rb | 21 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/pipeline/factory_spec.rb | 35 | ||||
-rw-r--r-- | spec/models/concerns/has_status_spec.rb | 2 |
5 files changed, 34 insertions, 27 deletions
diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb index 652f56f7f11..a8044f2ab15 100644 --- a/app/models/concerns/has_status.rb +++ b/app/models/concerns/has_status.rb @@ -114,7 +114,7 @@ module HasStatus end def blocked? - BLOCKED_STATUS == status + BLOCKED_STATUS.include?(status) end private diff --git a/lib/gitlab/ci/status/pipeline/factory.rb b/lib/gitlab/ci/status/pipeline/factory.rb index 17f9a75f436..00d8f01cbdc 100644 --- a/lib/gitlab/ci/status/pipeline/factory.rb +++ b/lib/gitlab/ci/status/pipeline/factory.rb @@ -5,6 +5,7 @@ module Gitlab class Factory < Status::Factory def self.extended_statuses [[Status::SuccessWarning, + Status::Pipeline::Scheduled, Status::Pipeline::Blocked]] end diff --git a/lib/gitlab/ci/status/pipeline/scheduled.rb b/lib/gitlab/ci/status/pipeline/scheduled.rb new file mode 100644 index 00000000000..5e8f99e58d7 --- /dev/null +++ b/lib/gitlab/ci/status/pipeline/scheduled.rb @@ -0,0 +1,21 @@ +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 diff --git a/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb b/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb index defb3fdc0df..8e3d4464898 100644 --- a/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb @@ -11,8 +11,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do end context 'when pipeline has a core status' do - (HasStatus::AVAILABLE_STATUSES - [HasStatus::BLOCKED_STATUS]) - .each do |simple_status| + HasStatus::AVAILABLE_STATUSES.each do |simple_status| context "when core status is #{simple_status}" do let(:pipeline) { create(:ci_pipeline, status: simple_status) } @@ -24,8 +23,15 @@ describe Gitlab::Ci::Status::Pipeline::Factory do expect(factory.core_status).to be_a expected_status end - it 'does not match extended statuses' do - expect(factory.extended_statuses).to be_empty + if HasStatus::BLOCKED_STATUS.include?(simple_status) + 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 it "fabricates a core status #{simple_status}" do @@ -40,27 +46,6 @@ 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 diff --git a/spec/models/concerns/has_status_spec.rb b/spec/models/concerns/has_status_spec.rb index 6866b43432c..fe9a89e8806 100644 --- a/spec/models/concerns/has_status_spec.rb +++ b/spec/models/concerns/has_status_spec.rb @@ -300,7 +300,7 @@ describe HasStatus do describe '::BLOCKED_STATUS' 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 |