Commit f5f243a0 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Hide "Edited" when note is transformed or resolved

Makes `Note#edited?` return `false` when the note body was not edited
parent a59b7cee
...@@ -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