Skip to content
Snippets Groups Projects
Unverified Commit bbd05526 authored by Alishan Ladhani's avatar Alishan Ladhani
Browse files

Extend pipeline job page for Deployment Approvals

Part of Deployment Approvals MVC
parent 82253cc6
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -427,6 +427,10 @@ def playable?
action? && !archived? && (manual? || scheduled? || retryable?)
end
 
def waiting_for_deployment_approval?
manual? && starts_environment? && deployment&.blocked?
end
def schedulable?
self.when == 'delayed' && options[:start_in].present?
end
Loading
Loading
Loading
Loading
@@ -14,7 +14,8 @@ def self.extended_statuses
Status::Build::WaitingForResource,
Status::Build::Preparing,
Status::Build::Pending,
Status::Build::Skipped],
Status::Build::Skipped,
Status::Build::WaitingForApproval],
[Status::Build::Cancelable,
Status::Build::Retryable],
[Status::Build::FailedUnmetPrerequisites,
Loading
Loading
# frozen_string_literal: true
module Gitlab
module Ci
module Status
module Build
class WaitingForApproval < Status::Extended
def illustration
{
image: 'illustrations/manual_action.svg',
size: 'svg-394',
title: 'Waiting for approval',
content: "This job deploys to the protected environment \"#{subject.deployment&.environment&.name}\" which requires approvals. Use the Deployments API to approve or reject the deployment."
}
end
def self.matches?(build, user)
build.waiting_for_deployment_approval?
end
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Ci::Status::Build::WaitingForApproval do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
subject { described_class.new(Gitlab::Ci::Status::Core.new(build, user)) }
describe '#illustration' do
let(:build) { create(:ci_build, :manual, environment: 'production', project: project) }
before do
environment = create(:environment, name: 'production', project: project)
create(:deployment, :blocked, project: project, environment: environment, deployable: build)
end
it { expect(subject.illustration).to include(:image, :size) }
it { expect(subject.illustration[:title]).to eq('Waiting for approval') }
it { expect(subject.illustration[:content]).to include('This job deploys to the protected environment "production"') }
end
describe '.matches?' do
subject { described_class.matches?(build, user) }
let(:build) { create(:ci_build, :manual, environment: 'production', project: project) }
before do
create(:deployment, deployment_status, deployable: build, project: project)
end
context 'when build is waiting for approval' do
let(:deployment_status) { :blocked }
it 'is a correct match' do
expect(subject).to be_truthy
end
end
context 'when build is not waiting for approval' do
let(:deployment_status) { :created }
it 'does not match' do
expect(subject).to be_falsey
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment