From bbb9d492cdbb94a4994e83ac33bae5e500cdfa04 Mon Sep 17 00:00:00 2001 From: Rutger Wessels Date: Tue, 30 Jul 2024 15:21:17 +0200 Subject: [PATCH 1/2] Remove 'disable validation' from Group::RelationTreeRestorer --- lib/gitlab/import_export/group/relation_tree_restorer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitlab/import_export/group/relation_tree_restorer.rb b/lib/gitlab/import_export/group/relation_tree_restorer.rb index da6af1e1c9b4fb..3ae9f67e9017ce 100644 --- a/lib/gitlab/import_export/group/relation_tree_restorer.rb +++ b/lib/gitlab/import_export/group/relation_tree_restorer.rb @@ -178,7 +178,7 @@ def update_params! modify_attributes - Namespace.with_disabled_organization_validation { @importable.save!(touch: false) } + @importable.save!(touch: false) end def filter_attributes(params) -- GitLab From 8d970c8cb2305fe5517a0cf284886fc02ddaa2b9 Mon Sep 17 00:00:00 2001 From: Rutger Wessels Date: Thu, 1 Aug 2024 16:53:20 +0200 Subject: [PATCH 2/2] Use current organization for Import::GitlabGroupsController --- app/controllers/import/gitlab_groups_controller.rb | 4 +--- ee/spec/controllers/projects_controller_spec.rb | 2 +- spec/features/groups/import_export/import_file_spec.rb | 6 +++++- spec/requests/import/gitlab_groups_controller_spec.rb | 8 ++++++-- .../helpers/disable_namespace_organization_validation.yml | 2 -- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/controllers/import/gitlab_groups_controller.rb b/app/controllers/import/gitlab_groups_controller.rb index 5b06649f2717cc..2ac67e9e56d137 100644 --- a/app/controllers/import/gitlab_groups_controller.rb +++ b/app/controllers/import/gitlab_groups_controller.rb @@ -21,9 +21,7 @@ def create ) .with_defaults(organization_id: Current.organization_id) - response = Namespace.with_disabled_organization_validation do - ::Groups::CreateService.new(current_user, group_data).execute - end + response = ::Groups::CreateService.new(current_user, group_data).execute group = response[:group] diff --git a/ee/spec/controllers/projects_controller_spec.rb b/ee/spec/controllers/projects_controller_spec.rb index 8543f6e575e272..4a43fa1edf7a6d 100644 --- a/ee/spec/controllers/projects_controller_spec.rb +++ b/ee/spec/controllers/projects_controller_spec.rb @@ -299,7 +299,7 @@ before do stub_uploads_object_storage(FileUploader) # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/474656 - allow(Gitlab::QueryLimiting).to receive(:threshold).and_return(201) + allow(Gitlab::QueryLimiting).to receive(:threshold).and_return(203) end it 'creates the project from project template', :sidekiq_might_not_need_inline do diff --git a/spec/features/groups/import_export/import_file_spec.rb b/spec/features/groups/import_export/import_file_spec.rb index f66062b9ac3f93..4f7a6880cfb94e 100644 --- a/spec/features/groups/import_export/import_file_spec.rb +++ b/spec/features/groups/import_export/import_file_spec.rb @@ -2,10 +2,14 @@ require 'spec_helper' -RSpec.describe 'Import/Export - Group Import', :js, feature_category: :importers do +RSpec.describe 'Import/Export - Group Import', :with_current_organization, :js, feature_category: :importers do let_it_be(:user) { create(:user) } let_it_be(:import_path) { "#{Dir.tmpdir}/group_import_spec" } + before_all do + current_organization.users << user + end + before do allow_next_instance_of(Gitlab::ImportExport) do |import_export| allow(import_export).to receive(:storage_path).and_return(import_path) diff --git a/spec/requests/import/gitlab_groups_controller_spec.rb b/spec/requests/import/gitlab_groups_controller_spec.rb index 734a4cefc5cfa2..65d7fd7df37c0a 100644 --- a/spec/requests/import/gitlab_groups_controller_spec.rb +++ b/spec/requests/import/gitlab_groups_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Import::GitlabGroupsController, feature_category: :importers do +RSpec.describe Import::GitlabGroupsController, :with_current_organization, feature_category: :importers do include WorkhorseHelpers include_context 'workhorse headers' @@ -21,6 +21,10 @@ stub_uploads_object_storage(ImportExportUploader) end + before_all do + current_organization.users << user + end + after do FileUtils.rm_rf(import_path, secure: true) end @@ -75,7 +79,7 @@ def upload_archive(file, headers = {}, params = {}) context 'when importing to a parent group' do let(:request_params) { { path: 'test-group-import', name: 'test-group-import', parent_id: parent_group.id } } - let(:parent_group) { create(:group) } + let(:parent_group) { create(:group, organization: current_organization) } before do parent_group.add_owner(user) diff --git a/spec/support/helpers/disable_namespace_organization_validation.yml b/spec/support/helpers/disable_namespace_organization_validation.yml index 2b3003d9c160ea..ab11f2437c0748 100644 --- a/spec/support/helpers/disable_namespace_organization_validation.yml +++ b/spec/support/helpers/disable_namespace_organization_validation.yml @@ -46,7 +46,6 @@ - spec/features/admin/admin_groups_spec.rb - spec/features/dashboard/group_spec.rb - spec/features/file_uploads/group_import_spec.rb -- spec/features/groups/import_export/import_file_spec.rb - spec/features/groups_spec.rb - spec/frontend/fixtures/groups.rb - spec/graphql/types/group_type_spec.rb @@ -59,7 +58,6 @@ - spec/lib/gitlab/import/source_user_mapper_spec.rb - spec/models/hooks/system_hook_spec.rb - spec/requests/api/groups_spec.rb -- spec/requests/import/gitlab_groups_controller_spec.rb - spec/services/users/create_service_spec.rb - spec/services/users/registrations_build_service_spec.rb - spec/services/groups/create_service_spec.rb -- GitLab