Browse Source

Feature: Add hosted support for AND/OR feature.

Dusan Vuckovic 2 years ago
parent
commit
34df8b3984

+ 19 - 0
db/migrate/20221221082844_and_or_conditions_setting_default.rb

@@ -0,0 +1,19 @@
+# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
+
+class AndOrConditionsSettingDefault < ActiveRecord::Migration[6.1]
+  def change
+    # return if it's a new setup
+    return if !Setting.exists?(name: 'system_init_done')
+
+    expert_setting = Setting.find_by(name: 'ticket_allow_expert_conditions')
+    return if !expert_setting
+
+    expert_setting.area = 'Ticket::Core'
+    expert_setting.state_current = { value: true }
+    expert_setting.state_initial = { value: true }
+    expert_setting.preferences[:online_service_disable] = true
+    expert_setting.preferences.delete(:prio)
+
+    expert_setting.save!
+  end
+end

+ 4 - 4
db/seeds/settings.rb

@@ -2187,7 +2187,7 @@ Setting.create_if_not_exists(
 Setting.create_if_not_exists(
   title:       __('Ticket Conditions Expert Mode'),
   name:        'ticket_allow_expert_conditions',
-  area:        'Ticket::Base',
+  area:        'Ticket::Core',
   description: __('Defines if the ticket conditions editor supports complex logical expressions.'),
   options:     {
     form: [
@@ -2203,10 +2203,10 @@ Setting.create_if_not_exists(
       },
     ],
   },
-  state:       false,
+  state:       true,
   preferences: {
-    prio:       4000,
-    permission: ['admin.ticket'],
+    online_service_disable: true,
+    permission:             ['admin.ticket'],
   },
   frontend:    true
 )

+ 53 - 0
spec/db/migrate/and_or_conditions_setting_default_spec.rb

@@ -0,0 +1,53 @@
+# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
+
+require 'rails_helper'
+
+RSpec.describe AndOrConditionsSettingDefault, type: :db_migration do
+  before do
+    Setting.find_by(name: 'ticket_allow_expert_conditions').destroy!
+    Setting.create(
+      title:       'Ticket Conditions Expert Mode',
+      name:        'ticket_allow_expert_conditions',
+      area:        'Ticket::Base',
+      description: 'Defines if the ticket conditions editor supports complex logical expressions.',
+      options:     {
+        form: [
+          {
+            display: '',
+            null:    true,
+            name:    'ticket_allow_expert_conditions',
+            tag:     'boolean',
+            options: {
+              true  => 'yes',
+              false => 'no',
+            },
+          },
+        ],
+      },
+      state:       false,
+      preferences: {
+        prio:       4000,
+        permission: ['admin.ticket'],
+      },
+      frontend:    true
+    )
+
+    migrate
+  end
+
+  it 'does migrate ticket_allow_expert_conditions setting' do
+    expect(Setting.find_by(name: 'ticket_allow_expert_conditions')).to have_attributes(
+      area:          'Ticket::Core',
+      state_current: {
+        value: true,
+      },
+      state_initial: {
+        value: true,
+      },
+      preferences:   {
+        online_service_disable: true,
+        permission:             ['admin.ticket'],
+      }
+    )
+  end
+end