diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-07-25 22:36:03 -0600 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-07-25 22:36:03 -0600 |
commit | c9aee48ced1bf9b4bec758be80791b6cbaccd335 (patch) | |
tree | fc79d0b68de671b1b6b81f0612bcaf4f13ad25c5 | |
parent | 46cc034e05448ff3f515c8e6ad2f72e3e0d657cc (diff) | |
download | gitlab-ce-c9aee48ced1bf9b4bec758be80791b6cbaccd335.tar.gz |
Add resolved methods on Discussion
-rw-r--r-- | app/models/discussion.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/app/models/discussion.rb b/app/models/discussion.rb index 74facfd1c9c..ff85e2038a7 100644 --- a/app/models/discussion.rb +++ b/app/models/discussion.rb @@ -1,7 +1,7 @@ class Discussion NUMBER_OF_TRUNCATED_DIFF_LINES = 16 - attr_reader :first_note, :notes + attr_reader :first_note, :last_note, :notes delegate :created_at, :project, @@ -18,6 +18,11 @@ class Discussion to: :first_note + delegate :resolved_at, + :resolved_by, + + to: :last_note + delegate :blob, :highlighted_diff_lines, to: :diff_file, allow_nil: true def self.for_notes(notes) @@ -30,6 +35,7 @@ class Discussion def initialize(notes) @first_note = notes.first + @last_note = notes.last @notes = notes end @@ -45,6 +51,18 @@ class Discussion notes.any?(&:legacy_diff_note?) end + def resolvable? + diff_discussion? && notes.any?(&:resolvable?) + end + + def resolved? + notes.none?(&:to_be_resolved?) + end + + def to_be_resolved? + notes.any?(&:to_be_resolved?) + end + def for_target?(target) self.noteable == target && !diff_discussion? end |