summaryrefslogtreecommitdiff
path: root/spec/models/ci/pipeline_spec.rb
diff options
context:
space:
mode:
authorKeith Pope <mute.pop3+gitlab@gmail.com>2016-08-05 10:29:09 +0100
committerKeith Pope <mute.pop3+gitlab@gmail.com>2016-10-08 12:30:47 +0100
commit07365e518330289149dd2135424c49fad19f401d (patch)
tree3a163231f4caa8f62c3fc5f4c0ca606c8ff92749 /spec/models/ci/pipeline_spec.rb
parent28ca8502c254d5c3edfb7ece36fc365e7a715df0 (diff)
downloadgitlab-ce-07365e518330289149dd2135424c49fad19f401d.tar.gz
Add config option to project to allow custom .gitlab-ci.yml location
Diffstat (limited to 'spec/models/ci/pipeline_spec.rb')
-rw-r--r--spec/models/ci/pipeline_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 550a890797e..8d774666d2b 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -403,6 +403,36 @@ describe Ci::Pipeline, models: true do
end
end
+ 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
+ pipeline.ci_yaml_file
+ expect(pipeline.yaml_errors).to eq('Failed to load CI config file')
+ end
+ end
+
describe '#execute_hooks' do
let!(:build_a) { create_build('a', 0) }
let!(:build_b) { create_build('b', 1) }