diff options
Diffstat (limited to 'spec/lib/gitlab/ci/status')
-rw-r--r-- | spec/lib/gitlab/ci/status/bridge/common_spec.rb | 9 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/bridge/factory_spec.rb | 61 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/canceled_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/created_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/failed_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/pending_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/preparing_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/running_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/scheduled_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/skipped_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/success_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/waiting_for_resource_spec.rb | 4 |
12 files changed, 99 insertions, 11 deletions
diff --git a/spec/lib/gitlab/ci/status/bridge/common_spec.rb b/spec/lib/gitlab/ci/status/bridge/common_spec.rb index 92600b21afc..37524afc83d 100644 --- a/spec/lib/gitlab/ci/status/bridge/common_spec.rb +++ b/spec/lib/gitlab/ci/status/bridge/common_spec.rb @@ -30,15 +30,6 @@ RSpec.describe Gitlab::Ci::Status::Bridge::Common do it { expect(subject).to have_details } it { expect(subject.details_path).to include "pipelines/#{downstream_pipeline.id}" } - - context 'when ci_bridge_pipeline_details is disabled' do - before do - stub_feature_flags(ci_bridge_pipeline_details: false) - end - - it { expect(subject).not_to have_details } - it { expect(subject.details_path).to be_nil } - end end context 'when user does not have access to read downstream pipeline' do diff --git a/spec/lib/gitlab/ci/status/bridge/factory_spec.rb b/spec/lib/gitlab/ci/status/bridge/factory_spec.rb index 021b777a0ff..d27bb98ba9a 100644 --- a/spec/lib/gitlab/ci/status/bridge/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/bridge/factory_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Gitlab::Ci::Status::Bridge::Factory do end context 'when bridge is created' do - let(:bridge) { create(:ci_bridge) } + let(:bridge) { create_bridge(:created) } it 'matches correct core status' do expect(factory.core_status).to be_a Gitlab::Ci::Status::Created @@ -32,7 +32,7 @@ RSpec.describe Gitlab::Ci::Status::Bridge::Factory do end context 'when bridge is failed' do - let(:bridge) { create(:ci_bridge, :failed) } + let(:bridge) { create_bridge(:failed) } it 'matches correct core status' do expect(factory.core_status).to be_a Gitlab::Ci::Status::Failed @@ -70,4 +70,61 @@ RSpec.describe Gitlab::Ci::Status::Bridge::Factory do end end end + + context 'when bridge is a manual action' do + let(:bridge) { create_bridge(:playable) } + + it 'matches correct core status' do + expect(factory.core_status).to be_a Gitlab::Ci::Status::Manual + end + + it 'matches correct extended statuses' do + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::Bridge::Manual, + Gitlab::Ci::Status::Bridge::Play, + Gitlab::Ci::Status::Bridge::Action] + end + + it 'fabricates action detailed status' do + expect(status).to be_a Gitlab::Ci::Status::Bridge::Action + end + + it 'fabricates status with correct details' do + expect(status.text).to eq s_('CiStatusText|manual') + expect(status.group).to eq 'manual' + expect(status.icon).to eq 'status_manual' + expect(status.favicon).to eq 'favicon_status_manual' + expect(status.illustration).to include(:image, :size, :title, :content) + expect(status.label).to include 'manual play action' + expect(status).not_to have_details + expect(status.action_path).to include 'play' + end + + context 'when user has ability to play action' do + before do + bridge.downstream_project.add_developer(user) + end + + it 'fabricates status that has action' do + expect(status).to have_action + end + end + + context 'when user does not have ability to play action' do + it 'fabricates status that has no action' do + expect(status).not_to have_action + end + end + end + + private + + def create_bridge(trait) + upstream_project = create(:project, :repository) + downstream_project = create(:project, :repository) + upstream_pipeline = create(:ci_pipeline, :running, project: upstream_project) + trigger = { trigger: { project: downstream_project.full_path, branch: 'feature' } } + + create(:ci_bridge, trait, options: trigger, pipeline: upstream_pipeline) + end end diff --git a/spec/lib/gitlab/ci/status/canceled_spec.rb b/spec/lib/gitlab/ci/status/canceled_spec.rb index a35efae5c57..7fae76f61ea 100644 --- a/spec/lib/gitlab/ci/status/canceled_spec.rb +++ b/spec/lib/gitlab/ci/status/canceled_spec.rb @@ -26,4 +26,8 @@ RSpec.describe Gitlab::Ci::Status::Canceled do describe '#group' do it { expect(subject.group).to eq 'canceled' } end + + describe '#details_path' do + it { expect(subject.details_path).to be_nil } + end end diff --git a/spec/lib/gitlab/ci/status/created_spec.rb b/spec/lib/gitlab/ci/status/created_spec.rb index 1ddced923f6..1e54d1ed8c5 100644 --- a/spec/lib/gitlab/ci/status/created_spec.rb +++ b/spec/lib/gitlab/ci/status/created_spec.rb @@ -26,4 +26,8 @@ RSpec.describe Gitlab::Ci::Status::Created do describe '#group' do it { expect(subject.group).to eq 'created' } end + + describe '#details_path' do + it { expect(subject.details_path).to be_nil } + end end diff --git a/spec/lib/gitlab/ci/status/failed_spec.rb b/spec/lib/gitlab/ci/status/failed_spec.rb index e8bd728b740..f3f3304b04d 100644 --- a/spec/lib/gitlab/ci/status/failed_spec.rb +++ b/spec/lib/gitlab/ci/status/failed_spec.rb @@ -26,4 +26,8 @@ RSpec.describe Gitlab::Ci::Status::Failed do describe '#group' do it { expect(subject.group).to eq 'failed' } end + + describe '#details_path' do + it { expect(subject.details_path).to be_nil } + end end diff --git a/spec/lib/gitlab/ci/status/pending_spec.rb b/spec/lib/gitlab/ci/status/pending_spec.rb index 0e47b19d9c1..1c062a0133d 100644 --- a/spec/lib/gitlab/ci/status/pending_spec.rb +++ b/spec/lib/gitlab/ci/status/pending_spec.rb @@ -26,4 +26,8 @@ RSpec.describe Gitlab::Ci::Status::Pending do describe '#group' do it { expect(subject.group).to eq 'pending' } end + + describe '#details_path' do + it { expect(subject.details_path).to be_nil } + end end diff --git a/spec/lib/gitlab/ci/status/preparing_spec.rb b/spec/lib/gitlab/ci/status/preparing_spec.rb index 6d33eb77560..ec1850c1959 100644 --- a/spec/lib/gitlab/ci/status/preparing_spec.rb +++ b/spec/lib/gitlab/ci/status/preparing_spec.rb @@ -26,4 +26,8 @@ RSpec.describe Gitlab::Ci::Status::Preparing do describe '#group' do it { expect(subject.group).to eq 'preparing' } end + + describe '#details_path' do + it { expect(subject.details_path).to be_nil } + end end diff --git a/spec/lib/gitlab/ci/status/running_spec.rb b/spec/lib/gitlab/ci/status/running_spec.rb index fbc7bfd81b3..e40d696ee4d 100644 --- a/spec/lib/gitlab/ci/status/running_spec.rb +++ b/spec/lib/gitlab/ci/status/running_spec.rb @@ -26,4 +26,8 @@ RSpec.describe Gitlab::Ci::Status::Running do describe '#group' do it { expect(subject.group).to eq 'running' } end + + describe '#details_path' do + it { expect(subject.details_path).to be_nil } + end end diff --git a/spec/lib/gitlab/ci/status/scheduled_spec.rb b/spec/lib/gitlab/ci/status/scheduled_spec.rb index 4a1dae937ca..8a923faf3f9 100644 --- a/spec/lib/gitlab/ci/status/scheduled_spec.rb +++ b/spec/lib/gitlab/ci/status/scheduled_spec.rb @@ -26,4 +26,8 @@ RSpec.describe Gitlab::Ci::Status::Scheduled do describe '#group' do it { expect(subject.group).to eq 'scheduled' } end + + describe '#details_path' do + it { expect(subject.details_path).to be_nil } + end end diff --git a/spec/lib/gitlab/ci/status/skipped_spec.rb b/spec/lib/gitlab/ci/status/skipped_spec.rb index f402bbe5221..ac3c2f253f7 100644 --- a/spec/lib/gitlab/ci/status/skipped_spec.rb +++ b/spec/lib/gitlab/ci/status/skipped_spec.rb @@ -26,4 +26,8 @@ RSpec.describe Gitlab::Ci::Status::Skipped do describe '#group' do it { expect(subject.group).to eq 'skipped' } end + + describe '#details_path' do + it { expect(subject.details_path).to be_nil } + end end diff --git a/spec/lib/gitlab/ci/status/success_spec.rb b/spec/lib/gitlab/ci/status/success_spec.rb index 2d1c50448d4..f2069334abd 100644 --- a/spec/lib/gitlab/ci/status/success_spec.rb +++ b/spec/lib/gitlab/ci/status/success_spec.rb @@ -26,4 +26,8 @@ RSpec.describe Gitlab::Ci::Status::Success do describe '#group' do it { expect(subject.group).to eq 'success' } end + + describe '#details_path' do + it { expect(subject.details_path).to be_nil } + end end diff --git a/spec/lib/gitlab/ci/status/waiting_for_resource_spec.rb b/spec/lib/gitlab/ci/status/waiting_for_resource_spec.rb index de18198c6c2..bb6139accaf 100644 --- a/spec/lib/gitlab/ci/status/waiting_for_resource_spec.rb +++ b/spec/lib/gitlab/ci/status/waiting_for_resource_spec.rb @@ -26,4 +26,8 @@ RSpec.describe Gitlab::Ci::Status::WaitingForResource do describe '#group' do it { expect(subject.group).to eq 'waiting-for-resource' } end + + describe '#details_path' do + it { expect(subject.details_path).to be_nil } + end end |