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:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2017-08-24 14:01:33 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2017-08-31 23:25:25 +0300
commit6ed490401f49a8941dc7a9e3757ec4012f14ef0b (patch)
tree058ba4c324208c486d2a8bd7326bcf0e292b32a7 /spec/models/ci
parente58428382265f02639a7fc8c1bfcc6311564c0d0 (diff)
Implement the implied CI/CD config for AutoDevOps
Behind an application setting, which defaults to false, this commit implements the implied CI/CD config. Which means that in the case we can't find the `.gitlab-ci.yml` on the commit we want to start a pipeline for, we fall back to an implied configuration. For now the Bash template has been copied to `Auto-Devops.gitlab-ci.yml` so the tests actually work. Fixes #34777
Diffstat (limited to 'spec/models/ci')
-rw-r--r--spec/models/ci/pipeline_spec.rb44
1 files changed, 39 insertions, 5 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index b84e3ff18e8..a7e0da04f55 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -784,13 +784,47 @@ describe Ci::Pipeline, :mailer do
end
describe '#ci_yaml_file' do
- it 'reports error if the file is not found' do
- allow(pipeline.project).to receive(:ci_config_path) { 'custom' }
+ let(:implied_yml) { Gitlab::Template::GitlabCiYmlTemplate.find('Auto-DevOps').content }
- pipeline.ci_yaml_file
+ context 'when AutoDevops is enabled' do
+ it 'returns the configuration if found' do
+ allow(pipeline.project.repository).to receive(:gitlab_ci_yml_for)
+ .and_return('config')
- expect(pipeline.yaml_errors)
- .to eq('Failed to load CI/CD config file at custom')
+ expect(pipeline.ci_yaml_file).to be_a(String)
+ expect(pipeline.ci_yaml_file).not_to eq(implied_yml)
+ expect(pipeline.yaml_errors).to be_nil
+ end
+
+ it 'returns the implied configuration when its not found' do
+ allow_any_instance_of(ApplicationSetting)
+ .to receive(:auto_devops_enabled?) { true }
+ allow(pipeline.project).to receive(:ci_config_path) { 'custom' }
+
+ expect(pipeline.ci_yaml_file).to eq(implied_yml)
+ end
+ end
+
+ context 'when AudoDevOps is disabled' do
+ context 'when an invalid path is given' do
+ it 'sets the yaml errors' do
+ allow(pipeline.project).to receive(:ci_config_path) { 'custom' }
+
+ expect(pipeline.ci_yaml_file).to be_nil
+ expect(pipeline.yaml_errors)
+ .to start_with('Failed to load CI/CD config file')
+ end
+ end
+
+ context 'when the config file can be found' do
+ it 'has no yaml_errors' do
+ allow(pipeline.project.repository).to receive(:gitlab_ci_yml_for)
+ .and_return('config')
+
+ expect(pipeline.ci_yaml_file).to eq('config')
+ expect(pipeline.yaml_errors).to be_nil
+ end
+ end
end
end