Use Github repo visibility during import while respecting restricted visibility levels
This commit is contained in:
parent
d8eea0c4ba
commit
c5e44dc5d1
3 changed files with 44 additions and 7 deletions
6
changelogs/unreleased/47189-github_import_visibility.yml
Normal file
6
changelogs/unreleased/47189-github_import_visibility.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
title: Use Github repo visibility during import while respecting restricted visibility
|
||||
levels
|
||||
merge_request:
|
||||
author:
|
||||
type: fixed
|
|
@ -35,7 +35,10 @@ module Gitlab
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
#
|
||||
|
|
|
@ -44,16 +44,44 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do
|
|||
end
|
||||
|
||||
context 'when GitHub project is public' do
|
||||
before do
|
||||
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
|
||||
it 'sets project visibility to public' do
|
||||
repo.private = false
|
||||
|
||||
project = service.execute
|
||||
|
||||
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL)
|
||||
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
|
||||
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)
|
||||
end
|
||||
|
||||
it 'sets project visibility to the default project visibility' do
|
||||
repo.private = false
|
||||
|
||||
project = service.execute
|
||||
|
||||
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue