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 class Play < SimpleDelegator
include Status::Extended include Status::Extended
def text
'manual'
end
def label def label
'manual play action' 'manual play action'
end end
def icon
'icon_status_manual'
end
def group
'manual'
end
def has_action? def has_action?
can?(user, :update_build, subject) can?(user, :update_build, subject)
end end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -643,6 +643,14 @@ describe Ci::Pipeline, models: true do
end end
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 context 'when pipeline is successful but with warnings' do
let(:pipeline) { create(:ci_pipeline, status: :success) } let(:pipeline) { create(:ci_pipeline, status: :success) }