From b9d43e27b294e0ac18421e4e0540ba2c5fd80d15 Mon Sep 17 00:00:00 2001 From: drew cimino Date: Tue, 25 Jun 2019 17:05:18 -0400 Subject: Added specs for Ci::Pipeline::Seed::Build - #included? when only: and except: both match --- spec/lib/gitlab/ci/pipeline/seed/build_spec.rb | 57 ++++++++++++++++++++++---- 1 file 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 -- cgit v1.2.1