Skip to content

Commit 5fac46f

Browse files
balasankarcstanhu
andcommitted
Merge branch 'sh-fix-specs-ruby-3.1' into 'master'
Update specs to pass with Ruby 3.0 and 3.1 See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7226 Merged-by: Balasankar 'Balu' C <[email protected]> Approved-by: Clemens Beck <[email protected]> Approved-by: Balasankar 'Balu' C <[email protected]> Reviewed-by: Clemens Beck <[email protected]> Co-authored-by: Stan Hu <[email protected]>
2 parents 9df8bb9 + 7004240 commit 5fac46f

File tree

10 files changed

+14
-18
lines changed

10 files changed

+14
-18
lines changed

spec/chef/cookbooks/gitlab-ee/recipes/geo-secondary_disable_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
let(:chef_run) { ChefSpec::SoloRunner.new(step_into: %w(templatesymlink)).converge('gitlab-ee::default') }
55
let(:database_yml_template) { chef_run.template('/var/opt/gitlab/gitlab-rails/etc/database.yml') }
66
let(:database_yml_file_content) { ChefSpec::Renderer.new(chef_run, database_yml_template).content }
7-
let(:database_yml) { YAML.safe_load(database_yml_file_content, [], [], true, symbolize_names: true) }
7+
let(:database_yml) { YAML.safe_load(database_yml_file_content, aliases: true, symbolize_names: true) }
88

99
before do
1010
allow(Gitlab).to receive(:[]).and_call_original

spec/chef/cookbooks/gitlab-ee/recipes/geo-secondary_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
let(:chef_run) { ChefSpec::SoloRunner.new(step_into: %w(templatesymlink)).converge('gitlab-ee::default') }
55
let(:database_yml_template) { chef_run.template('/var/opt/gitlab/gitlab-rails/etc/database.yml') }
66
let(:database_yml_file_content) { ChefSpec::Renderer.new(chef_run, database_yml_template).content }
7-
let(:database_yml) { YAML.safe_load(database_yml_file_content, [], [], true, symbolize_names: true) }
7+
let(:database_yml) { YAML.safe_load(database_yml_file_content, aliases: true, symbolize_names: true) }
88
let(:default_database_settings) do
99
{
1010
adapter: 'postgresql',

spec/chef/cookbooks/gitlab-kas/recipes/gitlab-kas_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,6 @@ def files
714714
def chef_run_load_yaml_template(chef_run, path)
715715
template = chef_run.template(path)
716716
file_content = ChefSpec::Renderer.new(chef_run, template).content
717-
YAML.safe_load(file_content, [], [], true, symbolize_names: true)
717+
YAML.safe_load(file_content, aliases: true, symbolize_names: true)
718718
end
719719
end

spec/chef/cookbooks/gitlab/recipes/gitlab-rails/click_house_yml_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
let(:chef_run) { ChefSpec::SoloRunner.new(step_into: 'templatesymlink').converge('gitlab::default') }
66
let(:clickhouse_yml_template) { chef_run.template('/var/opt/gitlab/gitlab-rails/etc/click_house.yml') }
77
let(:clickhouse_yml_file_content) { ChefSpec::Renderer.new(chef_run, clickhouse_yml_template).content }
8-
let(:clickhouse_yml) { YAML.safe_load(clickhouse_yml_file_content, [], [], true, symbolize_names: true) }
8+
let(:clickhouse_yml) { YAML.safe_load(clickhouse_yml_file_content, aliases: true, symbolize_names: true) }
99

1010
before do
1111
allow(Gitlab).to receive(:[]).and_call_original

spec/chef/cookbooks/gitlab/recipes/gitlab-rails/database_yml_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
let(:chef_run) { ChefSpec::SoloRunner.new(step_into: 'templatesymlink').converge('gitlab::default') }
66
let(:database_yml_template) { chef_run.template('/var/opt/gitlab/gitlab-rails/etc/database.yml') }
77
let(:database_yml_file_content) { ChefSpec::Renderer.new(chef_run, database_yml_template).content }
8-
let(:database_yml) { YAML.safe_load(database_yml_file_content, [], [], true, symbolize_names: true) }
8+
let(:database_yml) { YAML.safe_load(database_yml_file_content, aliases: true, symbolize_names: true) }
99
let(:default_database_settings) do
1010
{
1111
adapter: 'postgresql',

spec/chef/cookbooks/gitlab/recipes/gitlab-rails_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@
309309
context 'with TLS settings' do
310310
let(:resque_yml_template) { chef_run.template('/var/opt/gitlab/gitlab-rails/etc/resque.yml') }
311311
let(:resque_yml_file_content) { ChefSpec::Renderer.new(chef_run, resque_yml_template).content }
312-
let(:resque_yml) { YAML.safe_load(resque_yml_file_content, [], [], true, symbolize_names: true) }
312+
let(:resque_yml) { YAML.safe_load(resque_yml_file_content, aliases: true, symbolize_names: true) }
313313

314314
before do
315315
stub_gitlab_rb(

spec/chef/cookbooks/gitlab/recipes/mailroom_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
shared_examples 'renders Microsoft Graph config' do
2727
let(:gitlab_yml_template) { chef_run.template('/var/opt/gitlab/gitlab-rails/etc/gitlab.yml') }
2828
let(:gitlab_yml_file_content) { ChefSpec::Renderer.new(chef_run, gitlab_yml_template).content }
29-
let(:gitlab_yml) { YAML.safe_load(gitlab_yml_file_content, [], [], true, symbolize_names: true) }
29+
let(:gitlab_yml) { YAML.safe_load(gitlab_yml_file_content, aliases: true, symbolize_names: true) }
3030
let(:inbox_options) do
3131
{
3232
tenant_id: 'MY-TENANT-ID',
@@ -58,7 +58,7 @@
5858
shared_examples 'configured sidekiq delivery method' do
5959
let(:gitlab_yml_template) { chef_run.template('/var/opt/gitlab/gitlab-rails/etc/gitlab.yml') }
6060
let(:gitlab_yml_file_content) { ChefSpec::Renderer.new(chef_run, gitlab_yml_template).content }
61-
let(:gitlab_yml) { YAML.safe_load(gitlab_yml_file_content, [], [], true, symbolize_names: true) }
61+
let(:gitlab_yml) { YAML.safe_load(gitlab_yml_file_content, aliases: true, symbolize_names: true) }
6262

6363
before do
6464
stub_gitlab_rb(
@@ -81,7 +81,7 @@
8181
shared_examples 'configured webhook delivery method' do
8282
let(:gitlab_yml_template) { chef_run.template('/var/opt/gitlab/gitlab-rails/etc/gitlab.yml') }
8383
let(:gitlab_yml_file_content) { ChefSpec::Renderer.new(chef_run, gitlab_yml_template).content }
84-
let(:gitlab_yml) { YAML.safe_load(gitlab_yml_file_content, [], [], true, symbolize_names: true) }
84+
let(:gitlab_yml) { YAML.safe_load(gitlab_yml_file_content, aliases: true, symbolize_names: true) }
8585

8686
before do
8787
configured_mailroom = config_sections.each_with_object({}) do |config_section, memo|

spec/chef/cookbooks/monitoring/recipes/gitlab-exporter_spec.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@
5252

5353
expect(chef_run).to render_file('/var/opt/gitlab/gitlab-exporter/gitlab-exporter.yml')
5454
.with_content { |content|
55-
# Not disabling this Cop fails the test with:
56-
# Psych::BadAlias: Unknown alias: db_common
57-
settings = YAML.load(content) # rubocop:disable Security/YAMLLoad
55+
settings = YAML.safe_load(content, aliases: true)
5856
expect(settings.dig('server', 'name')).to eq('webrick')
5957
expect(settings.dig('probes', 'database')).not_to be_nil
6058
expect(settings.dig('probes', 'ruby')).not_to be_nil
@@ -109,9 +107,7 @@
109107
it 'populates TLS related settings in config file' do
110108
expect(chef_run).to render_file('/var/opt/gitlab/gitlab-exporter/gitlab-exporter.yml')
111109
.with_content { |content|
112-
# Not disabling this Cop fails the test with:
113-
# Psych::BadAlias: Unknown alias: db_common
114-
settings = YAML.load(content) # rubocop:disable Security/YAMLLoad
110+
settings = YAML.safe_load(content, aliases: true)
115111
expect(settings.dig('server', 'tls_enabled')).to be_truthy
116112
expect(settings.dig('server', 'listen_address')).to eq('0.0.0.0')
117113
expect(settings.dig('server', 'listen_port')).to eq(8443)
@@ -174,7 +170,7 @@
174170
it 'adds tranport options to elasticsearch config' do
175171
expect(chef_run).to render_file('/var/opt/gitlab/gitlab-exporter/gitlab-exporter.yml')
176172
.with_content { |content|
177-
transport_options = YAML.load(content) # rubocop:disable Security/YAMLLoad
173+
transport_options = YAML.safe_load(content, aliases: true)
178174
.dig('probes', 'elasticsearch', 'opts').first['options']
179175
expect(transport_options).to eq({ 'headers' => { 'Authorization' => authorization } })
180176
}

spec/chef/cookbooks/monitoring/recipes/prometheus_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@
383383
let(:chef_run) { ChefSpec::SoloRunner.new(step_into: %w(runit_service)).converge('gitlab::default') }
384384
let(:prometheus_yml_template) { chef_run.file('/var/opt/gitlab/prometheus/prometheus.yml') }
385385
let(:prometheus_yml_file_content) { ChefSpec::Renderer.new(chef_run, prometheus_yml_template).content }
386-
let(:prometheus_yml) { YAML.safe_load(prometheus_yml_file_content, [], [], true, symbolize_names: true) }
386+
let(:prometheus_yml) { YAML.safe_load(prometheus_yml_file_content, aliases: true, symbolize_names: true) }
387387

388388
let(:default_vars) do
389389
{

spec/chef/support/shared_context/gitlab_rails_shared_context.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
let(:chef_run) { ChefSpec::SoloRunner.new(step_into: 'templatesymlink').converge('gitlab::default') }
55
let(:gitlab_yml_template) { chef_run.template('/var/opt/gitlab/gitlab-rails/etc/gitlab.yml') }
66
let(:gitlab_yml_file_content) { ChefSpec::Renderer.new(chef_run, gitlab_yml_template).content }
7-
let(:gitlab_yml) { YAML.safe_load(gitlab_yml_file_content, [], [], true, symbolize_names: true) }
7+
let(:gitlab_yml) { YAML.safe_load(gitlab_yml_file_content, aliases: true, symbolize_names: true) }
88
let(:config_dir) { '/var/opt/gitlab/gitlab-rails/etc/' }
99

1010
before do

0 commit comments

Comments
 (0)