Commit a35c6cc1 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '195998-fix-build-prerequisite-transition' into 'master'

Prevent builds from halting unnecessarily when completing prerequisites

See merge request gitlab-org/gitlab!22938
parents a33c1984 ad4b1a94
...@@ -266,7 +266,7 @@ module Ci ...@@ -266,7 +266,7 @@ module Ci
end end
before_transition on: :enqueue_preparing do |build| 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 end
after_transition created: :scheduled do |build| 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 ...@@ -341,6 +341,36 @@ describe Ci::Build do
end end
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 describe '#actionize' do
context 'when build is a created' do context 'when build is a created' do
before 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