Commit ad4b1a94 authored by Tiger's avatar Tiger

Prevent builds from halting unnecessarily when completing prerequisites

parent 4f642915
......@@ -266,7 +266,7 @@ module Ci
end
before_transition on: :enqueue_preparing do |build|
build.any_unmet_prerequisites? # If false is returned, it stops the transition
!build.any_unmet_prerequisites? # If false is returned, it stops the transition
end
after_transition created: :scheduled do |build|
......
---
title: Prevent builds from halting unnecessarily when completing prerequisites
merge_request: 22938
author:
type: fixed
......@@ -341,6 +341,36 @@ describe Ci::Build do
end
end
describe '#enqueue_preparing' do
let(:build) { create(:ci_build, :preparing) }
subject { build.enqueue_preparing }
before do
allow(build).to receive(:any_unmet_prerequisites?).and_return(has_unmet_prerequisites)
end
context 'build completed prerequisites' do
let(:has_unmet_prerequisites) { false }
it 'transitions to pending' do
subject
expect(build).to be_pending
end
end
context 'build did not complete prerequisites' do
let(:has_unmet_prerequisites) { true }
it 'remains in preparing' do
subject
expect(build).to be_preparing
end
end
end
describe '#actionize' do
context 'when build is a created' do
before do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment