Commit e861af40 authored by Douwe Maan's avatar Douwe Maan

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

Fix GitHub project import visibility

See merge request gitlab-org/gitlab-ce!27133
parents 8036416d 15e2b5ad
---
title: Fix GitHub project import visibility
merge_request: 27133
author: Daniel Wyatt
type: fixed
...@@ -37,7 +37,7 @@ module Gitlab ...@@ -37,7 +37,7 @@ module Gitlab
end end
def visibility_level 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 = Gitlab::CurrentSettings.default_project_visibility if Gitlab::CurrentSettings.restricted_visibility_levels.include?(visibility_level)
visibility_level visibility_level
......
...@@ -47,12 +47,22 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do ...@@ -47,12 +47,22 @@ 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 it 'sets project visibility to namespace visibility level' do
repo.private = false repo.private = false
project = service.execute 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
end end
......
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