From 8c9dc985b90c353b33cb829caf51f8320171bc15 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 12 Feb 2020 06:09:05 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/models/ci/build_spec.rb | 3 +- spec/models/ci/processable_spec.rb | 68 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) (limited to 'spec/models/ci') diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index b99f51bb36e..91185446488 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -3007,7 +3007,8 @@ describe Ci::Build do stage: 'test', ref: 'feature', project: project, - pipeline: pipeline + pipeline: pipeline, + scheduling_type: :stage ) end diff --git a/spec/models/ci/processable_spec.rb b/spec/models/ci/processable_spec.rb index 87dbcbf870e..370606a73bc 100644 --- a/spec/models/ci/processable_spec.rb +++ b/spec/models/ci/processable_spec.rb @@ -52,4 +52,72 @@ describe Ci::Processable do end end end + + describe 'validate presence of scheduling_type' do + context 'on create' do + let(:processable) do + build( + :ci_build, :created, project: project, pipeline: pipeline, + importing: importing, scheduling_type: nil + ) + end + + context 'when importing' do + let(:importing) { true } + + context 'when validate_scheduling_type_of_processables is true' do + before do + stub_feature_flags(validate_scheduling_type_of_processables: true) + end + + it 'does not validate' do + expect(processable).to be_valid + end + end + + context 'when validate_scheduling_type_of_processables is false' do + before do + stub_feature_flags(validate_scheduling_type_of_processables: false) + end + + it 'does not validate' do + expect(processable).to be_valid + end + end + end + + context 'when not importing' do + let(:importing) { false } + + context 'when validate_scheduling_type_of_processables is true' do + before do + stub_feature_flags(validate_scheduling_type_of_processables: true) + end + + it 'validates' do + expect(processable).not_to be_valid + end + end + + context 'when validate_scheduling_type_of_processables is false' do + before do + stub_feature_flags(validate_scheduling_type_of_processables: false) + end + + it 'does not validate' do + expect(processable).to be_valid + end + end + end + end + + context 'on update' do + let(:processable) { create(:ci_build, :created, project: project, pipeline: pipeline) } + + it 'does not validate' do + processable.scheduling_type = nil + expect(processable).to be_valid + end + end + end end -- cgit v1.2.1