From 7de423517eca9a3e63d0feabd7b50e838bed368d Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Thu, 26 Aug 2021 14:35:03 +0100 Subject: [PATCH] Fixes #3710 - Unable to close tickets in certran cases if core workflow is used. --- app/models/concerns/checks_core_workflow.rb | 1 + .../concerns/checks_core_workflow_examples.rb | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/app/models/concerns/checks_core_workflow.rb b/app/models/concerns/checks_core_workflow.rb index 03066b468..f7a4f80da 100644 --- a/app/models/concerns/checks_core_workflow.rb +++ b/app/models/concerns/checks_core_workflow.rb @@ -50,6 +50,7 @@ module ChecksCoreWorkflow def check_mandatory(perform_result) perform_result[:mandatory].each_key do |key| + next if perform_result[:visibility][key] != 'show' next if !perform_result[:mandatory][key] next if self[key].present? diff --git a/spec/models/concerns/checks_core_workflow_examples.rb b/spec/models/concerns/checks_core_workflow_examples.rb index 71e77d041..980741351 100644 --- a/spec/models/concerns/checks_core_workflow_examples.rb +++ b/spec/models/concerns/checks_core_workflow_examples.rb @@ -91,4 +91,31 @@ RSpec.shared_examples 'ChecksCoreWorkflow' do expect { ticket }.to raise_error(Exceptions::UnprocessableEntity, "Missing required value for field 'pending_time'!") end end + + context 'when creation of mandatory field but hidden' do + subject(:ticket) { create(:ticket, group: agent_group, screen: 'create_middle', state: Ticket::State.find_by(name: 'open')) } + + before do + create(:core_workflow, + object: 'Ticket', + perform: { + 'ticket.pending_time': { + operator: 'set_mandatory', + set_mandatory: true + }, + }) + create(:core_workflow, + object: 'Ticket', + perform: { + 'ticket.pending_time': { + operator: 'hide', + hide: true + }, + }) + end + + it 'does create a ticket without pending_time value' do + expect { ticket }.not_to raise_error + end + end end