debian-mirror-gitlab/spec/lib/gitlab/ci/status/build/play_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

113 lines
2.8 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Ci::Status::Build::Play do
2022-07-23 23:45:48 +05:30
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :stubbed_repository) }
let_it_be_with_refind(:build) { create(:ci_build, :manual, project: project) }
2017-08-17 22:00:37 +05:30
let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
subject { described_class.new(status) }
describe '#label' do
it 'has a label that says it is a manual action' do
expect(subject.label).to eq 'manual play action'
end
end
2018-05-09 12:01:36 +05:30
describe '#status_tooltip' do
it 'does not override status status_tooltip' do
expect(status).to receive(:status_tooltip)
subject.status_tooltip
end
end
describe '#badge_tooltip' do
it 'does not override status badge_tooltip' do
expect(status).to receive(:badge_tooltip)
subject.badge_tooltip
end
end
2017-08-17 22:00:37 +05:30
describe '#has_action?' do
context 'when user is allowed to update build' do
context 'when user is allowed to trigger protected action' do
before do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
name: build.ref, project: project)
end
it { is_expected.to have_action }
end
context 'when user can not push to the branch' do
2017-09-10 17:25:29 +05:30
before do
build.project.add_developer(user)
2018-11-18 11:00:15 +05:30
create(:protected_branch, :maintainers_can_push,
2018-05-09 12:01:36 +05:30
name: build.ref, project: project)
2017-09-10 17:25:29 +05:30
end
2017-08-17 22:00:37 +05:30
it { is_expected.not_to have_action }
end
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
describe '#action_icon' do
2018-03-17 18:26:18 +05:30
it { expect(subject.action_icon).to eq 'play' }
2017-08-17 22:00:37 +05:30
end
describe '#action_title' do
it { expect(subject.action_title).to eq 'Play' }
end
2018-05-09 12:01:36 +05:30
describe '#action_button_title' do
it { expect(subject.action_button_title).to eq 'Trigger this manual action' }
end
2017-08-17 22:00:37 +05:30
describe '.matches?' do
subject { described_class.matches?(build, user) }
context 'when 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(subject).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(subject).to be true
end
end
end
context 'when build is not playable' do
let(:build) { create(:ci_build) }
it 'does not match' do
expect(subject).to be false
end
end
end
end