Add tests for build play extended detailed status
This commit is contained in:
parent
ffafd09731
commit
f91e8269c1
2 changed files with 69 additions and 3 deletions
|
@ -12,12 +12,14 @@ FactoryGirl.define do
|
|||
started_at 'Di 29. Okt 09:51:28 CET 2013'
|
||||
finished_at 'Di 29. Okt 09:53:28 CET 2013'
|
||||
commands 'ls -a'
|
||||
|
||||
options do
|
||||
{
|
||||
image: "ruby:2.1",
|
||||
services: ["postgres"]
|
||||
}
|
||||
end
|
||||
|
||||
yaml_variables do
|
||||
[
|
||||
{ key: :DB_NAME, value: 'postgres', public: true }
|
||||
|
@ -60,15 +62,20 @@ FactoryGirl.define do
|
|||
end
|
||||
|
||||
trait :teardown_environment do
|
||||
options do
|
||||
{ environment: { action: 'stop' } }
|
||||
end
|
||||
environment 'staging'
|
||||
options environment: { name: 'staging',
|
||||
action: 'stop' }
|
||||
end
|
||||
|
||||
trait :allowed_to_fail do
|
||||
allow_failure true
|
||||
end
|
||||
|
||||
trait :playable do
|
||||
skipped
|
||||
manual
|
||||
end
|
||||
|
||||
after(:build) do |build, evaluator|
|
||||
build.project = build.pipeline.project
|
||||
end
|
||||
|
|
59
spec/lib/gitlab/ci/status/build/play_spec.rb
Normal file
59
spec/lib/gitlab/ci/status/build/play_spec.rb
Normal file
|
@ -0,0 +1,59 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Ci::Status::Build::Play do
|
||||
let(:core_status) { double('core status') }
|
||||
let(:user) { double('user') }
|
||||
|
||||
subject do
|
||||
described_class.new(core_status)
|
||||
end
|
||||
|
||||
describe '#text' do
|
||||
it { expect(subject.text).to eq 'play' }
|
||||
end
|
||||
|
||||
describe '#label' do
|
||||
it { expect(subject.label).to eq 'play' }
|
||||
end
|
||||
|
||||
describe '#icon' do
|
||||
it 'does not override core status icon' do
|
||||
expect(core_status).to receive(:icon)
|
||||
|
||||
subject.icon
|
||||
end
|
||||
end
|
||||
|
||||
describe '.matches?' do
|
||||
context 'build is playable' do
|
||||
context 'when build stops an environment' do
|
||||
let(:build) do
|
||||
create(:ci_build, :playable, :teardown_environment)
|
||||
end
|
||||
|
||||
it 'does not match' do
|
||||
expect(described_class.matches?(build, user))
|
||||
.to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when build does not stop an environment' do
|
||||
let(:build) { create(:ci_build, :playable) }
|
||||
|
||||
it 'is a correct match' do
|
||||
expect(described_class.matches?(build, user))
|
||||
.to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when build is not playable' do
|
||||
let(:build) { create(:ci_build) }
|
||||
|
||||
it 'does not match' do
|
||||
expect(described_class.matches?(build, user))
|
||||
.to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue