Fixes #2629 - Full quote shows "<agent> wrote:" instead of "<customer> wrote" when agent toggled article visibility
This commit is contained in:
parent
9085ef3465
commit
e73a45a30a
3 changed files with 37 additions and 4 deletions
|
@ -344,7 +344,7 @@ class EmailReply extends App.Controller
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
date = @date_format(article.created_at)
|
date = @date_format(article.created_at)
|
||||||
name = article.updated_by.displayName()
|
name = (article.origin_by || article.created_by).displayName()
|
||||||
|
|
||||||
App.i18n.translateInline('On %s, %s wrote:', date, name) + '<br><br>'
|
App.i18n.translateInline('On %s, %s wrote:', date, name) + '<br><br>'
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ class App.TicketArticle extends App.Model
|
||||||
{ name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1, searchable: false },
|
{ name: 'created_at', display: 'Created', tag: 'datetime', readonly: 1, searchable: false },
|
||||||
{ name: 'updated_by_id', display: 'Updated by', relation: 'User', readonly: 1, searchable: false },
|
{ name: 'updated_by_id', display: 'Updated by', relation: 'User', readonly: 1, searchable: false },
|
||||||
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1, searchable: false },
|
{ name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1, searchable: false },
|
||||||
|
{ name: 'origin_by_id', display: 'Origin By', relation: 'User', readonly: 1 },
|
||||||
]
|
]
|
||||||
|
|
||||||
uiUrl: ->
|
uiUrl: ->
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone: 'Europe/London' do
|
RSpec.describe 'Ticket > Update > Full Quote Header', current_user_id: -> { current_user.id }, type: :system, time_zone: 'Europe/London' do
|
||||||
let(:group) { Group.find_by(name: 'Users') }
|
let(:group) { Group.find_by(name: 'Users') }
|
||||||
let(:ticket) { create(:ticket, group: group) }
|
let(:ticket) { create(:ticket, group: group) }
|
||||||
let(:ticket_article) { create(:ticket_article, ticket: ticket, from: 'Example Name <asdf1@example.com>') }
|
let(:ticket_article) { create(:ticket_article, ticket: ticket, from: 'Example Name <asdf1@example.com>') }
|
||||||
let(:customer) { create(:customer) }
|
let(:customer) { create(:customer) }
|
||||||
|
let(:current_user) { customer }
|
||||||
|
|
||||||
prepend_before do
|
prepend_before do
|
||||||
Setting.set 'ui_ticket_zoom_article_email_full_quote_header', full_quote_header_setting
|
Setting.set 'ui_ticket_zoom_article_email_full_quote_header', full_quote_header_setting
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
UserInfo.current_user_id = customer.id
|
|
||||||
visit "ticket/zoom/#{ticket_article.ticket.id}"
|
visit "ticket/zoom/#{ticket_article.ticket.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,6 +38,17 @@ RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone:
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'includes OP when article visibility toggled' do
|
||||||
|
within(:active_content) do
|
||||||
|
set_internal
|
||||||
|
highlight_and_click_reply
|
||||||
|
|
||||||
|
within(:richtext) do
|
||||||
|
expect(page).to contain_full_quote(ticket_article).formatted_for(:reply)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when customer is agent' do
|
context 'when customer is agent' do
|
||||||
let(:customer) { create(:agent) }
|
let(:customer) { create(:agent) }
|
||||||
|
|
||||||
|
@ -51,6 +62,23 @@ RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone:
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'ticket is created by agent on behalf of customer' do
|
||||||
|
let(:agent) { create(:agent) }
|
||||||
|
let(:current_user) { agent }
|
||||||
|
let(:ticket) { create(:ticket, group: group, title: 'Created by agent on behalf of a customer', customer: customer) }
|
||||||
|
let(:ticket_article) { create(:ticket_article, ticket: ticket, from: 'Created by agent on behalf of a customer', origin_by_id: customer.id) }
|
||||||
|
|
||||||
|
it 'includes OP without email when replying' do
|
||||||
|
within(:active_content) do
|
||||||
|
highlight_and_click_reply
|
||||||
|
|
||||||
|
within(:richtext) do
|
||||||
|
expect(page).to contain_full_quote(ticket_article).formatted_for(:reply)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when "ui_ticket_zoom_article_email_full_quote_header" is disabled' do
|
context 'when "ui_ticket_zoom_article_email_full_quote_header" is disabled' do
|
||||||
|
@ -81,6 +109,10 @@ RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone:
|
||||||
click '.js-ArticleAction[data-type=emailForward]'
|
click '.js-ArticleAction[data-type=emailForward]'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_internal
|
||||||
|
click '.js-ArticleAction[data-type=internal]'
|
||||||
|
end
|
||||||
|
|
||||||
def highlight_and_click_reply
|
def highlight_and_click_reply
|
||||||
find('.ticket-article-item .textBubble')
|
find('.ticket-article-item .textBubble')
|
||||||
.execute_script <<~JAVASCRIPT
|
.execute_script <<~JAVASCRIPT
|
||||||
|
@ -162,7 +194,7 @@ RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone:
|
||||||
end
|
end
|
||||||
|
|
||||||
def name
|
def name
|
||||||
expected.created_by.fullname
|
(expected.origin_by || expected.created_by).fullname
|
||||||
end
|
end
|
||||||
|
|
||||||
def email
|
def email
|
||||||
|
|
Loading…
Reference in a new issue