summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/visibility_level_spec.rb
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-12-20 16:19:54 +0100
committerBob Van Landuyt <bob@vanlanduyt.co>2017-12-29 11:15:26 +0100
commit0618487906a8b44eea7cb858aff45a5d5ea4cfff (patch)
treec6620ca499bba21b35a513ff195260478bd31333 /spec/lib/gitlab/visibility_level_spec.rb
parent723d788fbef90b270cce1ca1d4bc228c54041eaa (diff)
downloadgitlab-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/lib/gitlab/visibility_level_spec.rb')
-rw-r--r--spec/lib/gitlab/visibility_level_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/lib/gitlab/visibility_level_spec.rb b/spec/lib/gitlab/visibility_level_spec.rb
index 48a67773de9..d85dac630b4 100644
--- a/spec/lib/gitlab/visibility_level_spec.rb
+++ b/spec/lib/gitlab/visibility_level_spec.rb
@@ -49,4 +49,31 @@ describe Gitlab::VisibilityLevel do
.to eq([Gitlab::VisibilityLevel::PUBLIC])
end
end
+
+ describe '.allowed_levels' do
+ it 'only includes the levels that arent restricted' do
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL])
+
+ expect(described_class.allowed_levels)
+ .to contain_exactly(described_class::PRIVATE, described_class::PUBLIC)
+ end
+ end
+
+ describe '.closest_allowed_level' do
+ it 'picks INTERNAL instead of PUBLIC if public is restricted' do
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
+
+ expect(described_class.closest_allowed_level(described_class::PUBLIC))
+ .to eq(described_class::INTERNAL)
+ end
+
+ it 'picks PRIVATE if nothing is available' do
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC,
+ Gitlab::VisibilityLevel::INTERNAL,
+ Gitlab::VisibilityLevel::PRIVATE])
+
+ expect(described_class.closest_allowed_level(described_class::PUBLIC))
+ .to eq(described_class::PRIVATE)
+ end
+ end
end