summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-06-28 18:29:14 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-06-28 18:29:14 +0800
commit0d5e6536e7c18d839b1c1da0807aa90ba5be3e06 (patch)
tree6033a74623158d6ce1d5a9cbf3ba493fe6d09243
parent02ff4381979a5148cc17f7b6ea023fd4a1a5bffe (diff)
downloadgitlab-ce-0d5e6536e7c18d839b1c1da0807aa90ba5be3e06.tar.gz
Fix the test and implement missing update
-rw-r--r--app/models/ci/pipeline.rb2
-rw-r--r--spec/models/ci/pipeline_spec.rb18
2 files changed, 18 insertions, 2 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 23b641c334d..3a514718ca8 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -327,6 +327,8 @@ module Ci
@ci_yaml_file = begin
project.repository.gitlab_ci_yml_for(sha, ci_yaml_file_path)
rescue
+ self.yaml_errors =
+ "Failed to load CI/CD config file at #{ci_yaml_file_path}"
nil
end
end
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 8fb6759d3ab..fef40874d95 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -744,31 +744,45 @@ describe Ci::Pipeline, models: true do
describe 'yaml config file resolution' do
let(:project) { FactoryGirl.build(:project) }
-
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
+
it 'uses custom ci config file path when present' do
allow(project).to receive(:ci_config_file) { 'custom/path' }
+
expect(pipeline.ci_yaml_file_path).to eq('custom/path/.gitlab-ci.yml')
end
+
it 'uses root when custom path is nil' do
allow(project).to receive(:ci_config_file) { nil }
+
expect(pipeline.ci_yaml_file_path).to eq('.gitlab-ci.yml')
end
+
it 'uses root when custom path is empty' do
allow(project).to receive(:ci_config_file) { '' }
+
expect(pipeline.ci_yaml_file_path).to eq('.gitlab-ci.yml')
end
+
it 'allows custom filename' do
allow(project).to receive(:ci_config_file) { 'custom/path/.my-config.yml' }
+
expect(pipeline.ci_yaml_file_path).to eq('custom/path/.my-config.yml')
end
+
it 'custom filename must be yml' do
allow(project).to receive(:ci_config_file) { 'custom/path/.my-config.cnf' }
+
expect(pipeline.ci_yaml_file_path).to eq('custom/path/.my-config.cnf/.gitlab-ci.yml')
end
+
it 'reports error if the file is not found' do
+ allow(project).to receive(:ci_config_file) { 'custom' }
+
pipeline.ci_yaml_file
- expect(pipeline.yaml_errors).to eq('Failed to load CI config file')
+
+ expect(pipeline.yaml_errors)
+ .to eq('Failed to load CI/CD config file at custom/.gitlab-ci.yml')
end
end