summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-15 12:08:09 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-15 12:08:09 +0000
commit37439afe69efe58e2351d899d231670d945be5e2 (patch)
tree0bb4989879fcc18396c013741a3a21c7cc1cb637 /spec/lib/gitlab
parent8353b844b31ebfa1181014e5a409ba93c22d8ad0 (diff)
downloadgitlab-ce-37439afe69efe58e2351d899d231670d945be5e2.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/api_authentication/sent_through_builder_spec.rb4
-rw-r--r--spec/lib/gitlab/conflict/file_spec.rb6
-rw-r--r--spec/lib/gitlab/github_import/client_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/model_configuration_spec.rb4
-rw-r--r--spec/lib/gitlab/import_export/project/tree_restorer_spec.rb2
-rw-r--r--spec/lib/gitlab/metrics/dashboard/validator_spec.rb52
6 files changed, 9 insertions, 61 deletions
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