Commit 45444c8e authored by Douwe Maan's avatar Douwe Maan

Merge branch '47189-github_import_visibility' into 'master'

Use Github repo visibility during import while respecting restricted visibility levels

Closes #47189

See merge request gitlab-org/gitlab-ce!19450
parents f4b03f09 c5e44dc5
---
title: Use Github repo visibility during import while respecting restricted visibility
levels
merge_request:
author:
type: fixed
...@@ -35,7 +35,10 @@ module Gitlab ...@@ -35,7 +35,10 @@ module Gitlab
end end
def visibility_level def visibility_level
repo.private ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::CurrentSettings.default_project_visibility visibility_level = repo.private ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC
visibility_level = Gitlab::CurrentSettings.default_project_visibility if Gitlab::CurrentSettings.restricted_visibility_levels.include?(visibility_level)
visibility_level
end end
# #
......
...@@ -44,7 +44,34 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do ...@@ -44,7 +44,34 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do
end end
context 'when GitHub project is public' do context 'when GitHub project is public' do
it 'sets project visibility to public' do
repo.private = false
project = service.execute
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
end
context 'when visibility level is restricted' do
context 'when GitHub project is private' do
before do before do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PRIVATE])
allow_any_instance_of(ApplicationSetting).to receive(:default_project_visibility).and_return(Gitlab::VisibilityLevel::INTERNAL)
end
it 'sets project visibility to the default project visibility' do
repo.private = true
project = service.execute
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
end
context 'when GitHub project is public' do
before do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
allow_any_instance_of(ApplicationSetting).to receive(:default_project_visibility).and_return(Gitlab::VisibilityLevel::INTERNAL) allow_any_instance_of(ApplicationSetting).to receive(:default_project_visibility).and_return(Gitlab::VisibilityLevel::INTERNAL)
end end
...@@ -56,6 +83,7 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do ...@@ -56,6 +83,7 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL) expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL)
end end
end end
end
context 'when GitHub project has wiki' do context 'when GitHub project has wiki' do
it 'does not create the wiki repository' do it 'does not create the wiki repository' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment