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