Commit f774624c authored by lauraMon's avatar lauraMon

Makes merged_yaml return deep stringified keys

* Also updates specs
parent cfe70265
---
title: Returns deep stringified keys for merged_yaml in linting endpoint
merge_request: 54336
author:
type: changed
......@@ -101,7 +101,7 @@ module Gitlab
end
def merged_yaml
@ci_config&.to_hash&.to_yaml
@ci_config&.to_hash&.deep_stringify_keys.to_yaml
end
def variables_with_data
......
......@@ -92,7 +92,7 @@ RSpec.describe Gitlab::Ci::Lint do
it 'sets merged_config' do
root_config = YAML.safe_load(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)
end
......
......@@ -24,7 +24,7 @@ module Gitlab
let(:included_yml) do
YAML.dump(
another_test: { stage: 'test', script: 'echo 2' }
{ another_test: { stage: 'test', script: 'echo 2' } }.deep_stringify_keys
)
end
......
......@@ -166,7 +166,7 @@ RSpec.describe API::Lint do
included_config = YAML.safe_load(included_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(json_response).to be_an Hash
......@@ -246,7 +246,7 @@ RSpec.describe API::Lint do
let(:dry_run) { false }
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
before do
......@@ -299,7 +299,7 @@ RSpec.describe API::Lint do
end
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
before do
......@@ -341,7 +341,7 @@ RSpec.describe API::Lint do
context 'with invalid .gitlab-ci.yml 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
before do
......@@ -385,7 +385,7 @@ RSpec.describe API::Lint do
included_config = YAML.safe_load(included_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(json_response).to be_an Hash
......@@ -539,7 +539,7 @@ RSpec.describe API::Lint do
context 'with invalid .gitlab-ci.yml 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
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