Commit 6461cbdf authored by Sean McGivern's avatar Sean McGivern

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
parents 66eec660 f5f243a0
...@@ -313,6 +313,14 @@ class Note < ActiveRecord::Base ...@@ -313,6 +313,14 @@ class Note < ActiveRecord::Base
!system? !system?
end 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) def cross_reference_not_visible_for?(user)
cross_reference? && !all_referenced_mentionables_allowed?(user) cross_reference? && !all_referenced_mentionables_allowed?(user)
end end
......
---
title: Fix notes being marked as edited after resolving
merge_request: 26143
author:
type: fixed
...@@ -208,6 +208,24 @@ describe Note do ...@@ -208,6 +208,24 @@ describe Note do
end end
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 describe "confidential?" do
it "delegates to noteable" do it "delegates to noteable" do
issue_note = build(:note, :on_issue) issue_note = build(:note, :on_issue)
......
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