diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-12-20 16:19:54 +0100 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-12-29 11:15:26 +0100 |
commit | 0618487906a8b44eea7cb858aff45a5d5ea4cfff (patch) | |
tree | c6620ca499bba21b35a513ff195260478bd31333 /spec/services | |
parent | 723d788fbef90b270cce1ca1d4bc228c54041eaa (diff) | |
download | gitlab-ce-0618487906a8b44eea7cb858aff45a5d5ea4cfff.tar.gz |
Forking a project to a namespace with lower visibility.bvl-fork-public-project-to-private-namespace
In this case the project will get the minimum between both
visibilities.
If that visibility is restricted, then a lower level will be picked.
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/projects/fork_service_spec.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb index 4057caca2ac..409d5de8d43 100644 --- a/spec/services/projects/fork_service_spec.rb +++ b/spec/services/projects/fork_service_spec.rb @@ -139,10 +139,10 @@ describe Projects::ForkService do stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL]) end - it "creates fork with highest allowed level" do + it "creates fork with lowest level" do forked_project = fork_project(@from_project, @to_user) - expect(forked_project.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC) + expect(forked_project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) end end @@ -209,6 +209,19 @@ describe Projects::ForkService do expect(to_project.errors[:path]).to eq(['has already been taken']) end end + + context 'when the namespace has a lower visibility level than the project' do + it 'creates the project with the lower visibility level' do + public_project = create(:project, :public) + private_group = create(:group, :private) + group_owner = create(:user) + private_group.add_owner(group_owner) + + forked_project = fork_project(public_project, group_owner, namespace: private_group) + + expect(forked_project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) + end + end end end |