diff options
3 files changed, 22 insertions, 4 deletions
diff --git a/changelogs/unreleased/georgekoltsov-64311-set-visibility-private-if-internal-restricted.yml b/changelogs/unreleased/georgekoltsov-64311-set-visibility-private-if-internal-restricted.yml new file mode 100644 index 00000000000..18af16e5216 --- /dev/null +++ b/changelogs/unreleased/georgekoltsov-64311-set-visibility-private-if-internal-restricted.yml @@ -0,0 +1,5 @@ +--- +title: Set visibility level 'Private' for restricted 'Internal' imported projects when 'Internal' visibility setting is restricted in admin settings +merge_request: 30522 +author: +type: other diff --git a/doc/user/project/settings/import_export.md b/doc/user/project/settings/import_export.md index 98bcc7cc09f..9b12f7230b7 100644 --- a/doc/user/project/settings/import_export.md +++ b/doc/user/project/settings/import_export.md @@ -116,3 +116,10 @@ For more details on the specific data persisted in a project export, see the 1. Click on **Import project** to begin importing. Your newly imported project page will appear soon. + +NOTE: **Note:** +If use of the `Internal` visibility level +[is restricted](../../../public_access/public_access.md#restricting-the-use-of-public-or-internal-projects), +all imported projects with a visibility of `Internal` are given the +visibility of `Private`, unless they are imported to a group with a +visibility of `Internal`. 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 1d6c8b7e50e..da180988252 100644 --- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb @@ -492,14 +492,12 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do end context 'with restricted internal visibility' do - before do - Gitlab::CurrentSettings.restricted_visibility_levels = [visibility] - end - describe 'internal project' do let(:visibility) { Gitlab::VisibilityLevel::INTERNAL } it 'uses private visibility' do + stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL]) + expect(restorer.restored_project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) end end @@ -537,6 +535,14 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do it 'uses the group visibility' do expect(restorer.restored_project.visibility_level).to eq(group_visibility) end + + context 'with restricted internal visibility' do + it 'uses the group visibility' do + stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL]) + + expect(restorer.restored_project.visibility_level).to eq(group_visibility) + end + end end end end |