2016-12-12 08:59:46 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::Ci::Status::Build::Stop do
|
2016-12-13 06:27:01 -05:00
|
|
|
let(:status) { double('core status') }
|
2016-12-12 08:59:46 -05:00
|
|
|
let(:user) { double('user') }
|
|
|
|
|
|
|
|
subject do
|
2016-12-13 06:27:01 -05:00
|
|
|
described_class.new(status)
|
2016-12-12 08:59:46 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#label' do
|
2016-12-13 06:27:01 -05:00
|
|
|
it { expect(subject.label).to eq 'manual stop action' }
|
2016-12-12 08:59:46 -05:00
|
|
|
end
|
|
|
|
|
2016-12-13 07:13:09 -05:00
|
|
|
describe 'action details' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:build) { create(:ci_build) }
|
|
|
|
let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
|
2016-12-13 06:27:01 -05:00
|
|
|
|
2016-12-13 07:13:09 -05:00
|
|
|
describe '#has_action?' do
|
|
|
|
context 'when user is allowed to update build' do
|
|
|
|
before { build.project.team << [user, :developer] }
|
2016-12-13 06:27:01 -05:00
|
|
|
|
2016-12-13 07:13:09 -05:00
|
|
|
it { is_expected.to have_action }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user is not allowed to update build' do
|
|
|
|
it { is_expected.not_to have_action }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#action_path' do
|
|
|
|
it { expect(subject.action_path).to include "#{build.id}/play" }
|
|
|
|
end
|
2016-12-13 06:27:01 -05:00
|
|
|
|
2016-12-13 07:13:09 -05:00
|
|
|
describe '#action_icon' do
|
2017-01-25 06:04:16 -05:00
|
|
|
it { expect(subject.action_icon).to eq 'icon_action_stop' }
|
2016-12-13 07:13:09 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#action_title' do
|
|
|
|
it { expect(subject.action_title).to eq 'Stop' }
|
|
|
|
end
|
2016-12-12 08:59:46 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '.matches?' do
|
2016-12-13 06:27:01 -05:00
|
|
|
subject { described_class.matches?(build, user) }
|
|
|
|
|
2016-12-14 05:36:19 -05:00
|
|
|
context 'when build is playable' do
|
2016-12-12 08:59:46 -05:00
|
|
|
context 'when build stops an environment' do
|
|
|
|
let(:build) do
|
|
|
|
create(:ci_build, :playable, :teardown_environment)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is a correct match' do
|
2016-12-13 06:27:01 -05:00
|
|
|
expect(subject).to be true
|
2016-12-12 08:59:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when build does not stop an environment' do
|
|
|
|
let(:build) { create(:ci_build, :playable) }
|
|
|
|
|
|
|
|
it 'does not match' do
|
2016-12-13 06:27:01 -05:00
|
|
|
expect(subject).to be false
|
2016-12-12 08:59:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when build is not playable' do
|
|
|
|
let(:build) { create(:ci_build) }
|
|
|
|
|
|
|
|
it 'does not match' do
|
2016-12-13 06:27:01 -05:00
|
|
|
expect(subject).to be false
|
2016-12-12 08:59:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|