summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-06-20 15:55:31 +0000
committerRémy Coutable <remy@rymai.me>2017-06-20 15:55:31 +0000
commit639133fc44fcbee97f4f79944bbc6668d8c5c957 (patch)
tree7a7d587959c709f53458f65c7e58269c9bf8c2f7 /spec/lib/gitlab
parente5d416abb8c57f15306964c27793001deb7f4f7c (diff)
parentc9e277ee01b05da7e359459a0a25bdd9bc7dbca8 (diff)
downloadgitlab-ce-639133fc44fcbee97f4f79944bbc6668d8c5c957.tar.gz
Merge branch 'refactor-projects-finder-init-collection' into 'master'
Refactor ProjectsFinder#init_collection and GroupProjectsFinder#init_collection Closes #33632 See merge request !12135
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/visibility_level_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/lib/gitlab/visibility_level_spec.rb b/spec/lib/gitlab/visibility_level_spec.rb
index 3255c6f1ef7..a8f21803ec7 100644
--- a/spec/lib/gitlab/visibility_level_spec.rb
+++ b/spec/lib/gitlab/visibility_level_spec.rb
@@ -18,4 +18,35 @@ describe Gitlab::VisibilityLevel, lib: true do
expect(described_class.level_value(100)).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
end
+
+ describe '.levels_for_user' do
+ it 'returns all levels for an admin' do
+ user = double(:user, admin?: true)
+
+ expect(described_class.levels_for_user(user)).
+ to eq([Gitlab::VisibilityLevel::PRIVATE,
+ Gitlab::VisibilityLevel::INTERNAL,
+ Gitlab::VisibilityLevel::PUBLIC])
+ end
+
+ it 'returns INTERNAL and PUBLIC for internal users' do
+ user = double(:user, admin?: false, external?: false)
+
+ expect(described_class.levels_for_user(user)).
+ to eq([Gitlab::VisibilityLevel::INTERNAL,
+ Gitlab::VisibilityLevel::PUBLIC])
+ end
+
+ it 'returns PUBLIC for external users' do
+ user = double(:user, admin?: false, external?: true)
+
+ expect(described_class.levels_for_user(user)).
+ to eq([Gitlab::VisibilityLevel::PUBLIC])
+ end
+
+ it 'returns PUBLIC when no user is given' do
+ expect(described_class.levels_for_user).
+ to eq([Gitlab::VisibilityLevel::PUBLIC])
+ end
+ end
end