summaryrefslogtreecommitdiff
path: root/spec/models/note_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-12 12:08:50 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-12 12:08:50 +0000
commit47bb4281f0b12f158923f8a1e5691c7a4be2f2f6 (patch)
tree319d236945ce62673cab2fdcc5331e79ef0c01ba /spec/models/note_spec.rb
parent2e3f13a01a2833f85fb2201a245205b8e9d0ca9a (diff)
downloadgitlab-ce-47bb4281f0b12f158923f8a1e5691c7a4be2f2f6.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/note_spec.rb')
-rw-r--r--spec/models/note_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index e56c140e501..4b262c1f3a9 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -1753,4 +1753,27 @@ RSpec.describe Note do
expect(note.commands_changes.keys).to contain_exactly(:emoji_award, :time_estimate, :spend_time)
end
end
+
+ describe '#bump_updated_at', :freeze_time do
+ it 'sets updated_at to the current timestamp' do
+ note = create(:note, updated_at: 1.day.ago)
+
+ note.bump_updated_at
+ note.reload
+
+ expect(note.updated_at).to be_like_time(Time.current)
+ end
+
+ context 'with legacy edited note' do
+ it 'copies updated_at to last_edited_at before bumping the timestamp' do
+ note = create(:note, updated_at: 1.day.ago, updated_by: create(:user), last_edited_at: nil)
+
+ note.bump_updated_at
+ note.reload
+
+ expect(note.last_edited_at).to be_like_time(1.day.ago)
+ expect(note.updated_at).to be_like_time(Time.current)
+ end
+ end
+ end
end