Fixes #2406 - Forwarding: Attachment of original content gets removed starting from the second forward without reloading per ticket

This commit is contained in:
Mantas Masalskis 2020-01-10 13:01:33 +01:00
parent 1772e9f1e4
commit ceb9bf6e14
3 changed files with 54 additions and 2 deletions

View file

@ -1005,9 +1005,12 @@ class App.TicketZoom extends App.Controller
# reset task state
taskReset: =>
@form_id = App.ControllerForm.formId()
@articleNew.form_id = @form_id
@articleNew.render()
@articleView.updateFormId(@form_id)
@localTaskData =
ticket: {}
article: {}

View file

@ -60,6 +60,9 @@ class App.TicketZoomArticleView extends App.Controller
false
updateFormId: (newFormId) ->
for id, viewItem of @articleController
viewItem.updateFormId(newFormId)
class ArticleViewItem extends App.ObserverController
model: 'TicketArticle'
@ -205,7 +208,7 @@ class ArticleViewItem extends App.ObserverController
size: 40
)
new App.TicketZoomArticleActions(
@articleActions = new App.TicketZoomArticleActions(
el: @$('.js-article-actions')
ticket: @ticket
article: article
@ -425,3 +428,6 @@ class ArticleViewItem extends App.ObserverController
e.preventDefault()
e.stopPropagation()
new App.TicketZoomArticleImageView(image: $(e.target).get(0).outerHTML, parentElement: $(e.currentTarget))
updateFormId: (newFormId) ->
@articleActions?.form_id = newFormId

View file

@ -126,7 +126,50 @@ RSpec.describe 'Ticket zoom', type: :system do
end
end
end
end
context 'when ticket has an attachment' do
let(:group) { Group.find_by(name: 'Users') }
let(:ticket) { create(:ticket, group: group) }
let(:article) { create(:ticket_article, ticket: ticket) }
let(:attachment_name) { 'some_file.txt' }
before do
Store.add(
object: 'Ticket::Article',
o_id: article.id,
data: 'some content',
filename: attachment_name,
preferences: {
'Content-Type' => 'text/plain',
},
created_by_id: 1,
)
end
context 'article was already forwarded once' do
before do
visit "#ticket/zoom/#{ticket.id}"
within(:active_content) do
find('a[data-type=emailForward]').click
click('.js-reset')
have_no_css('.js-reset')
end
end
it 'adds attachments when forwarding multiple times' do
within(:active_content) do
find('a[data-type=emailForward]').click
end
within('.js-writeArea') do
expect(page).to have_text attachment_name
end
end
end
end
end