2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-05-09 12:01:36 +05:30
require 'spec_helper'
2023-03-17 16:20:25 +05:30
RSpec . describe Gitlab :: Ci :: Status :: Build :: Manual , feature_category : :continuous_integration do
2022-06-21 17:19:12 +05:30
let_it_be ( :user ) { create ( :user ) }
let_it_be ( :job ) { create ( :ci_build , :manual ) }
2018-05-09 12:01:36 +05:30
subject do
2022-06-21 17:19:12 +05:30
described_class . new ( Gitlab :: Ci :: Status :: Core . new ( job , user ) )
2018-05-09 12:01:36 +05:30
end
describe '#illustration' do
it { expect ( subject . illustration ) . to include ( :image , :size , :title , :content ) }
2022-06-21 17:19:12 +05:30
context 'when the user can trigger the job' do
before do
job . project . add_maintainer ( user )
end
2023-03-17 16:20:25 +05:30
context 'when the job has not been played' do
it 'instructs the user about possible actions' do
expect ( subject . illustration [ :content ] ) . to eq (
_ (
'This job does not start automatically and must be started manually. ' \
'You can add CI/CD variables below for last-minute configuration changes before starting the job.'
)
)
end
end
context 'when the job is retryable' do
before do
job . update! ( status : :failed )
end
it 'instructs the user about possible actions' do
expect ( subject . illustration [ :content ] ) . to eq (
_ ( " You can modify this job's CI/CD variables before running it again. " )
)
end
end
end
context 'when the user can not trigger the job because of outdated deployment' do
before do
allow ( job ) . to receive ( :outdated_deployment? ) . and_return ( true )
end
it { expect ( subject . illustration [ :content ] ) . to match / This deployment job does not run automatically and must be started manually, but it's older than the latest deployment, and therefore can't run / }
2022-06-21 17:19:12 +05:30
end
2023-03-17 16:20:25 +05:30
context 'when the user can not trigger the job due to another reason' do
it 'informs the user' do
expect ( subject . illustration [ :content ] ) . to eq (
_ ( " This job does not run automatically and must be started manually, but you do not have access to it. " )
)
end
2022-06-21 17:19:12 +05:30
end
2018-05-09 12:01:36 +05:30
end
describe '.matches?' do
2022-08-27 11:52:29 +05:30
subject { described_class . matches? ( build , user ) }
2018-05-09 12:01:36 +05:30
context 'when build is manual' do
let ( :build ) { create ( :ci_build , :manual ) }
it 'is a correct match' do
expect ( subject ) . to be true
end
end
context 'when build is not manual' do
let ( :build ) { create ( :ci_build ) }
it 'does not match' do
expect ( subject ) . to be false
end
end
end
end