From 37439afe69efe58e2351d899d231670d945be5e2 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 15 Dec 2022 12:08:09 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../sent_through_builder_spec.rb | 4 +- spec/lib/gitlab/conflict/file_spec.rb | 6 +-- spec/lib/gitlab/github_import/client_spec.rb | 2 +- .../import_export/model_configuration_spec.rb | 4 +- .../import_export/project/tree_restorer_spec.rb | 2 +- .../lib/gitlab/metrics/dashboard/validator_spec.rb | 52 ---------------------- 6 files changed, 9 insertions(+), 61 deletions(-) (limited to 'spec/lib/gitlab') diff --git a/spec/lib/gitlab/api_authentication/sent_through_builder_spec.rb b/spec/lib/gitlab/api_authentication/sent_through_builder_spec.rb index 845e317f3aa..aa088a5d6d5 100644 --- a/spec/lib/gitlab/api_authentication/sent_through_builder_spec.rb +++ b/spec/lib/gitlab/api_authentication/sent_through_builder_spec.rb @@ -8,10 +8,10 @@ RSpec.describe Gitlab::APIAuthentication::SentThroughBuilder do let(:locators) { Array.new(3) { double } } it 'adds a strategy for each of locators x resolvers' do - strategies = locators.to_h { |l| [l, []] } + strategies = locators.index_with { [] } described_class.new(strategies, resolvers).sent_through(*locators) - expect(strategies).to eq(locators.to_h { |l| [l, resolvers] }) + expect(strategies).to eq(locators.index_with { resolvers }) end end end diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb index 165305476d2..6ea8e6c6706 100644 --- a/spec/lib/gitlab/conflict/file_spec.rb +++ b/spec/lib/gitlab/conflict/file_spec.rb @@ -30,7 +30,7 @@ RSpec.describe Gitlab::Conflict::File do let(:section_keys) { conflict_file.sections.map { |section| section[:id] }.compact } context 'when resolving everything to the same side' do - let(:resolution_hash) { section_keys.to_h { |key| [key, 'head'] } } + let(:resolution_hash) { section_keys.index_with { 'head' } } let(:resolved_lines) { conflict_file.resolve_lines(resolution_hash) } let(:expected_lines) { conflict_file.lines.reject { |line| line.type == 'old' } } @@ -63,8 +63,8 @@ RSpec.describe Gitlab::Conflict::File do end it 'raises ResolutionError when passed a hash without resolutions for all sections' do - empty_hash = section_keys.to_h { |key| [key, nil] } - invalid_hash = section_keys.to_h { |key| [key, 'invalid'] } + empty_hash = section_keys.index_with { nil } + invalid_hash = section_keys.index_with { 'invalid' } expect { conflict_file.resolve_lines({}) } .to raise_error(Gitlab::Git::Conflict::Resolver::ResolutionError) diff --git a/spec/lib/gitlab/github_import/client_spec.rb b/spec/lib/gitlab/github_import/client_spec.rb index 625212da394..526a8721ff3 100644 --- a/spec/lib/gitlab/github_import/client_spec.rb +++ b/spec/lib/gitlab/github_import/client_spec.rb @@ -679,7 +679,7 @@ RSpec.describe Gitlab::GithubImport::Client do context 'when pagination options present' do it 'searches for repositories via expected query' do expect(client.octokit).to receive(:search_repositories).with( - expected_query, page: 2, per_page: 25 + expected_query, { page: 2, per_page: 25 } ) client.search_repos_by_name('test', { page: 2, per_page: 25 }) diff --git a/spec/lib/gitlab/import_export/model_configuration_spec.rb b/spec/lib/gitlab/import_export/model_configuration_spec.rb index 34591122a97..4f01f470ce7 100644 --- a/spec/lib/gitlab/import_export/model_configuration_spec.rb +++ b/spec/lib/gitlab/import_export/model_configuration_spec.rb @@ -23,8 +23,8 @@ RSpec.describe 'Import/Export model configuration' do # List of current models between models, in the format of # {model: [model_2, model3], ...} def setup_models - model_names.each_with_object({}) do |model_name, hash| - hash[model_name] = associations_for(relation_class_for_name(model_name)) - ['project'] + model_names.index_with do |model_name| + associations_for(relation_class_for_name(model_name)) - ['project'] end end diff --git a/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb index b753746cd8c..2699dc10b18 100644 --- a/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb @@ -768,7 +768,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do it 'overrides project feature access levels' do access_level_keys = ProjectFeature.available_features.map { |feature| ProjectFeature.access_level_attribute(feature) } - disabled_access_levels = access_level_keys.to_h { |item| [item, 'disabled'] } + disabled_access_levels = access_level_keys.index_with { 'disabled' } project.create_import_data(data: { override_params: disabled_access_levels }) diff --git a/spec/lib/gitlab/metrics/dashboard/validator_spec.rb b/spec/lib/gitlab/metrics/dashboard/validator_spec.rb index aaa9daf8fee..fb55b736354 100644 --- a/spec/lib/gitlab/metrics/dashboard/validator_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/validator_spec.rb @@ -143,56 +143,4 @@ RSpec.describe Gitlab::Metrics::Dashboard::Validator do end end end - - describe '#errors' do - context 'valid dashboard schema' do - it 'returns no errors' do - expect(described_class.errors(valid_dashboard)).to eq [] - end - - context 'with duplicate metric_ids' do - it 'returns errors' do - expect(described_class.errors(duplicate_id_dashboard)).to eq [Gitlab::Metrics::Dashboard::Validator::Errors::DuplicateMetricIds.new] - end - end - - context 'with dashboard_path and project' do - subject { described_class.errors(valid_dashboard, dashboard_path: 'test/path.yml', project: project) } - - context 'with no conflicting metric identifiers in db' do - it { is_expected.to eq [] } - end - - context 'with metric identifier present in current dashboard' do - before do - create(:prometheus_metric, - identifier: 'metric_a1', - dashboard_path: 'test/path.yml', - project: project - ) - end - - it { is_expected.to eq [] } - end - - context 'with metric identifier present in another dashboard' do - before do - create(:prometheus_metric, - identifier: 'metric_a1', - dashboard_path: 'some/other/dashboard/path.yml', - project: project - ) - end - - it { is_expected.to eq [Gitlab::Metrics::Dashboard::Validator::Errors::DuplicateMetricIds.new] } - end - end - end - - context 'invalid dashboard schema' do - it 'returns collection of validation errors' do - expect(described_class.errors(invalid_dashboard)).to all be_kind_of(Gitlab::Metrics::Dashboard::Validator::Errors::SchemaValidationError) - end - end - end end -- cgit v1.2.1