diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee
index 52abad1f7..862cb5616 100644
--- a/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee
+++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee
@@ -344,7 +344,7 @@ class EmailReply extends App.Controller
return ''
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) + '
'
diff --git a/app/assets/javascripts/app/models/ticket_article.coffee b/app/assets/javascripts/app/models/ticket_article.coffee
index 0e0cca8e3..84e5d7f80 100644
--- a/app/assets/javascripts/app/models/ticket_article.coffee
+++ b/app/assets/javascripts/app/models/ticket_article.coffee
@@ -16,6 +16,7 @@ class App.TicketArticle extends App.Model
{ 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_at', display: 'Updated', tag: 'datetime', readonly: 1, searchable: false },
+ { name: 'origin_by_id', display: 'Origin By', relation: 'User', readonly: 1 },
]
uiUrl: ->
diff --git a/spec/system/ticket/update/full_quote_header_spec.rb b/spec/system/ticket/update/full_quote_header_spec.rb
index 4b0ae8f4a..8fe7389d6 100644
--- a/spec/system/ticket/update/full_quote_header_spec.rb
+++ b/spec/system/ticket/update/full_quote_header_spec.rb
@@ -1,17 +1,17 @@
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(:ticket) { create(:ticket, group: group) }
let(:ticket_article) { create(:ticket_article, ticket: ticket, from: 'Example Name ') }
let(:customer) { create(:customer) }
+ let(:current_user) { customer }
prepend_before do
Setting.set 'ui_ticket_zoom_article_email_full_quote_header', full_quote_header_setting
end
before do
- UserInfo.current_user_id = customer.id
visit "ticket/zoom/#{ticket_article.ticket.id}"
end
@@ -38,6 +38,17 @@ RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone:
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
let(:customer) { create(:agent) }
@@ -51,6 +62,23 @@ RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone:
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
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]'
end
+ def set_internal
+ click '.js-ArticleAction[data-type=internal]'
+ end
+
def highlight_and_click_reply
find('.ticket-article-item .textBubble')
.execute_script <<~JAVASCRIPT
@@ -162,7 +194,7 @@ RSpec.describe 'Ticket > Update > Full Quote Header', type: :system, time_zone:
end
def name
- expected.created_by.fullname
+ (expected.origin_by || expected.created_by).fullname
end
def email