summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-05-25 20:47:46 +0000
committerDouwe Maan <douwe@gitlab.com>2016-05-25 20:47:46 +0000
commit74fb50041568e381513d2a9053d31a714797a0a8 (patch)
tree655cc4c6bb8db89a4d2423e25ed10759426bb4f9 /spec
parent380966e861a3c0cfc1d2884939c6677599690206 (diff)
parent5273335247660465a39ffdcb1c801807e84b3eba (diff)
downloadgitlab-ce-74fb50041568e381513d2a9053d31a714797a0a8.tar.gz
Merge branch 'issue_10725' into 'master'
Fix forks creation when visibility level is restricted fixes #10725 See merge request !4283
Diffstat (limited to 'spec')
-rw-r--r--spec/services/projects/fork_service_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index d1ee60a0aea..31bb7120d84 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -42,6 +42,33 @@ describe Projects::ForkService, services: true do
expect(@to_project.builds_enabled?).to be_truthy
end
end
+
+ context "when project has restricted visibility level" do
+ context "and only one visibility level is restricted" do
+ before do
+ @from_project.update_attributes(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL])
+ end
+
+ it "creates fork with highest allowed level" do
+ forked_project = fork_project(@from_project, @to_user)
+
+ expect(forked_project.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC)
+ end
+ end
+
+ context "and all visibility levels are restricted" do
+ before do
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC, Gitlab::VisibilityLevel::INTERNAL, Gitlab::VisibilityLevel::PRIVATE])
+ end
+
+ it "creates fork with private visibility levels" do
+ forked_project = fork_project(@from_project, @to_user)
+
+ expect(forked_project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
+ end
+ end
+ end
end
describe :fork_to_namespace do