summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 832c68243fb..115a2775ffb 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -249,7 +249,7 @@ class Note < ActiveRecord::Base
# When commit notes are rendered on an MR's Discussion page, they are
# displayed in one discussion instead of individually.
# See also `#discussion_id` and `Discussion.override_discussion_id`.
- if noteable && noteable != self.noteable
+ if different_context?(noteable)
OutOfContextDiscussion
else
IndividualNoteDiscussion
@@ -300,6 +300,12 @@ class Note < ActiveRecord::Base
private
+ def different_context?(noteable)
+ return false unless noteable
+
+ noteable.id != noteable_id && noteable.class.name != noteable_type
+ end
+
def keep_around_commit
project.repository.keep_around(self.commit_id)
end