Add methods to resolve diff notes and discussions

This commit is contained in:
Douwe Maan 2016-07-25 22:37:22 -06:00
parent c9aee48ced
commit bbab5d014f
2 changed files with 30 additions and 0 deletions

View file

@ -85,6 +85,24 @@ class DiffNote < Note
self.resolved_at.present? self.resolved_at.present?
end 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 private
def supported? def supported?

View file

@ -63,6 +63,18 @@ class Discussion
notes.any?(&:to_be_resolved?) notes.any?(&:to_be_resolved?)
end 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) def for_target?(target)
self.noteable == target && !diff_discussion? self.noteable == target && !diff_discussion?
end end