From 6e90f4bfa2528378f4000cc24934c82d4ff4fd11 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Thu, 16 Dec 2021 12:18:30 +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 c7ede74ba..106a0a78e 100644 --- a/spec/system/ticket/zoom_spec.rb +++ b/spec/system/ticket/zoom_spec.rb @@ -2344,4 +2344,34 @@ RSpec.describe 'Ticket zoom', type: :system do expect(page).to have_no_selector('.js-reset') 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