diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-13 15:08:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-13 15:08:04 +0300 |
commit | eb30dd6e28f6fc9eb8021d205f6ed84511f001e2 (patch) | |
tree | 9557e4782c762f4d08f57c9e04991bf988695085 /spec/lib/gitlab/ci | |
parent | c3ad57034cc1cbd6d0ad02de7ac57f6004440c83 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r-- | spec/lib/gitlab/ci/build/policy/refs_spec.rb | 28 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb | 53 |
2 files changed, 81 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/build/policy/refs_spec.rb b/spec/lib/gitlab/ci/build/policy/refs_spec.rb index 8fc1e0a4e88..c32fdc5c72e 100644 --- a/spec/lib/gitlab/ci/build/policy/refs_spec.rb +++ b/spec/lib/gitlab/ci/build/policy/refs_spec.rb @@ -98,6 +98,34 @@ describe Gitlab::Ci::Build::Policy::Refs do .not_to be_satisfied_by(pipeline) end end + + context 'when source is pipeline' do + let(:pipeline) { build_stubbed(:ci_pipeline, source: :pipeline) } + + it 'is satisfied with only: pipelines' do + expect(described_class.new(%w[pipelines])) + .to be_satisfied_by(pipeline) + end + + it 'is satisfied with only: pipeline' do + expect(described_class.new(%w[pipeline])) + .to be_satisfied_by(pipeline) + end + end + + context 'when source is parent_pipeline' do + let(:pipeline) { build_stubbed(:ci_pipeline, source: :parent_pipeline) } + + it 'is satisfied with only: parent_pipelines' do + expect(described_class.new(%w[parent_pipelines])) + .to be_satisfied_by(pipeline) + end + + it 'is satisfied with only: parent_pipeline' do + expect(described_class.new(%w[parent_pipeline])) + .to be_satisfied_by(pipeline) + end + end end context 'when matching a ref by a regular expression' do diff --git a/spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb index aaea044595f..4c4359ad5d2 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb @@ -15,6 +15,42 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do stub_feature_flags(ci_root_config_content: false) end + context 'when bridge job is passed in as parameter' do + let(:ci_config_path) { nil } + let(:bridge) { create(:ci_bridge) } + + before do + command.bridge = bridge + end + + context 'when bridge job has downstream yaml' do + before do + allow(bridge).to receive(:yaml_for_downstream).and_return('the-yaml') + end + + it 'returns the content already available in command' do + subject.perform! + + expect(pipeline.config_source).to eq 'bridge_source' + expect(command.config_content).to eq 'the-yaml' + end + end + + context 'when bridge job does not have downstream yaml' do + before do + allow(bridge).to receive(:yaml_for_downstream).and_return(nil) + end + + it 'returns the next available source' do + subject.perform! + + expect(pipeline.config_source).to eq 'auto_devops_source' + template = Gitlab::Template::GitlabCiYmlTemplate.find('Beta/Auto-DevOps') + expect(command.config_content).to eq(template.content) + end + end + end + context 'when config is defined in a custom path in the repository' do let(:ci_config_path) { 'path/to/config.yml' } @@ -135,6 +171,23 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do end end + context 'when bridge job is passed in as parameter' do + let(:ci_config_path) { nil } + let(:bridge) { create(:ci_bridge) } + + before do + command.bridge = bridge + allow(bridge).to receive(:yaml_for_downstream).and_return('the-yaml') + end + + it 'returns the content already available in command' do + subject.perform! + + expect(pipeline.config_source).to eq 'bridge_source' + expect(command.config_content).to eq 'the-yaml' + end + end + context 'when config is defined in a custom path in the repository' do let(:ci_config_path) { 'path/to/config.yml' } let(:config_content_result) do |