Improve specs for detailed statuses with manual actions

This commit is contained in:
Grzegorz Bizon 2017-03-06 14:08:55 +01:00
parent cb4c9a03ce
commit bb2460c1ea
14 changed files with 42 additions and 57 deletions

View file

@ -5,22 +5,10 @@ module Gitlab
class Play < SimpleDelegator
include Status::Extended
def text
'manual'
end
def label
'manual play action'
end
def icon
'icon_status_manual'
end
def group
'manual'
end
def has_action?
can?(user, :update_build, subject)
end

View file

@ -5,22 +5,10 @@ module Gitlab
class Stop < SimpleDelegator
include Status::Extended
def text
'manual'
end
def label
'manual stop action'
end
def icon
'icon_status_manual'
end
def group
'manual'
end
def has_action?
can?(user, :update_build, subject)
end

View file

@ -200,12 +200,13 @@ describe Gitlab::Ci::Status::Build::Factory do
.to eq [Gitlab::Ci::Status::Build::Play]
end
it 'fabricates a core skipped status' do
it 'fabricates a play detailed status' do
expect(status).to be_a Gitlab::Ci::Status::Build::Play
end
it 'fabricates status with correct details' do
expect(status.text).to eq 'manual'
expect(status.group).to eq 'manual'
expect(status.icon).to eq 'icon_status_manual'
expect(status.label).to eq 'manual play action'
expect(status).to have_details
@ -226,12 +227,13 @@ describe Gitlab::Ci::Status::Build::Factory do
.to eq [Gitlab::Ci::Status::Build::Stop]
end
it 'fabricates a core skipped status' do
it 'fabricates a stop detailed status' do
expect(status).to be_a Gitlab::Ci::Status::Build::Stop
end
it 'fabricates status with correct details' do
expect(status.text).to eq 'manual'
expect(status.group).to eq 'manual'
expect(status.icon).to eq 'icon_status_manual'
expect(status.label).to eq 'manual stop action'
expect(status).to have_details

View file

@ -6,22 +6,10 @@ describe Gitlab::Ci::Status::Build::Play do
subject { described_class.new(status) }
describe '#text' do
it { expect(subject.text).to eq 'manual' }
end
describe '#label' do
it { expect(subject.label).to eq 'manual play action' }
end
describe '#icon' do
it { expect(subject.icon).to eq 'icon_status_manual' }
end
describe '#group' do
it { expect(subject.group).to eq 'manual' }
end
describe 'action details' do
let(:user) { create(:user) }
let(:build) { create(:ci_build) }

View file

@ -8,22 +8,10 @@ describe Gitlab::Ci::Status::Build::Stop do
described_class.new(status)
end
describe '#text' do
it { expect(subject.text).to eq 'manual' }
end
describe '#label' do
it { expect(subject.label).to eq 'manual stop action' }
end
describe '#icon' do
it { expect(subject.icon).to eq 'icon_status_manual' }
end
describe '#group' do
it { expect(subject.group).to eq 'manual' }
end
describe 'action details' do
let(:user) { create(:user) }
let(:build) { create(:ci_build) }

View file

@ -6,7 +6,7 @@ describe Gitlab::Ci::Status::Canceled do
end
describe '#text' do
it { expect(subject.label).to eq 'canceled' }
it { expect(subject.text).to eq 'canceled' }
end
describe '#label' do

View file

@ -6,7 +6,7 @@ describe Gitlab::Ci::Status::Created do
end
describe '#text' do
it { expect(subject.label).to eq 'created' }
it { expect(subject.text).to eq 'created' }
end
describe '#label' do

View file

@ -6,7 +6,7 @@ describe Gitlab::Ci::Status::Failed do
end
describe '#text' do
it { expect(subject.label).to eq 'failed' }
it { expect(subject.text).to eq 'failed' }
end
describe '#label' do

View file

@ -0,0 +1,23 @@
require 'spec_helper'
describe Gitlab::Ci::Status::Manual do
subject do
described_class.new(double('subject'), double('user'))
end
describe '#text' do
it { expect(subject.text).to eq 'manual' }
end
describe '#label' do
it { expect(subject.label).to eq 'manual action' }
end
describe '#icon' do
it { expect(subject.icon).to eq 'icon_status_manual' }
end
describe '#group' do
it { expect(subject.group).to eq 'manual' }
end
end

View file

@ -6,7 +6,7 @@ describe Gitlab::Ci::Status::Pending do
end
describe '#text' do
it { expect(subject.label).to eq 'pending' }
it { expect(subject.text).to eq 'pending' }
end
describe '#label' do

View file

@ -6,7 +6,7 @@ describe Gitlab::Ci::Status::Running do
end
describe '#text' do
it { expect(subject.label).to eq 'running' }
it { expect(subject.text).to eq 'running' }
end
describe '#label' do

View file

@ -6,7 +6,7 @@ describe Gitlab::Ci::Status::Skipped do
end
describe '#text' do
it { expect(subject.label).to eq 'skipped' }
it { expect(subject.text).to eq 'skipped' }
end
describe '#label' do

View file

@ -6,7 +6,7 @@ describe Gitlab::Ci::Status::Success do
end
describe '#text' do
it { expect(subject.label).to eq 'passed' }
it { expect(subject.text).to eq 'passed' }
end
describe '#label' do

View file

@ -643,6 +643,14 @@ describe Ci::Pipeline, models: true do
end
end
context 'when pipeline is blocked' do
let(:pipeline) { create(:ci_pipeline, status: :manual) }
it 'returns detailed status for blocked pipeline' do
expect(subject.text).to eq 'manual'
end
end
context 'when pipeline is successful but with warnings' do
let(:pipeline) { create(:ci_pipeline, status: :success) }