summaryrefslogtreecommitdiff
path: root/app/models/ability.rb
diff options
context:
space:
mode:
authorRegis <boudinot.regis@yahoo.com>2017-01-25 14:01:44 -0700
committerRegis <boudinot.regis@yahoo.com>2017-01-25 14:01:44 -0700
commitd4b2f4dd8332701c2df0003a213b34abe0163599 (patch)
treeec868cb769c6656bbcb4b42b65710ab72717598e /app/models/ability.rb
parent5348985015cd0f3163ed7617eb86df63396db16b (diff)
parent112f9710b65fe830a058366cde1734a2928764de (diff)
downloadgitlab-ce-pipeline_index_vue_error_state.tar.gz
Merge branch 'master' into pipeline_index_vue_error_statepipeline_index_vue_error_state
Diffstat (limited to 'app/models/ability.rb')
-rw-r--r--app/models/ability.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb
index fa8f8bc3a5f..ad6c588202e 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -22,6 +22,17 @@ class Ability
end
end
+ # Given a list of users and a snippet this method returns the users that can
+ # read the given snippet.
+ def users_that_can_read_personal_snippet(users, snippet)
+ case snippet.visibility_level
+ when Snippet::INTERNAL, Snippet::PUBLIC
+ users
+ when Snippet::PRIVATE
+ users.include?(snippet.author) ? [snippet.author] : []
+ end
+ end
+
# Returns an Array of Issues that can be read by the given user.
#
# issues - The issues to reduce down to those readable by the user.