Fixes #3567 - Invalid auto assignment conditions may break ticket view for unassigned tickets.

This commit is contained in:
Rolf Schmidt 2021-05-28 15:00:43 +01:00 committed by Thorsten Eckel
parent 01b414f9fc
commit 8ca12c1685
4 changed files with 36 additions and 1 deletions

View file

@ -22,7 +22,7 @@ class App.SettingTicketAutoAssignment extends App.ControllerSubContent
@html(App.view('settings/ticket_auto_assignment')())
configure_attributes = [
{ name: 'condition', display: 'Conditions for effected objects', tag: 'ticket_selector', null: false, preview: false, action: false, hasChanged: false },
{ name: 'condition', display: 'Conditions for effected objects', tag: 'ticket_selector', null: false, preview: false, action: false, hasChanged: false, article: false },
]
ticket_auto_assignment_selector = App.Setting.get('ticket_auto_assignment_selector')

View file

@ -62,6 +62,9 @@ class App.UiElement.ticket_selector
# merge config
elements = {}
if attribute.article is false
delete groups.article
if attribute.action
elements['ticket.action'] =
name: 'action'

View file

@ -0,0 +1,17 @@
class Issue3567AutoAssignment < ActiveRecord::Migration[5.2]
def change
return if !Setting.exists?(name: 'system_init_done')
setting = Setting.get('ticket_auto_assignment_selector')
return if setting.blank?
return if setting['condition'].blank?
setting['condition'].each_key do |key|
next if !key.start_with?('article.')
setting['condition'].delete(key)
end
Setting.set('ticket_auto_assignment_selector', setting)
end
end

View file

@ -0,0 +1,15 @@
require 'rails_helper'
RSpec.describe Issue3567AutoAssignment, type: :db_migration, db_strategy: :reset do
context 'when setting contains article keys' do
before do
Setting.set('ticket_auto_assignment_selector', { 'condition'=>{ 'article.subject'=>{ 'operator' => 'contains', 'value' => 'test' } } })
migrate
end
it 'config gets removed' do
config = Setting.get('ticket_auto_assignment_selector')
expect(config['condition']['article.subject']).to be nil
end
end
end