diff options
Diffstat (limited to 'spec/lib/gitlab/ci/pipeline/chain')
3 files changed, 30 insertions, 7 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb index 5d20b1b8fda..cc4aaffb0a4 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb @@ -23,9 +23,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Sequence do end it 'does not process the second step' do - subject.build! do |pipeline, sequence| - expect(sequence).not_to be_complete - end + subject.build! expect(second_step).not_to have_received(:perform!) end @@ -43,9 +41,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Sequence do end it 'iterates through entire sequence' do - subject.build! do |pipeline, sequence| - expect(sequence).to be_complete - end + subject.build! expect(first_step).to have_received(:perform!) expect(second_step).to have_received(:perform!) diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb index 931c62701ce..de580d2e148 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb @@ -41,9 +41,10 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do ) end + let(:save_incompleted) { true } let(:command) do Gitlab::Ci::Pipeline::Chain::Command.new( - project: project, current_user: user, config_processor: yaml_processor + project: project, current_user: user, config_processor: yaml_processor, save_incompleted: save_incompleted ) end @@ -84,6 +85,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do perform! expect(pipeline.status).to eq('failed') + expect(pipeline).to be_persisted expect(pipeline.errors.to_a).to include('External validation failed') end @@ -98,6 +100,30 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do perform! end + + context 'when save_incompleted is false' do + let(:save_incompleted) { false} + + it 'adds errors to the pipeline without dropping it' do + perform! + + expect(pipeline.status).to eq('pending') + expect(pipeline).not_to be_persisted + expect(pipeline.errors.to_a).to include('External validation failed') + end + + it 'breaks the chain' do + perform! + + expect(step.break?).to be true + end + + it 'logs the authorization' do + expect(Gitlab::AppLogger).to receive(:info).with(message: 'Pipeline not authorized', project_id: project.id, user_id: user.id) + + perform! + end + end end end diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb index 1dc2e0a1822..7eefb4d7876 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb @@ -68,6 +68,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::Repository do proj.repository.add_tag(user, 'master', 'master') end end + let(:command) do Gitlab::Ci::Pipeline::Chain::Command.new( project: project, current_user: user, origin_ref: 'master') |