summaryrefslogtreecommitdiff
path: root/app/models/concerns/resolvable_note.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-09-05 16:49:05 +0100
committerSean McGivern <sean@gitlab.com>2017-09-06 10:08:03 +0100
commite8f29569bcb4a2d732a2c00b34958f58d5622836 (patch)
tree41b69a559246c423699c741d2f9f252911a2e525 /app/models/concerns/resolvable_note.rb
parentac816d90d4cc116117497479f400211a43db6be1 (diff)
downloadgitlab-ce-e8f29569bcb4a2d732a2c00b34958f58d5622836.tar.gz
Resolve outdated diff discussions on push
Diffstat (limited to 'app/models/concerns/resolvable_note.rb')
-rw-r--r--app/models/concerns/resolvable_note.rb24
1 files changed, 16 insertions, 8 deletions
diff --git a/app/models/concerns/resolvable_note.rb b/app/models/concerns/resolvable_note.rb
index 05eb6f86704..6f39029ff5a 100644
--- a/app/models/concerns/resolvable_note.rb
+++ b/app/models/concerns/resolvable_note.rb
@@ -51,22 +51,30 @@ module ResolvableNote
end
# If you update this method remember to also update `.resolve!`
- def resolve!(current_user)
- return unless resolvable?
- return if resolved?
+ def resolve_without_save(current_user, resolved_by_push: false)
+ return false unless resolvable?
+ return false if resolved?
self.resolved_at = Time.now
self.resolved_by = current_user
- save!
+ self.resolved_by_push = resolved_by_push
end
# If you update this method remember to also update `.unresolve!`
- def unresolve!
- return unless resolvable?
- return unless resolved?
+ def unresolve_without_save(current_user)
+ return false unless resolvable?
+ return false unless resolved?
self.resolved_at = nil
self.resolved_by = nil
- save!
+ end
+
+ def resolve!(current_user, resolved_by_push: false)
+ resolve_without_save(current_user, resolved_by_push: resolved_by_push) &&
+ save!
+ end
+
+ def unresolve!
+ unresolve_without_save(current_user) && save
end
end