diff options
author | Matija Čupić <matteeyah@gmail.com> | 2019-01-21 13:30:27 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2019-01-21 16:26:09 +0100 |
commit | a2477ec2e363c58857e5f8f08a370282bffa57cf (patch) | |
tree | 82d107cd6f7eafa7bbd0a826e9c9278f1bd91444 /spec | |
parent | 673b80977542e1f8725a288e84287b0e5606b466 (diff) | |
download | gitlab-ce-a2477ec2e363c58857e5f8f08a370282bffa57cf.tar.gz |
Assign pipeline protected attribute in Populate
This removes the Protect pipeline chain step and assigns the protected
attribute in the Populate step instead.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb | 25 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/chain/protect_spec.rb | 43 |
2 files changed, 25 insertions, 43 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb index 1b014ecfaa4..3459939267a 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb @@ -79,6 +79,31 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do end end + describe 'pipeline protect' do + subject { step.perform! } + + context 'when ref is protected' do + before do + allow(project).to receive(:protected_for?).with('master').and_return(true) + allow(project).to receive(:protected_for?).with('refs/heads/master').and_return(true) + end + + it 'does not protect the pipeline' do + subject + + expect(pipeline.protected).to eq(true) + end + end + + context 'when ref is not protected' do + it 'does not protect the pipeline' do + subject + + expect(pipeline.protected).to eq(false) + end + end + end + context 'when pipeline has validation errors' do let(:pipeline) do build(:ci_pipeline, project: project, ref: nil) diff --git a/spec/lib/gitlab/ci/pipeline/chain/protect_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/protect_spec.rb deleted file mode 100644 index 8523ebb83fc..00000000000 --- a/spec/lib/gitlab/ci/pipeline/chain/protect_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe Gitlab::Ci::Pipeline::Chain::Protect do - set(:project) { create(:project) } - set(:user) { create(:user) } - - let(:pipeline) do - build(:ci_empty_pipeline, project: project, ref: 'master') - end - - let(:command) do - Gitlab::Ci::Pipeline::Chain::Command.new( - project: project, current_user: user, origin_ref: 'master') - end - - let(:step) { described_class.new(pipeline, command) } - - context 'when the ref is protected' do - before do - allow(project).to receive(:protected_for?).with('master').and_return(true) - - step.perform! - end - - it 'protects the pipeline' do - expect(pipeline.protected).to eq(true) - end - end - - context 'when the ref is not protected' do - before do - allow(project).to receive(:protected_for?).with('master').and_return(false) - - step.perform! - end - - it 'does not protect the pipeline' do - expect(pipeline.protected).to eq(false) - end - end -end |