Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/import_export')
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml8
-rw-r--r--spec/lib/gitlab/import_export/attributes_permitter_spec.rb1
-rw-r--r--spec/lib/gitlab/import_export/base/relation_object_saver_spec.rb31
-rw-r--r--spec/lib/gitlab/import_export/command_line_util_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/decompressed_archive_size_validator_spec.rb14
-rw-r--r--spec/lib/gitlab/import_export/file_importer_spec.rb3
-rw-r--r--spec/lib/gitlab/import_export/import_test_coverage_spec.rb1
-rw-r--r--spec/lib/gitlab/import_export/json/ndjson_writer_spec.rb11
-rw-r--r--spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb3
-rw-r--r--spec/lib/gitlab/import_export/project/export_task_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/project/tree_restorer_spec.rb2
11 files changed, 36 insertions, 42 deletions
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index 5bbb95b3ea5..d337a37c69f 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -85,6 +85,7 @@ events:
notes:
- award_emoji
- project
+- namespace
- noteable
- author
- updated_by
@@ -103,6 +104,7 @@ note_metadata:
- note
- email_participant
commit_notes:
+- namespace
- award_emoji
- noteable
- author
@@ -621,6 +623,7 @@ project:
- project_members
- project_repository
- users
+- maintainers
- requesters
- namespace_members
- namespace_requesters
@@ -690,7 +693,6 @@ project:
- pool_repository
- kubernetes_namespaces
- error_tracking_setting
-- metrics_setting
- gitlab_slack_application_integration
- github_integration
- protected_environments
@@ -738,6 +740,7 @@ project:
- project_registry
- packages
- package_files
+- package_protection_rules
- rpm_repository_files
- npm_metadata_caches
- packages_cleanup_policy
@@ -823,6 +826,7 @@ project:
- project_state
- security_policy_bots
- target_branch_rules
+- organization
award_emoji:
- awardable
- user
@@ -872,8 +876,6 @@ suggestions:
- note
diff_note_positions:
- note
-metrics_setting:
-- project
protected_environments:
- project
- group
diff --git a/spec/lib/gitlab/import_export/attributes_permitter_spec.rb b/spec/lib/gitlab/import_export/attributes_permitter_spec.rb
index 8089b40cae8..08abd7908d2 100644
--- a/spec/lib/gitlab/import_export/attributes_permitter_spec.rb
+++ b/spec/lib/gitlab/import_export/attributes_permitter_spec.rb
@@ -97,7 +97,6 @@ RSpec.describe Gitlab::ImportExport::AttributesPermitter, feature_category: :imp
:user | true
:author | false
:ci_cd_settings | true
- :metrics_setting | true
:project_badges | true
:pipeline_schedules | true
:error_tracking_setting | true
diff --git a/spec/lib/gitlab/import_export/base/relation_object_saver_spec.rb b/spec/lib/gitlab/import_export/base/relation_object_saver_spec.rb
index e42a1d0ff8b..13d94fdb6fe 100644
--- a/spec/lib/gitlab/import_export/base/relation_object_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/base/relation_object_saver_spec.rb
@@ -27,8 +27,8 @@ RSpec.describe Gitlab::ImportExport::Base::RelationObjectSaver, feature_category
expect { saver.execute }.to change(project.issues, :count).by(1)
end
- context 'when subrelation is present' do
- let(:notes) { build_list(:note, 6, project: project, importing: true) }
+ context 'when subrelation collection is present' do
+ let(:notes) { build_list(:note, 2, project: project, importing: true) }
let(:relation_object) { build(:issue, project: project, notes: notes) }
let(:relation_definition) { { 'notes' => {} } }
@@ -39,7 +39,7 @@ RSpec.describe Gitlab::ImportExport::Base::RelationObjectSaver, feature_category
saver.execute
issue = project.issues.last
- expect(issue.notes.count).to eq(6)
+ expect(issue.notes.count).to eq(2)
end
end
@@ -58,25 +58,10 @@ RSpec.describe Gitlab::ImportExport::Base::RelationObjectSaver, feature_category
end
end
- context 'when subrelation collection count is small' do
- let(:note) { build(:note, project: project, importing: true) }
- let(:relation_object) { build(:issue, project: project, notes: [note]) }
- let(:relation_definition) { { 'notes' => {} } }
-
- it 'saves subrelation as part of the relation object itself' do
- expect(relation_object.notes).not_to receive(:<<)
-
- saver.execute
-
- issue = project.issues.last
- expect(issue.notes.count).to eq(1)
- end
- end
-
context 'when some subrelations are invalid' do
- let(:notes) { build_list(:note, 5, project: project, importing: true) }
+ let(:note) { build(:note, project: project, importing: true) }
let(:invalid_note) { build(:note) }
- let(:relation_object) { build(:issue, project: project, notes: notes + [invalid_note]) }
+ let(:relation_object) { build(:issue, project: project, notes: [note, invalid_note]) }
let(:relation_definition) { { 'notes' => {} } }
it 'saves valid subrelations and logs invalid subrelation' do
@@ -88,7 +73,7 @@ RSpec.describe Gitlab::ImportExport::Base::RelationObjectSaver, feature_category
issue = project.issues.last
expect(invalid_note.persisted?).to eq(false)
- expect(issue.notes.count).to eq(5)
+ expect(issue.notes.count).to eq(1)
end
context 'when invalid subrelation can still be persisted' do
@@ -112,14 +97,14 @@ RSpec.describe Gitlab::ImportExport::Base::RelationObjectSaver, feature_category
let(:relation_key) { 'labels' }
let(:relation_definition) { { 'priorities' => {} } }
let(:importable) { create(:group) }
- let(:valid_priorities) { build_list(:label_priority, 5, importing: true) }
+ let(:valid_priorities) { [build(:label_priority, importing: true)] }
let(:invalid_priority) { build(:label_priority, priority: -1) }
let(:relation_object) { build(:group_label, group: importable, title: 'test', priorities: valid_priorities + [invalid_priority]) }
it 'saves relation without invalid subrelations' do
saver.execute
- expect(importable.labels.last.priorities.count).to eq(5)
+ expect(importable.labels.last.priorities.count).to eq(1)
end
end
end
diff --git a/spec/lib/gitlab/import_export/command_line_util_spec.rb b/spec/lib/gitlab/import_export/command_line_util_spec.rb
index 8ed3a60d7fc..76a35d07c7f 100644
--- a/spec/lib/gitlab/import_export/command_line_util_spec.rb
+++ b/spec/lib/gitlab/import_export/command_line_util_spec.rb
@@ -203,7 +203,7 @@ RSpec.describe Gitlab::ImportExport::CommandLineUtil, feature_category: :importe
it 'throws a blocked url error' do
Tempfile.create('test') do |file|
- expect { subject.download(url, file.path) }.to raise_error((Gitlab::HTTP::BlockedUrlError))
+ expect { subject.download(url, file.path) }.to raise_error(Gitlab::HTTP::BlockedUrlError)
end
end
diff --git a/spec/lib/gitlab/import_export/decompressed_archive_size_validator_spec.rb b/spec/lib/gitlab/import_export/decompressed_archive_size_validator_spec.rb
index aceea70be92..04e25dee905 100644
--- a/spec/lib/gitlab/import_export/decompressed_archive_size_validator_spec.rb
+++ b/spec/lib/gitlab/import_export/decompressed_archive_size_validator_spec.rb
@@ -13,13 +13,13 @@ RSpec.describe Gitlab::ImportExport::DecompressedArchiveSizeValidator, feature_c
FileUtils.rm(filepath)
end
- subject { described_class.new(archive_path: filepath, max_bytes: max_bytes) }
+ subject { described_class.new(archive_path: filepath) }
describe '#valid?' do
- let(:max_bytes) { 1 }
-
context 'when file does not exceed allowed decompressed size' do
- let(:max_bytes) { 20 }
+ before do
+ stub_application_setting(max_decompressed_archive_size: 20)
+ end
it 'returns true' do
expect(subject.valid?).to eq(true)
@@ -35,6 +35,10 @@ RSpec.describe Gitlab::ImportExport::DecompressedArchiveSizeValidator, feature_c
end
context 'when file exceeds allowed decompressed size' do
+ before do
+ stub_application_setting(max_decompressed_archive_size: 0.000001)
+ end
+
it 'logs error message returns false' do
expect(Gitlab::Import::Logger)
.to receive(:info)
@@ -93,7 +97,7 @@ RSpec.describe Gitlab::ImportExport::DecompressedArchiveSizeValidator, feature_c
end
context 'when timeout occurs' do
- let(:error_message) { 'Timeout reached during archive decompression' }
+ let(:error_message) { 'Timeout of 210 seconds reached during archive decompression' }
let(:exception) { Timeout::Error }
include_examples 'logs raised exception and terminates validator process group'
diff --git a/spec/lib/gitlab/import_export/file_importer_spec.rb b/spec/lib/gitlab/import_export/file_importer_spec.rb
index d449446d7be..ef118d2987c 100644
--- a/spec/lib/gitlab/import_export/file_importer_spec.rb
+++ b/spec/lib/gitlab/import_export/file_importer_spec.rb
@@ -198,8 +198,7 @@ RSpec.describe Gitlab::ImportExport::FileImporter, feature_category: :importers
context 'when validate_import_decompressed_archive_size feature flag is enabled' do
before do
stub_feature_flags(validate_import_decompressed_archive_size: true)
-
- allow(Gitlab::ImportExport::DecompressedArchiveSizeValidator).to receive(:max_bytes).and_return(1)
+ stub_application_setting(max_decompressed_archive_size: 0.000001)
end
it 'returns false and sets an error on shared' do
diff --git a/spec/lib/gitlab/import_export/import_test_coverage_spec.rb b/spec/lib/gitlab/import_export/import_test_coverage_spec.rb
index 1d3fc764b50..09a2417ce1e 100644
--- a/spec/lib/gitlab/import_export/import_test_coverage_spec.rb
+++ b/spec/lib/gitlab/import_export/import_test_coverage_spec.rb
@@ -48,7 +48,6 @@ RSpec.describe 'Test coverage of the Project Import', feature_category: :importe
project.ci_pipelines.notes.events.push_event_payload
project.protected_branches.unprotect_access_levels
project.prometheus_metrics
- project.metrics_setting
project.boards.lists.label.priorities
project.service_desk_setting
project.security_setting
diff --git a/spec/lib/gitlab/import_export/json/ndjson_writer_spec.rb b/spec/lib/gitlab/import_export/json/ndjson_writer_spec.rb
index 452d63d548e..486d179ae05 100644
--- a/spec/lib/gitlab/import_export/json/ndjson_writer_spec.rb
+++ b/spec/lib/gitlab/import_export/json/ndjson_writer_spec.rb
@@ -2,7 +2,7 @@
require "spec_helper"
-RSpec.describe Gitlab::ImportExport::Json::NdjsonWriter do
+RSpec.describe Gitlab::ImportExport::Json::NdjsonWriter, feature_category: :importers do
include ImportExport::CommonUtil
let(:path) { "#{Dir.tmpdir}/ndjson_writer_spec/tree" }
@@ -35,13 +35,18 @@ RSpec.describe Gitlab::ImportExport::Json::NdjsonWriter do
end
context "when single relation is already serialized" do
- it "raise exception" do
+ it "appends to the existing file" do
values = [{ "key" => "value_1", "key_1" => "value_1" }, { "key" => "value_2", "key_1" => "value_2" }]
relation = "relation"
file_path = File.join(path, exportable_path, "#{relation}.ndjson")
subject.write_relation(exportable_path, relation, values[0])
- expect { subject.write_relation(exportable_path, relation, values[1]) }.to raise_exception("The #{file_path} already exist")
+ expect { subject.write_relation(exportable_path, relation, values[1]) }.not_to raise_exception
+
+ file_data = File.read(file_path)
+
+ expect(file_data).to include(values[0].to_json)
+ expect(file_data).to include(values[1].to_json)
end
end
end
diff --git a/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb b/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb
index f4c9189030b..e5058e029c8 100644
--- a/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb
+++ b/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb
@@ -70,8 +70,9 @@ RSpec.describe Gitlab::ImportExport::Json::StreamingSerializer, feature_category
create_list(:issue, 3, :with_desc_relative_position, project: exportable ) # ascending ids, descending position
end
- it 'calls json_writer.write_relation_array with proper params' do
+ it 'calls json_writer.write_relation_array with proper params and clears SafeRequestStore' do
expect(json_writer).to receive(:write_relation_array).with(exportable_path, :issues, array_including(issue.to_json))
+ expect(Gitlab::SafeRequestStore).to receive(:clear!)
subject.execute
end
diff --git a/spec/lib/gitlab/import_export/project/export_task_spec.rb b/spec/lib/gitlab/import_export/project/export_task_spec.rb
index 95971d08175..0837874526a 100644
--- a/spec/lib/gitlab/import_export/project/export_task_spec.rb
+++ b/spec/lib/gitlab/import_export/project/export_task_spec.rb
@@ -2,7 +2,7 @@
require 'rake_helper'
-RSpec.describe Gitlab::ImportExport::Project::ExportTask, :silence_stdout do
+RSpec.describe Gitlab::ImportExport::Project::ExportTask, :silence_stdout, feature_category: :importers do
let_it_be(:username) { 'root' }
let(:namespace_path) { username }
let_it_be(:user) { create(:user, username: username) }
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 47003707172..c83cfb0e2f5 100644
--- a/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb
@@ -467,7 +467,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer, feature_category: :i
aggregate_failures do
expect(release.tag).to eq('release-1.0')
- expect(release.author_id).to eq(User.select(:id).ghost.id)
+ expect(release.author_id).to eq(Users::Internal.ghost.id)
end
end