Fixes #2985 - Adding a note during bulk operation only works for one ticket

This commit is contained in:
Mantas Masalskis 2020-07-15 13:51:13 +02:00 committed by Thorsten Eckel
parent 73f6a98e29
commit 41bba5dda3
2 changed files with 121 additions and 90 deletions

View file

@ -1575,6 +1575,15 @@ class BulkForm extends App.Controller
if _.isEmpty(ticket.title) if _.isEmpty(ticket.title)
ticket.title = '-' ticket.title = '-'
@saveTicketArticle(ticket, article)
@holder.find('.table-overview').find('[name="bulk"]:checked').prop('checked', false)
App.Event.trigger 'notify', {
type: 'success'
msg: App.i18n.translateContent('Bulk action executed!')
}
saveTicketArticle: (ticket, article) =>
ticket.save( ticket.save(
done: (r) => done: (r) =>
@bulkCountIndex++ @bulkCountIndex++
@ -1603,11 +1612,6 @@ class BulkForm extends App.Controller
} }
) )
@holder.find('.table-overview').find('[name="bulk"]:checked').prop('checked', false)
App.Event.trigger 'notify', {
type: 'success'
msg: App.i18n.translateContent('Bulk action executed!')
}
class App.OverviewSettings extends App.ControllerModal class App.OverviewSettings extends App.ControllerModal
buttonClose: true buttonClose: true

View file

@ -1,7 +1,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe 'Ticket views', type: :system do RSpec.describe 'Ticket views', type: :system do
context 'macros' do
let!(:group1) { create :group } let!(:group1) { create :group }
let!(:group2) { create :group } let!(:group2) { create :group }
let!(:macro_without_group) { create :macro } let!(:macro_without_group) { create :macro }
@ -85,4 +85,31 @@ RSpec.describe 'Ticket views', type: :system do
end end
end end
end
context 'bulk note', authenticated_as: :user do
let(:group) { create :group }
let(:user) { create :admin, groups: [group] }
let!(:ticket1) { create(:ticket, state_name: 'open', owner: user, group: group) }
let!(:ticket2) { create(:ticket, state_name: 'open', owner: user, group: group) }
let(:note) { Faker::Lorem.sentence }
it 'adds note to all selected tickets' do
visit 'ticket/view/my_assigned'
within :active_content do
all('.js-checkbox-field', count: 2).each(&:click)
click '.js-confirm'
find('.js-confirm-step textarea').fill_in with: note
click '.js-submit'
end
await_empty_ajax_queue
expect([
ticket1.articles.last&.body,
ticket2.articles.last&.body
]).to be_all note
end
end
end end