From 3b18bb36dda1575a44943c171f3786da42857e66 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Wed, 5 Jan 2022 10:20:39 +0100 Subject: [PATCH] Fixes #3880 - Changing ticket status from "new" to any other status always results in uncommited status "closed". --- .../form_handler_core_workflow.coffee | 5 ++++ spec/system/ticket/zoom_spec.rb | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/form_handler_core_workflow.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/form_handler_core_workflow.coffee index 558b72406..c52f4e61b 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/form_handler_core_workflow.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/form_handler_core_workflow.coffee @@ -139,6 +139,11 @@ class App.FormHandlerCoreWorkflow if valueFound item.default = paramValue item.newValue = paramValue + else if params.id + obj = App[ui.model.className].find(params.id) + if obj && obj[item.name] + item.default = obj[item.name] + item.newValue = obj[item.name] else item.default = '' item.newValue = '' diff --git a/spec/system/ticket/zoom_spec.rb b/spec/system/ticket/zoom_spec.rb index cb9eb7023..f7e988c95 100644 --- a/spec/system/ticket/zoom_spec.rb +++ b/spec/system/ticket/zoom_spec.rb @@ -2316,4 +2316,34 @@ RSpec.describe 'Ticket zoom', type: :system do expect(page.all('select[name=owner_id] option').map(&:value)).to include(agent2.id.to_s) end end + + describe 'Changing ticket status from "new" to any other status always results in uncommited status "closed" #3880', authenticated_as: :authenticate do + let(:ticket) { create(:ticket, group: Group.find_by(name: 'Users')) } + let(:workflow) do + create(:core_workflow, + object: 'Ticket', + condition_selected: { + 'ticket.priority_id': { + operator: 'is', + value: [ Ticket::Priority.find_by(name: '3 high').id.to_s ], + }, + }, + perform: { 'ticket.state_id' => { operator: 'remove_option', remove_option: [ Ticket::State.find_by(name: 'pending reminder').id.to_s ] } }) + end + + def authenticate + workflow + true + end + + before do + visit "#ticket/zoom/#{ticket.id}" + end + + it 'does switch back to the saved value in the ticket instead of the first value of the dropdown' do + page.select 'pending reminder', from: 'state_id' + page.select '3 high', from: 'priority_id' + expect(page).to have_select('state_id', selected: 'new') + end + end end