From 76d8a83f0f9ca459f7ab17595ea4dcb1fd278da5 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Mon, 21 Mar 2022 13:02:28 +0100 Subject: [PATCH] =?UTF-8?q?Fixes=20#4022=20-=20Error=20=E2=80=9Ccustomer?= =?UTF-8?q?=5Fid=20required=E2=80=9D=20on=20Macro=20execution.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascripts/app/models/ticket.coffee | 2 +- spec/system/ticket/zoom_spec.rb | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) 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