Commit bbab5d01 authored by Douwe Maan's avatar Douwe Maan

Add methods to resolve diff notes and discussions

parent c9aee48c
......@@ -85,6 +85,24 @@ class DiffNote < Note
self.resolved_at.present?
end
def resolve!(current_user)
return unless resolvable?
return if resolved?
self.resolved_at = Time.now
self.resolved_by = current_user
save!
end
def unresolve!
return unless resolvable?
return unless resolved?
self.resolved_at = nil
self.resolved_by = nil
save!
end
private
def supported?
......
......@@ -63,6 +63,18 @@ class Discussion
notes.any?(&:to_be_resolved?)
end
def resolve!(current_user)
notes.each do |note|
note.resolve!(current_user) if note.resolvable?
end
end
def unresolve!
notes.each do |note|
note.unresolve! if note.resolvable?
end
end
def for_target?(target)
self.noteable == target && !diff_discussion?
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment