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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/lib/gitlab/config
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/lib/gitlab/config')
-rw-r--r--spec/lib/gitlab/config/entry/factory_spec.rb11
-rw-r--r--spec/lib/gitlab/config/loader/yaml_spec.rb47
2 files changed, 54 insertions, 4 deletions
diff --git a/spec/lib/gitlab/config/entry/factory_spec.rb b/spec/lib/gitlab/config/entry/factory_spec.rb
index a614ef56a78..81ca5f2cba1 100644
--- a/spec/lib/gitlab/config/entry/factory_spec.rb
+++ b/spec/lib/gitlab/config/entry/factory_spec.rb
@@ -4,11 +4,14 @@ require 'spec_helper'
describe Gitlab::Config::Entry::Factory do
describe '#create!' do
- class Script < Gitlab::Config::Entry::Node
- include Gitlab::Config::Entry::Validatable
+ before do
+ stub_const('Script', Class.new(Gitlab::Config::Entry::Node))
+ Script.class_eval do
+ include Gitlab::Config::Entry::Validatable
- validations do
- validates :config, array_of_strings: true
+ validations do
+ validates :config, array_of_strings: true
+ end
end
end
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