summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-03-15 09:44:57 +0000
committerGitLab Release Tools Bot <robert+release-tools@gitlab.com>2019-03-19 13:56:29 +0000
commit11e8798402bffe626c21540fde09571034720907 (patch)
tree2814629f41698c1bc1483f1384014743ebb309e2
parent14a681fd99893cdc62dfd91a00960edd3eb7cc28 (diff)
downloadgitlab-ce-11e8798402bffe626c21540fde09571034720907.tar.gz
Merge branch '57330-fix-comment-edited' into 'master'
Hide "Edited" when note is transformed or resolved Closes #57330 See merge request gitlab-org/gitlab-ce!26143 (cherry picked from commit 6461cbdfa4df0873d62183ca0c0979b20040fde6) f5f243a0 Hide "Edited" when note is transformed or resolved
-rw-r--r--app/models/note.rb8
-rw-r--r--changelogs/unreleased/57330-fix-comment-edited.yml5
-rw-r--r--spec/models/note_spec.rb18
3 files changed, 31 insertions, 0 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 1578ae9c4cc..2c9980b1a0d 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -313,6 +313,14 @@ class Note < ActiveRecord::Base
!system?
end
+ # Since we're using `updated_at` as `last_edited_at`, it could be touched by transforming / resolving a note.
+ # This makes sure it is only marked as edited when the note body is updated.
+ def edited?
+ return false if updated_by.blank?
+
+ super
+ end
+
def cross_reference_not_visible_for?(user)
cross_reference? && !all_referenced_mentionables_allowed?(user)
end
diff --git a/changelogs/unreleased/57330-fix-comment-edited.yml b/changelogs/unreleased/57330-fix-comment-edited.yml
new file mode 100644
index 00000000000..68cf6c03d4c
--- /dev/null
+++ b/changelogs/unreleased/57330-fix-comment-edited.yml
@@ -0,0 +1,5 @@
+---
+title: Fix notes being marked as edited after resolving
+merge_request: 26143
+author:
+type: fixed
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 385b8a7959f..eb6f6ff5faf 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -208,6 +208,24 @@ describe Note do
end
end
+ describe "edited?" do
+ let(:note) { build(:note, updated_by_id: nil, created_at: Time.now, updated_at: Time.now + 5.hours) }
+
+ context "with updated_by" do
+ it "returns true" do
+ note.updated_by = build(:user)
+
+ expect(note.edited?).to be_truthy
+ end
+ end
+
+ context "without updated_by" do
+ it "returns false" do
+ expect(note.edited?).to be_falsy
+ end
+ end
+ end
+
describe "confidential?" do
it "delegates to noteable" do
issue_note = build(:note, :on_issue)