summaryrefslogtreecommitdiff
path: root/lib/gitlab/visibility_level.rb
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2016-05-24 17:53:53 -0400
committerFelipe Artur <felipefac@gmail.com>2016-05-25 10:57:00 -0400
commit5273335247660465a39ffdcb1c801807e84b3eba (patch)
tree0eba37e98a775cdfccc6ba59ac3e8c86a9e1584b /lib/gitlab/visibility_level.rb
parent9a10205a4fdb79346f087318ec35110b17ba9153 (diff)
downloadgitlab-ce-5273335247660465a39ffdcb1c801807e84b3eba.tar.gz
Fix forks creation when visibility level is restrictedissue_10725
Diffstat (limited to 'lib/gitlab/visibility_level.rb')
-rw-r--r--lib/gitlab/visibility_level.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb
index a1ee1cba216..9462f3368e6 100644
--- a/lib/gitlab/visibility_level.rb
+++ b/lib/gitlab/visibility_level.rb
@@ -32,6 +32,13 @@ module Gitlab
}
end
+ def highest_allowed_level
+ restricted_levels = current_application_settings.restricted_visibility_levels
+
+ allowed_levels = self.values - restricted_levels
+ allowed_levels.max || PRIVATE
+ end
+
def allowed_for?(user, level)
user.is_admin? || allowed_level?(level.to_i)
end