Merge branch '47327-fix-github-project-import-visibility' into 'master'

Fix GitHub project import visibility

See merge request gitlab-org/gitlab-ce!27133
This commit is contained in:
Douwe Maan 2019-04-10 09:10:37 +00:00
commit e861af409d
3 changed files with 19 additions and 4 deletions

View file

@ -0,0 +1,5 @@
---
title: Fix GitHub project import visibility
merge_request: 27133
author: Daniel Wyatt
type: fixed

View file

@ -37,7 +37,7 @@ module Gitlab
end
def visibility_level
visibility_level = repo.private ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::VisibilityLevel::PUBLIC
visibility_level = repo.private ? Gitlab::VisibilityLevel::PRIVATE : @namespace.visibility_level
visibility_level = Gitlab::CurrentSettings.default_project_visibility if Gitlab::CurrentSettings.restricted_visibility_levels.include?(visibility_level)
visibility_level

View file

@ -47,12 +47,22 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do
end
context 'when GitHub project is public' do
it 'sets project visibility to public' do
it 'sets project visibility to namespace visibility level' do
repo.private = false
project = service.execute
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC)
expect(project.visibility_level).to eq(namespace.visibility_level)
end
context 'when importing into a user namespace' do
subject(:service) { described_class.new(repo, repo.name, user.namespace, user, github_access_token: 'asdffg') }
it 'sets project visibility to user namespace visibility level' do
repo.private = false
project = service.execute
expect(project.visibility_level).to eq(user.namespace.visibility_level)
end
end
end