diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-08-03 15:32:00 -0700 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-08-03 15:32:00 -0700 |
commit | 538e66d71c0f7125cc62ea51480668ba8b342544 (patch) | |
tree | d27f667dbe404ce406e2ac6b3a901b87ff93da47 /app/models/ability.rb | |
parent | 3ccb27c0c79ef92585a901de32339948319cf068 (diff) | |
parent | 8890376f0f72f713a7530bd7989e71442c69dc91 (diff) | |
download | gitlab-ce-538e66d71c0f7125cc62ea51480668ba8b342544.tar.gz |
Merge branch 'master' into diff-line-comment-vuejs
# Conflicts:
# app/models/discussion.rb
# db/schema.rb
Diffstat (limited to 'app/models/ability.rb')
-rw-r--r-- | app/models/ability.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb index 5075076c27b..c9d4c4dd03b 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -47,6 +47,16 @@ class Ability 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. + # user - The User for which to check the issues + def issues_readable_by_user(issues, user = nil) + return issues if user && user.admin? + + issues.select { |issue| issue.visible_to_user?(user) } + end + # List of possible abilities for anonymous user def anonymous_abilities(user, subject) if subject.is_a?(PersonalSnippet) |