Browse Source

Fixed #4157 - Ticket is not opened, nothing can be viewed if auto assignment selector in admin interface has no value selected.

Martin Edenhofer 2 years ago
parent
commit
583baf08d0

+ 2 - 0
app/assets/javascripts/app/models/ticket.coffee

@@ -258,8 +258,10 @@ class App.Ticket extends App.Model
 
   @_selectorMatch: (object, objectName, attributeName, condition) ->
     conditionValue = condition.value
+    conditionValue = '' if conditionValue == null
     conditionValue = '' if conditionValue == undefined
     objectValue    = object[attributeName]
+    objectValue    = '' if objectValue == null
     objectValue    = '' if objectValue == undefined
 
     # take care about pre conditions

+ 87 - 0
public/assets/tests/qunit/ticket_selector.js

@@ -235,6 +235,65 @@ window.onload = function() {
     assert.equal(result, false, result);
   };
 
+  var testIsNull = function (assert, key, value, ticket) {
+    setting = {
+      "condition": {
+        [key]: {
+          "operator": "is",
+          "value": null
+        },
+      }
+    };
+    result = App.Ticket.selector(ticket, setting['condition']);
+    assert.equal(result, false, result);
+
+    setting = {
+      "condition": {
+        [key]: {
+          "operator": "is not",
+          "value": null
+        },
+      }
+    };
+    result = App.Ticket.selector(ticket, setting['condition']);
+    assert.equal(result, true, result);
+  };
+
+  var testIsUndefined = function (assert, key, value, ticket) {
+    setting = {
+      "condition": {
+        [key]: {
+          "operator": "is",
+          "value": undefined
+        },
+      }
+    };
+    result = App.Ticket.selector(ticket, setting['condition']);
+    assert.equal(result, false, result);
+
+    setting = {
+      "condition": {
+        [key]: {
+          "operator": "is not",
+          "value": undefined
+        },
+      }
+    };
+    result = App.Ticket.selector(ticket, setting['condition']);
+    assert.equal(result, true, result);
+  };
+
+  var testSelectorUndefined = function (assert, ticket) {
+    result = App.Ticket.selector(ticket, undefined);
+    assert.equal(result, true, result);
+  };
+
+  var testSelectorNull = function (assert, ticket) {
+    result = App.Ticket.selector(ticket, null);
+    assert.equal(result, true, result);
+  };
+
+
   var testPreConditionUser = function (assert, key, specificValue, ticket, session) {
     App.Session.set(6);
 
@@ -686,6 +745,20 @@ window.onload = function() {
    * ------------------------------------------------------------------------
    */
 
+  QUnit.test("selector is undefined", assert => {
+    ticket = new App.Ticket();
+    ticket.load(ticketData);
+
+    testSelectorUndefined(assert, ticket);
+  });
+
+  QUnit.test("selector is null", assert => {
+    ticket = new App.Ticket();
+    ticket.load(ticketData);
+
+    testSelectorNull(assert, ticket);
+  });
+
   QUnit.test("ticket number", assert => {
     ticket = new App.Ticket();
     ticket.load(ticketData);
@@ -739,6 +812,20 @@ window.onload = function() {
     testIs(assert, 'ticket.state_id', ['4'], ticket, sessionData);
   });
 
+  QUnit.test("ticket state_id -> null", assert => {
+    ticket = new App.Ticket();
+    ticket.load(ticketData);
+
+    testIsNull(assert, 'ticket.state_id', null, ticket, sessionData);
+  });
+
+  QUnit.test("ticket state_id -> undefined", assert => {
+    ticket = new App.Ticket();
+    ticket.load(ticketData);
+
+    testIsNull(assert, 'ticket.state_id', undefined, ticket, sessionData);
+  });
+
   QUnit.test("ticket pending_time", assert => {
     ticket = new App.Ticket();
     ticket.load(ticketData);