From 740f8bf4d292fc3bcf5a91e536e3f49e065a0217 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Wed, 23 Mar 2022 13:30:59 +0100 Subject: [PATCH] Fixes #3984 - Mention history does not show properly who got added. --- .../_modal_generic_history.coffee | 10 +++++++++- app/models/mention.rb | 1 + spec/system/ticket/zoom_spec.rb | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee b/app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee index 5470580c7..c4090a7ff 100644 --- a/app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee @@ -100,7 +100,7 @@ class App.GenericHistory extends App.ControllerModal content += " '#{ @translateItemValue(item, item.value_from) }'" if item.value_to - if item.value_from + if item.value_from || item.object is 'Mention' content += ' →' content += " '#{ @translateItemValue(item, item.value_to) }'" else if item.value_from @@ -114,6 +114,14 @@ class App.GenericHistory extends App.ControllerModal newItems translateItemValue: ({object, attribute}, value) -> + if object is 'Mention' + result = '-' + if value + user = App.User.find(value) + if user + result = user.displayName() + return result + localAttribute = @objectAttribute(object, attribute) if localAttribute && localAttribute.tag is 'datetime' return App.i18n.translateTimestamp(value) diff --git a/app/models/mention.rb b/app/models/mention.rb index 9bd9b293e..022b5f233 100644 --- a/app/models/mention.rb +++ b/app/models/mention.rb @@ -30,6 +30,7 @@ class Mention < ApplicationModel { related_o_id: mentionable_id, related_history_object: mentionable_type, + value_to: user.id, } end diff --git a/spec/system/ticket/zoom_spec.rb b/spec/system/ticket/zoom_spec.rb index 40dbb0957..fbee57549 100644 --- a/spec/system/ticket/zoom_spec.rb +++ b/spec/system/ticket/zoom_spec.rb @@ -1381,6 +1381,7 @@ RSpec.describe 'Ticket zoom', type: :system do context 'when logged in as agent' do let(:ticket) { create(:ticket, group: Group.find_by(name: 'Users')) } let!(:other_agent) { create(:agent, groups: [Group.find_by(name: 'Users')]) } + let!(:admin) { User.find_by(email: 'admin@example.com') } it 'can subscribe and unsubscribe' do ensure_websocket do @@ -1400,8 +1401,9 @@ RSpec.describe 'Ticket zoom', type: :system do # check history for mention entries click 'h2.sidebar-header-headline.js-headline' click 'li[data-type=ticket-history] a' - expect(page).to have_text('created Mention') - expect(page).to have_text('removed Mention') + expect(page).to have_text("created Mention → '#{admin.firstname} #{admin.lastname}'") + expect(page).to have_text("removed Mention → '#{admin.firstname} #{admin.lastname}'") + expect(page).to have_text("created Mention → '#{other_agent.firstname} #{other_agent.lastname}'") end end end