Fixes #3984 - Mention history does not show properly who got added.

This commit is contained in:
Rolf Schmidt 2022-03-23 13:30:59 +01:00
parent 1049368fc7
commit 740f8bf4d2
3 changed files with 14 additions and 3 deletions

View file

@ -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)

View file

@ -30,6 +30,7 @@ class Mention < ApplicationModel
{
related_o_id: mentionable_id,
related_history_object: mentionable_type,
value_to: user.id,
}
end

View file

@ -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