From e4eba908cd85c3ad7b9861c3edbd3c81623242a0 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 29 Jun 2017 16:19:09 -0500 Subject: Allow commenting on individual commits inside an MR --- app/models/note.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/models/note.rb') diff --git a/app/models/note.rb b/app/models/note.rb index 733bbbc013f..1357e75d907 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -230,10 +230,14 @@ class Note < ActiveRecord::Base for_personal_snippet? end + def commit + project.commit(commit_id) if commit_id.present? + end + # override to return commits, which are not active record def noteable if for_commit? - @commit ||= project.commit(commit_id) + @commit ||= commit else super end -- cgit v1.2.1 From 3d8fbd12b8f234aa62f4b5ceed21076a7afbcd23 Mon Sep 17 00:00:00 2001 From: "micael.bergeron" Date: Mon, 20 Nov 2017 09:02:01 -0500 Subject: add support for commit (in mr) to reference filter --- app/models/note.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/models/note.rb') diff --git a/app/models/note.rb b/app/models/note.rb index 1357e75d907..fb4a52f8c6e 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -405,6 +405,10 @@ class Note < ActiveRecord::Base noteable_object&.touch end + def banzai_render_context(field) + super.merge(noteable: noteable) + end + private def keep_around_commit -- cgit v1.2.1 From 17075a0bdc0c271e9f7a4f25829c0517656d5871 Mon Sep 17 00:00:00 2001 From: "micael.bergeron" Date: Wed, 6 Dec 2017 10:57:10 -0500 Subject: cache the Note#commit method --- app/models/note.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'app/models/note.rb') diff --git a/app/models/note.rb b/app/models/note.rb index fb4a52f8c6e..c4c2ab8e67d 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -231,19 +231,17 @@ class Note < ActiveRecord::Base end def commit - project.commit(commit_id) if commit_id.present? + @commit ||= project.commit(commit_id) if commit_id.present? end # override to return commits, which are not active record def noteable - if for_commit? - @commit ||= commit - else - super - end - # Temp fix to prevent app crash - # if note commit id doesn't exist + return commit if for_commit? + + super rescue + # Temp fix to prevent app crash + # if note commit id doesn't exist nil end -- cgit v1.2.1