summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-12-08 10:50:10 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-12-08 10:50:10 +0100
commitb30e0e0691716c2ef0b858b81dd5cef8d4728c59 (patch)
tree658af97734ba537da94ed1156f108248cfaad952 /spec
parentfe62860e05ca6e3ef7125fe92fdf52cd6f7b63df (diff)
downloadgitlab-ce-b30e0e0691716c2ef0b858b81dd5cef8d4728c59.tar.gz
Fix invalid pipeline build chain tag evaluation
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/build_spec.rb37
-rw-r--r--spec/services/ci/create_pipeline_service_spec.rb20
2 files changed, 55 insertions, 2 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
index 0f1d72080c5..ff90d3f10a4 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
@@ -21,31 +21,64 @@ describe Gitlab::Ci::Pipeline::Chain::Build do
before do
stub_repository_ci_yaml_file(sha: anything)
-
- step.perform!
end
it 'never breaks the chain' do
+ step.perform!
+
expect(step.break?).to be false
end
it 'fills pipeline object with data' do
+ step.perform!
+
expect(pipeline.sha).not_to be_empty
expect(pipeline.sha).to eq project.commit.id
expect(pipeline.ref).to eq 'master'
+ expect(pipeline.tag).to be false
expect(pipeline.user).to eq user
expect(pipeline.project).to eq project
end
it 'sets a valid config source' do
+ step.perform!
+
expect(pipeline.repository_source?).to be true
end
it 'returns a valid pipeline' do
+ step.perform!
+
expect(pipeline).to be_valid
end
it 'does not persist a pipeline' do
+ step.perform!
+
expect(pipeline).not_to be_persisted
end
+
+ context 'when pipeline is running for a tag' do
+ let(:command) do
+ double('command', source: :push,
+ origin_ref: 'mytag',
+ checkout_sha: project.commit.id,
+ after_sha: nil,
+ before_sha: nil,
+ trigger_request: nil,
+ schedule: nil,
+ project: project,
+ current_user: user)
+ end
+
+ before do
+ allow(step).to receive(:tag_exists?).and_return(true)
+
+ step.perform!
+ end
+
+ it 'correctly indicated that this is a tagged pipeline' do
+ expect(pipeline).to be_tag
+ end
+ end
end
diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb
index b0de8d447a2..be4abf11cf4 100644
--- a/spec/services/ci/create_pipeline_service_spec.rb
+++ b/spec/services/ci/create_pipeline_service_spec.rb
@@ -518,5 +518,25 @@ describe Ci::CreatePipelineService do
end
end
end
+
+ context 'when pipelie is running for a tag' do
+ before do
+ allow_any_instance_of(Repository)
+ .to receive(:tag_exists?).and_return(false)
+ allow_any_instance_of(Repository)
+ .to receive(:tag_exists?).with('refs/tags/mytag').and_return(true)
+
+ config = YAML.dump(test: { script: 'test', only: ['branches'] },
+ deploy: { script: 'deploy', only: ['tags'] })
+
+ stub_ci_pipeline_yaml_file(config)
+ end
+
+ it 'creates a tagged pipeline' do
+ pipeline = execute_service(ref: 'mytag')
+
+ expect(pipeline.tag?).to be true
+ end
+ end
end
end