summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrew cimino <dcimino@gitlab.com>2019-06-25 17:05:18 -0400
committerdrew cimino <dcimino@gitlab.com>2019-07-11 17:37:59 -0400
commitb9d43e27b294e0ac18421e4e0540ba2c5fd80d15 (patch)
tree1d6db9665e03a50ebb07167f7db921f9c9d29f52
parentd50125a03fffe64cd8976f1c8b2e5b66e5fc5b2d (diff)
downloadgitlab-ce-b9d43e27b294e0ac18421e4e0540ba2c5fd80d15.tar.gz
Added specs for Ci::Pipeline::Seed::Build
- #included? when only: and except: both match
-rw-r--r--spec/lib/gitlab/ci/pipeline/seed/build_spec.rb57
1 files changed, 49 insertions, 8 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
index 7991e2f48b5..633000ec8fe 100644
--- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
@@ -3,14 +3,9 @@ require 'spec_helper'
describe Gitlab::Ci::Pipeline::Seed::Build do
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
+ let(:attributes) { { name: 'rspec', ref: 'master' } }
- let(:attributes) do
- { name: 'rspec', ref: 'master' }
- end
-
- subject do
- described_class.new(pipeline, attributes)
- end
+ subject { described_class.new(pipeline, attributes) }
describe '#attributes' do
it 'returns hash attributes of a build' do
@@ -76,7 +71,7 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
end
end
- describe 'applying only/except policies' do
+ describe 'applying job inclusion policies' do
context 'when no branch policy is specified' do
let(:attributes) { { name: 'rspec' } }
@@ -95,6 +90,12 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
it { is_expected.to be_included }
end
+
+ context 'with both only and except policies' do
+ let(:attributes) { { name: 'rspec', only: { refs: %w(deploy) }, except: { refs: %(deploy) } } }
+
+ it { is_expected.not_to be_included }
+ end
end
context 'when branch regexp policy does not match' do
@@ -109,6 +110,12 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
it { is_expected.to be_included }
end
+
+ context 'with both only and except policies' do
+ let(:attributes) { { name: 'rspec', only: { refs: %w(/^deploy$/) }, except: { refs: %w(/^deploy$/) } } }
+
+ it { is_expected.not_to be_included }
+ end
end
context 'when branch policy matches' do
@@ -123,6 +130,12 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
it { is_expected.not_to be_included }
end
+
+ context 'when using both only and except policies' do
+ let(:attributes) { { name: 'rspec', only: { refs: %w(deploy master) }, except: { refs: %w(deploy master) } } }
+
+ it { is_expected.not_to be_included }
+ end
end
context 'when keyword policy matches' do
@@ -137,6 +150,12 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
it { is_expected.not_to be_included }
end
+
+ context 'when using both only and except policies' do
+ let(:attributes) { { name: 'rspec', only: { refs: %w(branches) }, except: { refs: %(branches) } } }
+
+ it { is_expected.not_to be_included }
+ end
end
context 'when keyword policy does not match' do
@@ -151,6 +170,12 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
it { is_expected.to be_included }
end
+
+ context 'when using both only and except policies' do
+ let(:attributes) { { name: 'rspec', only: { refs: %(tags) }, except: { refs: %(tags) } } }
+
+ it { is_expected.not_to be_included }
+ end
end
context 'with source-keyword policy' do
@@ -239,6 +264,14 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
it { is_expected.not_to be_included }
end
+
+ context 'when using both only and except policies' do
+ let(:attributes) do
+ { name: 'rspec', only: { refs: ["branches@#{pipeline.project_full_path}"] }, except: { refs: ["branches@#{pipeline.project_full_path}"] } }
+ end
+
+ it { is_expected.not_to be_included }
+ end
end
context 'when repository path does not matches' do
@@ -257,6 +290,14 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
it { is_expected.to be_included }
end
+
+ context 'when using both only and except policies' do
+ let(:attributes) do
+ { name: 'rspec', only: { refs: ['branches@fork'] }, except: { refs: ['branches@fork'] } }
+ end
+
+ it { is_expected.not_to be_included }
+ end
end
end
end