diff --git a/app/models/ticket.rb b/app/models/ticket.rb index ebf748bef..2b965c3f0 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -311,6 +311,12 @@ returns # quiet update of reassign of articles Ticket::Article.where(ticket_id: id).update_all(['ticket_id = ?', data[:ticket_id]]) # rubocop:disable Rails/SkipsModelValidations + # mark target ticket as updated + # otherwise the "received_merge" history entry + # will be the same as the last updated_at + # which might be a long time ago + target_ticket.updated_at = Time.zone.now + # add merge event to both ticket's history (Issue #2469 - Add information "Ticket merged" to History) target_ticket.history_log( 'received_merge', diff --git a/spec/models/ticket_spec.rb b/spec/models/ticket_spec.rb index a009a53ae..949a61419 100644 --- a/spec/models/ticket_spec.rb +++ b/spec/models/ticket_spec.rb @@ -81,6 +81,14 @@ RSpec.describe Ticket, type: :model do context 'when merging' do let(:merge_user) { create(:user) } + before do + # create target ticket early + # to avoid a race condition + # when creating the history entries + target_ticket + travel 5.minutes + end + it 'creates history entries in both the origin ticket and the target ticket' do ticket.merge_to(ticket_id: target_ticket.id, user_id: merge_user.id)