diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-06-06 10:54:43 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-06-06 10:54:43 +0000 |
commit | 45444c8e3007d2753349dca4d2c81f7ec90da278 (patch) | |
tree | 95c0e6b0501eaf412163696baae89add7b42ba1e /spec | |
parent | f4b03f0992d39db9f9f77798cb285d732c352074 (diff) | |
parent | c5e44dc5d1a98a92362b93c30342ebf1f972061c (diff) | |
download | gitlab-ce-45444c8e3007d2753349dca4d2c81f7ec90da278.tar.gz |
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
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/legacy_github_import/project_creator_spec.rb | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/spec/lib/gitlab/legacy_github_import/project_creator_spec.rb b/spec/lib/gitlab/legacy_github_import/project_creator_spec.rb index eb1b13704ea..972b17d5b12 100644 --- a/spec/lib/gitlab/legacy_github_import/project_creator_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/project_creator_spec.rb @@ -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 |