Skip to content

Commit

Permalink
Fixes #2406 - Forwarding: Attachment of original content gets removed…
Browse files Browse the repository at this point in the history
… starting from the second forward without reloading per ticket
  • Loading branch information
mantas committed Jan 10, 2020
1 parent 19bb024 commit 375c492
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/app/controllers/ticket_zoom.coffee
Expand Up @@ -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: {}
Expand Down
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
45 changes: 44 additions & 1 deletion spec/system/ticket/zoom_spec.rb
Expand Up @@ -126,7 +126,50 @@
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

0 comments on commit 375c492

Please sign in to comment.