diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/services/ci/create_pipeline_service/custom_yaml_tags_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/services/ci/create_pipeline_service/custom_yaml_tags_spec.rb')
-rw-r--r-- | spec/services/ci/create_pipeline_service/custom_yaml_tags_spec.rb | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/spec/services/ci/create_pipeline_service/custom_yaml_tags_spec.rb b/spec/services/ci/create_pipeline_service/custom_yaml_tags_spec.rb new file mode 100644 index 00000000000..4cf52223e38 --- /dev/null +++ b/spec/services/ci/create_pipeline_service/custom_yaml_tags_spec.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe Ci::CreatePipelineService do + describe '!reference tags' do + let_it_be(:project) { create(:project, :repository) } + let_it_be(:user) { project.owner } + + let(:ref) { 'refs/heads/master' } + let(:source) { :push } + let(:service) { described_class.new(project, user, { ref: ref }) } + let(:pipeline) { service.execute(source) } + + before do + stub_ci_pipeline_yaml_file(config) + end + + context 'with valid config' do + let(:config) do + <<~YAML + .job-1: + script: + - echo doing step 1 of job 1 + + .job-2: + before_script: + - ls + script: !reference [.job-1, script] + + job: + before_script: !reference [.job-2, before_script] + script: + - echo doing my first step + - !reference [.job-2, script] + - echo doing my last step + YAML + end + + it 'creates a pipeline' do + expect(pipeline).to be_persisted + expect(pipeline.builds.first.options).to match(a_hash_including({ + 'before_script' => ['ls'], + 'script' => [ + 'echo doing my first step', + 'echo doing step 1 of job 1', + 'echo doing my last step' + ] + })) + end + end + + context 'with invalid config' do + let(:config) do + <<~YAML + job-1: + script: + - echo doing step 1 of job 1 + - !reference [job-3, script] + + job-2: + script: + - echo doing step 1 of job 2 + - !reference [job-3, script] + + job-3: + script: + - echo doing step 1 of job 3 + - !reference [job-1, script] + YAML + end + + it 'creates a pipeline without builds' do + expect(pipeline).to be_persisted + expect(pipeline.builds).to be_empty + expect(pipeline.yaml_errors).to eq("!reference [\"job-3\", \"script\"] is part of a circular chain") + end + end + end +end |