Commit e559c38b authored by Sean McGivern's avatar Sean McGivern

Merge branch 'lm-deep-stringify-merged-yaml' into 'master'

Makes merged_yaml return deep stringified keys

See merge request gitlab-org/gitlab!54336
parents 8e6f6bef 1743375d
---
title: Returns deep stringified keys for merged_yaml in linting endpoint
merge_request: 54336
author:
type: changed
...@@ -101,7 +101,7 @@ module Gitlab ...@@ -101,7 +101,7 @@ module Gitlab
end end
def merged_yaml def merged_yaml
@ci_config&.to_hash&.to_yaml @ci_config&.to_hash&.deep_stringify_keys&.to_yaml
end end
def variables_with_data def variables_with_data
......
...@@ -92,7 +92,7 @@ RSpec.describe Gitlab::Ci::Lint do ...@@ -92,7 +92,7 @@ RSpec.describe Gitlab::Ci::Lint do
it 'sets merged_config' do it 'sets merged_config' do
root_config = YAML.safe_load(content, [Symbol]) root_config = YAML.safe_load(content, [Symbol])
included_config = YAML.safe_load(included_content, [Symbol]) included_config = YAML.safe_load(included_content, [Symbol])
expected_config = included_config.merge(root_config).except(:include) expected_config = included_config.merge(root_config).except(:include).deep_stringify_keys
expect(subject.merged_yaml).to eq(expected_config.to_yaml) expect(subject.merged_yaml).to eq(expected_config.to_yaml)
end end
......
...@@ -24,7 +24,7 @@ module Gitlab ...@@ -24,7 +24,7 @@ module Gitlab
let(:included_yml) do let(:included_yml) do
YAML.dump( YAML.dump(
another_test: { stage: 'test', script: 'echo 2' } { another_test: { stage: 'test', script: 'echo 2' } }.deep_stringify_keys
) )
end end
......
...@@ -166,7 +166,7 @@ RSpec.describe API::Lint do ...@@ -166,7 +166,7 @@ RSpec.describe API::Lint do
included_config = YAML.safe_load(included_content, [Symbol]) included_config = YAML.safe_load(included_content, [Symbol])
root_config = YAML.safe_load(yaml_content, [Symbol]) root_config = YAML.safe_load(yaml_content, [Symbol])
expected_yaml = included_config.merge(root_config).except(:include).to_yaml expected_yaml = included_config.merge(root_config).except(:include).deep_stringify_keys.to_yaml
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Hash expect(json_response).to be_an Hash
...@@ -246,7 +246,7 @@ RSpec.describe API::Lint do ...@@ -246,7 +246,7 @@ RSpec.describe API::Lint do
let(:dry_run) { false } let(:dry_run) { false }
let(:included_content) do let(:included_content) do
{ another_test: { stage: 'test', script: 'echo 1' } }.to_yaml { another_test: { stage: 'test', script: 'echo 1' } }.deep_stringify_keys.to_yaml
end end
before do before do
...@@ -299,7 +299,7 @@ RSpec.describe API::Lint do ...@@ -299,7 +299,7 @@ RSpec.describe API::Lint do
end end
let(:included_content) do let(:included_content) do
{ another_test: { stage: 'test', script: 'echo 1' } }.to_yaml { another_test: { stage: 'test', script: 'echo 1' } }.deep_stringify_keys.to_yaml
end end
before do before do
...@@ -341,7 +341,7 @@ RSpec.describe API::Lint do ...@@ -341,7 +341,7 @@ RSpec.describe API::Lint do
context 'with invalid .gitlab-ci.yml content' do context 'with invalid .gitlab-ci.yml content' do
let(:yaml_content) do let(:yaml_content) do
{ image: 'ruby:2.7', services: ['postgres'] }.to_yaml { image: 'ruby:2.7', services: ['postgres'] }.deep_stringify_keys.to_yaml
end end
before do before do
...@@ -385,7 +385,7 @@ RSpec.describe API::Lint do ...@@ -385,7 +385,7 @@ RSpec.describe API::Lint do
included_config = YAML.safe_load(included_content, [Symbol]) included_config = YAML.safe_load(included_content, [Symbol])
root_config = YAML.safe_load(yaml_content, [Symbol]) root_config = YAML.safe_load(yaml_content, [Symbol])
expected_yaml = included_config.merge(root_config).except(:include).to_yaml expected_yaml = included_config.merge(root_config).except(:include).deep_stringify_keys.to_yaml
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Hash expect(json_response).to be_an Hash
...@@ -539,7 +539,7 @@ RSpec.describe API::Lint do ...@@ -539,7 +539,7 @@ RSpec.describe API::Lint do
context 'with invalid .gitlab-ci.yml content' do context 'with invalid .gitlab-ci.yml content' do
let(:yaml_content) do let(:yaml_content) do
{ image: 'ruby:2.7', services: ['postgres'] }.to_yaml { image: 'ruby:2.7', services: ['postgres'] }.deep_stringify_keys.to_yaml
end end
context 'when running as dry run' do context 'when running as dry run' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment