Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/ci/create_pipeline_service/environment_spec.rb')
-rw-r--r--spec/services/ci/create_pipeline_service/environment_spec.rb48
1 files changed, 47 insertions, 1 deletions
diff --git a/spec/services/ci/create_pipeline_service/environment_spec.rb b/spec/services/ci/create_pipeline_service/environment_spec.rb
index 43b5220334c..438cb6ac895 100644
--- a/spec/services/ci/create_pipeline_service/environment_spec.rb
+++ b/spec/services/ci/create_pipeline_service/environment_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Ci::CreatePipelineService do
+RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectness do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:developer) { create(:user) }
@@ -45,5 +45,51 @@ RSpec.describe Ci::CreatePipelineService do
end
end
end
+
+ context 'when variables are dependent on stage name' do
+ let(:config) do
+ <<~YAML
+ deploy-review-app-1:
+ stage: deploy
+ environment: 'test/$CI_JOB_STAGE/1'
+ script:
+ - echo $SCOPED_VARIABLE
+ rules:
+ - if: $SCOPED_VARIABLE == 'my-value-1'
+
+ deploy-review-app-2:
+ stage: deploy
+ script:
+ - echo $SCOPED_VARIABLE
+ environment: 'test/$CI_JOB_STAGE/2'
+ rules:
+ - if: $SCOPED_VARIABLE == 'my-value-2'
+ YAML
+ end
+
+ before do
+ create(:ci_variable, key: 'SCOPED_VARIABLE', value: 'my-value-1', environment_scope: '*', project: project)
+ create(:ci_variable,
+ key: 'SCOPED_VARIABLE',
+ value: 'my-value-2',
+ environment_scope: 'test/deploy/*',
+ project: project
+ )
+ stub_ci_pipeline_yaml_file(config)
+ end
+
+ it 'creates the pipeline successfully', :aggregate_failures do
+ pipeline = subject
+ build = pipeline.builds.first
+
+ expect(pipeline).to be_created_successfully
+ expect(Environment.find_by_name('test/deploy/2')).to be_persisted
+ expect(pipeline.builds.size).to eq(1)
+ expect(build.persisted_environment.name).to eq('test/deploy/2')
+ expect(build.name).to eq('deploy-review-app-2')
+ expect(build.environment).to eq('test/$CI_JOB_STAGE/2')
+ expect(build.variables.to_hash['SCOPED_VARIABLE']).to eq('my-value-2')
+ end
+ end
end
end