diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-24 09:25:10 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-24 09:25:10 +0300 |
commit | 823970b570463bb011fbdc1117a1450310763da0 (patch) | |
tree | 3ef133909a5abeb4889daeb792b4d48c1586314c | |
parent | 1f320edb7721bcc86d26add7ba3fcbd185a1ca06 (diff) |
Fix ci config cache validation in legacy processor
-rw-r--r-- | lib/ci/gitlab_ci_yaml_processor.rb | 4 | ||||
-rw-r--r-- | spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 15 |
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index e4710195687..33492775fe1 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -127,8 +127,8 @@ module Ci def validate_global_cache! @cache.keys.each do |key| - unless ALLOWED_CACHE_KEYS.include? key - raise ValidationError, "#{name} cache unknown parameter #{key}" + unless ALLOWED_CACHE_KEYS.include?(key) + raise ValidationError, "Cache config has unknown parameter: #{key}" end end diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 3f732d2ca2a..6ef6a59f186 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -591,7 +591,20 @@ module Ci end end - describe "Caches" do + describe 'cache' do + context 'when cache definition has unknown keys' do + it 'raises relevant validation error' do + config = YAML.dump( + { cache: { untracked: true, invalid: 'key' }, + rspec: { script: 'rspec' } }) + + expect { GitlabCiYamlProcessor.new(config) }.to raise_error( + GitlabCiYamlProcessor::ValidationError, + 'Cache config has unknown parameter: invalid' + ) + end + end + it "returns cache when defined globally" do config = YAML.dump({ cache: { paths: ["logs/", "binaries/"], untracked: true, key: 'key' }, |