diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-15 18:08:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-15 18:08:20 +0300 |
commit | 4774fa00b74a9248b2d14fc424a8c2f1abb0a0de (patch) | |
tree | 1fe6da0110394a038cdd0c7ddb2b7bd2c528ff01 /spec/lib/gitlab/config | |
parent | 67441623767b3084d594288408bb078b2eb9f83e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/config')
-rw-r--r-- | spec/lib/gitlab/config/loader/yaml_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/lib/gitlab/config/loader/yaml_spec.rb b/spec/lib/gitlab/config/loader/yaml_spec.rb index a52c1c362e1..623fe927233 100644 --- a/spec/lib/gitlab/config/loader/yaml_spec.rb +++ b/spec/lib/gitlab/config/loader/yaml_spec.rb @@ -5,6 +5,16 @@ require 'spec_helper' describe Gitlab::Config::Loader::Yaml do let(:loader) { described_class.new(yml) } + let(:yml) do + <<~YAML + image: 'ruby:2.7' + texts: + nested_key: 'value1' + more_text: + more_nested_key: 'value2' + YAML + end + context 'when yaml syntax is correct' do let(:yml) { 'image: ruby:2.7' } @@ -61,6 +71,15 @@ describe Gitlab::Config::Loader::Yaml do expect(loader).not_to be_valid end end + + describe '#load_raw!' do + it 'raises error' do + expect { loader.load_raw! }.to raise_error( + Gitlab::Config::Loader::FormatError, + 'Invalid configuration format' + ) + end + end end # Prevent Billion Laughs attack: https://gitlab.com/gitlab-org/gitlab-foss/issues/56018 @@ -123,4 +142,32 @@ describe Gitlab::Config::Loader::Yaml do end end end + + describe '#load_raw!' do + it 'loads keys as strings' do + expect(loader.load_raw!).to eq( + 'image' => 'ruby:2.7', + 'texts' => { + 'nested_key' => 'value1', + 'more_text' => { + 'more_nested_key' => 'value2' + } + } + ) + end + end + + describe '#load!' do + it 'symbolizes keys' do + expect(loader.load!).to eq( + image: 'ruby:2.7', + texts: { + nested_key: 'value1', + more_text: { + more_nested_key: 'value2' + } + } + ) + end + end end |