diff --git a/app/assets/javascripts/app/models/ticket.coffee b/app/assets/javascripts/app/models/ticket.coffee index c97515eec..120fa6b40 100644 --- a/app/assets/javascripts/app/models/ticket.coffee +++ b/app/assets/javascripts/app/models/ticket.coffee @@ -164,7 +164,7 @@ class App.Ticket extends App.Model params.ticket[attributes[1]] = pendtil.toISOString() # apply user changes - else if attributes[1] is 'owner_id' + else if attributes[1] is 'owner_id' || attributes[1] is 'customer_id' if content.pre_condition is 'current_user.id' params.ticket[attributes[1]] = App.Session.get('id') else diff --git a/spec/system/ticket/zoom_spec.rb b/spec/system/ticket/zoom_spec.rb index 68c987e3f..40dbb0957 100644 --- a/spec/system/ticket/zoom_spec.rb +++ b/spec/system/ticket/zoom_spec.rb @@ -2590,4 +2590,25 @@ RSpec.describe 'Ticket zoom', type: :system do expect(page).to have_selector('.sidebar-content', text: 'mail001.box') end end + + describe 'Error “customer_id required” on Macro execution #4022', authenticated_as: :authenticate do + let(:ticket) { create(:ticket, group: Group.first) } + let(:macro) { create(:macro, perform: { 'ticket.customer_id'=>{ 'pre_condition' => 'current_user.id', 'value' => nil, 'value_completion' => '' } }) } + + def authenticate + ticket && macro + + true + end + + before do + visit "#ticket/zoom/#{ticket.id}" + end + + it 'does set the agent as customer via macro' do + click '.js-openDropdownMacro' + page.find(:macro, macro.id).click + expect(ticket.reload.customer_id).to eq(User.find_by(email: 'admin@example.com').id) + end + end end