From f0002da09c0f8ae4fb9f732c2e225c9affd98b04 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin <godfat@godfat.org> Date: Sat, 1 Oct 2016 14:38:39 +0800 Subject: [PATCH] Add a test for on_failure jobs in the middle --- app/models/concerns/has_status.rb | 1 + .../ci/process_pipeline_service_spec.rb | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb index 5a6c2725354..582fe8bb1a7 100644 --- a/app/models/concerns/has_status.rb +++ b/app/models/concerns/has_status.rb @@ -72,6 +72,7 @@ module HasStatus quoted_when = connection.quote_column_name('when') # We want to ignore skipped manual jobs where("#{quoted_when} <> ? OR status <> ?", 'manual', 'skipped'). + # We want to ignore skipped on_failure where("#{quoted_when} <> ? OR status <> ?", 'on_failure', 'skipped') end end diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb index 95bdb43db05..ff113efd916 100644 --- a/spec/services/ci/process_pipeline_service_spec.rb +++ b/spec/services/ci/process_pipeline_service_spec.rb @@ -230,7 +230,7 @@ describe Ci::ProcessPipelineService, services: true do end end - context 'when there are manual jobs in earlier stages' do + context 'when there are manual/on_failure jobs in earlier stages' do before do builds process_pipeline @@ -266,6 +266,23 @@ describe Ci::ProcessPipelineService, services: true do end end + context 'when second stage has only on_failure jobs' do + let(:builds) do + [create_build('check', 0), + create_build('build', 1, 'on_failure'), + create_build('test', 2)] + end + + it 'skips second stage and continues on third stage' do + expect(builds.map(&:status)).to eq(%w[pending created created]) + + builds.first.success + builds.each(&:reload) + + expect(builds.map(&:status)).to eq(%w[success skipped pending]) + end + end + def create_build(name, stage_idx, when_value = nil) create(:ci_build, :created, -- GitLab