summaryrefslogtreecommitdiff
path: root/app/models/discussion.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-07-28 21:14:45 -0600
committerDouwe Maan <douwe@selenight.nl>2016-07-28 21:14:45 -0600
commitd9a949c17c29c8531b2b0a1c227ab0b3341f0ba3 (patch)
tree16443fec66c0507d908c588a23f3b8cbfddf3dc1 /app/models/discussion.rb
parent1bee660b96d7a84cfcc4a274c68cbe0fba4b5fa5 (diff)
downloadgitlab-ce-d9a949c17c29c8531b2b0a1c227ab0b3341f0ba3.tar.gz
Use correct user for 'Discussion resolved by...'
Diffstat (limited to 'app/models/discussion.rb')
-rw-r--r--app/models/discussion.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/models/discussion.rb b/app/models/discussion.rb
index 3efa2c0649f..88de62d19e0 100644
--- a/app/models/discussion.rb
+++ b/app/models/discussion.rb
@@ -21,7 +21,8 @@ class Discussion
delegate :resolved_at,
:resolved_by,
- to: :last_note
+ to: :last_resolved_note,
+ allow_nil: true
delegate :blob, :highlighted_diff_lines, to: :diff_file, allow_nil: true
@@ -39,6 +40,12 @@ class Discussion
@notes = notes
end
+ def last_resolved_note
+ return unless resolved?
+
+ @last_resolved_note ||= resolved_notes.sort_by(&:resolved_at).last
+ end
+
def last_updated_at
last_note.created_at
end
@@ -67,6 +74,10 @@ class Discussion
resolvable? && notes.none?(&:to_be_resolved?)
end
+ def resolved_notes
+ notes.select(&:resolved?)
+ end
+
def to_be_resolved?
notes.any?(&:to_be_resolved?)
end