summaryrefslogtreecommitdiff
path: root/app/helpers/notes_helper.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-06-29 06:11:42 -0700
committerStan Hu <stanhu@gmail.com>2016-06-29 13:42:15 -0700
commit20688cdf0711f0d7d70abdf01db5a4f3a0671c6c (patch)
treed8eb4c8a17f2a2f19e1b3275f4aacf167796500f /app/helpers/notes_helper.rb
parent8c29b0b06554eb9549fe9bd2f33e80ce149752fd (diff)
downloadgitlab-ce-20688cdf0711f0d7d70abdf01db5a4f3a0671c6c.tar.gz
Be explicit which project and user ID are memoized
Diffstat (limited to 'app/helpers/notes_helper.rb')
-rw-r--r--app/helpers/notes_helper.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb
index 80d588aaf5e..e85ba76887d 100644
--- a/app/helpers/notes_helper.rb
+++ b/app/helpers/notes_helper.rb
@@ -71,10 +71,12 @@ module NotesHelper
end
def note_max_access_for_user(note)
- user_id = note.author.id
- project = note.project
- @max_access_by_user_id ||= Hash.new { |hash, key| hash[key] = project.team.human_max_access(key) }
+ @max_access_by_user_id ||= Hash.new do |hash, key|
+ project = key[:project]
+ hash[key] = project.team.human_max_access(key[:user_id])
+ end
- @max_access_by_user_id[user_id]
+ full_key = { project: note.project, user_id: note.author_id }
+ @max_access_by_user_id[full_key]
end
end