From d6b11dafd37e78c12c982c42f274928293cdfa53 Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Thu, 5 Jan 2017 14:36:06 +0100 Subject: Support notes without project --- app/models/ability.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/models/ability.rb') diff --git a/app/models/ability.rb b/app/models/ability.rb index fa8f8bc3a5f..5bad5c17747 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.select { |user| snippet.author == user } + 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. -- cgit v1.2.1 From 0c350b79395d6712c7c4fee649cdbd77aa4052cc Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Fri, 20 Jan 2017 11:28:40 +0100 Subject: address comments --- app/models/ability.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/ability.rb') diff --git a/app/models/ability.rb b/app/models/ability.rb index 5bad5c17747..ad6c588202e 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -29,7 +29,7 @@ class Ability when Snippet::INTERNAL, Snippet::PUBLIC users when Snippet::PRIVATE - users.select { |user| snippet.author == user } + users.include?(snippet.author) ? [snippet.author] : [] end end -- cgit v1.2.1