diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-05-11 16:49:18 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-05-11 16:49:18 +0900 |
commit | 46fa3089c84642170d86799c4f60fe87507e575d (patch) | |
tree | 9c0959ff4fbc247beabf2dea22d188fb5822f7c5 /spec/lib | |
parent | 910a7d02a812b1203e320d843a77cad2c7069b63 (diff) | |
download | gitlab-ce-46fa3089c84642170d86799c4f60fe87507e575d.tar.gz |
Rescue RecordNotUnique when pipeline is created with non-unique iid
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/chain/create_spec.rb | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb index 0edc3f315bb..b8ab0135092 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb @@ -37,21 +37,38 @@ describe Gitlab::Ci::Pipeline::Chain::Create do end context 'when pipeline has validation errors' do - let(:pipeline) do - build(:ci_pipeline, project: project, ref: nil) + shared_examples_for 'expectations' do + it 'breaks the chain' do + expect(step.break?).to be true + end + + it 'appends validation error' do + expect(pipeline.errors.to_a) + .to include /Failed to persist the pipeline/ + end end + + context 'when ref is nil' do + let(:pipeline) do + build(:ci_pipeline, project: project, ref: nil) + end - before do - step.perform! - end + before do + step.perform! + end - it 'breaks the chain' do - expect(step.break?).to be true + it_behaves_like 'expectations' end - it 'appends validation error' do - expect(pipeline.errors.to_a) - .to include /Failed to persist the pipeline/ + context 'when pipeline has a duplicate iid' do + before do + allow_any_instance_of(Ci::Pipeline).to receive(:ensure_project_iid!) { |p| p.send(:write_attribute, :iid, 1) } + create(:ci_pipeline, project: project) + + step.perform! + end + + it_behaves_like 'expectations' end end end |