From bab50e0133e226c06b7a968c2bfa46717de81485 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 23 Mar 2016 12:41:53 +0100 Subject: [PATCH 1/2] Preserve time notes has been updated at when moving issue --- app/services/issues/move_service.rb | 3 ++- spec/services/issues/move_service_spec.rb | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index 468f8acdf64..a5efb21fab6 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -54,7 +54,8 @@ module Issues new_note = note.dup new_params = { project: @new_project, noteable: @new_issue, note: unfold_references(new_note.note), - created_at: note.created_at } + created_at: note.created_at, + updated_at: note.updated_at } new_note.update(new_params) end diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index ade3b7850f1..9b0c73aaf37 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -85,6 +85,10 @@ describe Issues::MoveService, services: true do expect(old_issue.moved?).to eq true expect(old_issue.moved_to).to eq new_issue end + + it 'preserves create time' do + expect(old_issue.created_at).to eq new_issue.created_at + end end context 'issue with notes' do @@ -121,10 +125,23 @@ describe Issues::MoveService, services: true do it 'preserves orignal author of comment' do expect(user_notes.pluck(:author_id)).to all(eq(author.id)) end + end + + context 'note that has been updated' do + let!(:note) do + create(:note, noteable: old_issue, project: old_project, + author: author, updated_at: Date.yesterday, + created_at: Date.yesterday) + end + + include_context 'issue move executed' it 'preserves time when note has been created at' do - expect(old_issue.notes.first.created_at) - .to eq new_issue.notes.first.created_at + expect(new_issue.notes.first.created_at).to eq note.created_at + end + + it 'preserves time when note has been updated at' do + expect(new_issue.notes.first.updated_at).to eq note.updated_at end end From 85b9d763f17e4f8a24610684b570ae02bf0f7522 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 23 Mar 2016 13:24:15 +0100 Subject: [PATCH 2/2] Add Changelog entry for preserving timestamps when moving issue --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 924358a4f0b..79e49d41902 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 8.7.0 (unreleased) + - Preserve time notes/comments have been updated at when moving issue - Make HTTP(s) label consistent on clone bar (Stan Hu) v 8.6.1 (unreleased)