Merge branch '39884-fix-pipeline-transition-with-single-manual-action' into 'master'

Make sure all pipelines would go to pending once

Closes #39884

See merge request gitlab-org/gitlab-ce!15251
This commit is contained in:
Kamil Trzciński 2017-11-14 10:46:07 +00:00
commit 6b9b516007
3 changed files with 32 additions and 2 deletions

View file

@ -66,8 +66,8 @@ module Ci
state_machine :status, initial: :created do
event :enqueue do
transition created: :pending
transition [:success, :failed, :canceled, :skipped] => :running
transition [:created, :skipped] => :pending
transition [:success, :failed, :canceled] => :running
end
event :run do

View file

@ -0,0 +1,6 @@
---
title: Fix pipeline status transition for single manual job. This would also fix pipeline
duration becuse it is depending on status transition
merge_request: 15251
author:
type: fixed

View file

@ -292,6 +292,30 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
context 'when there is only one manual action' do
before do
create_build('deploy', stage_idx: 0, when: 'manual', allow_failure: true)
process_pipeline
end
it 'skips the pipeline' do
expect(pipeline.reload).to be_skipped
end
context 'when the action was played' do
before do
play_manual_action('deploy')
end
it 'queues the action and pipeline' do
expect(all_builds_statuses).to eq(%w[pending])
expect(pipeline.reload).to be_pending
end
end
end
context 'when blocking manual actions are defined' do
before do
create_build('code:test', stage_idx: 0)