Browse Source

Fixed ticket selector if user ist not set.

Martin Edenhofer 9 years ago
parent
commit
8015303032
2 changed files with 8 additions and 8 deletions
  1. 2 2
      app/models/ticket.rb
  2. 6 6
      test/unit/ticket_selector_test.rb

+ 2 - 2
app/models/ticket.rb

@@ -486,7 +486,7 @@ condition example
       if selector['operator'] == 'is'
         if selector['pre_condition'] == 'not_set'
           if attributes[1] =~ /^(created_by|updated_by|owner|customer|user)_id/
-            query += "#{attribute} NOT IN (?)"
+            query += "#{attribute} IN (?)"
             bind_params.push 1
           else
             query += "#{attribute} IS NOT NULL"
@@ -513,7 +513,7 @@ condition example
       elsif selector['operator'] == 'is not'
         if selector['pre_condition'] == 'not_set'
           if attributes[1] =~ /^(created_by|updated_by|owner|customer|user)_id/
-            query += "#{attribute} IN (?)"
+            query += "#{attribute} NOT IN (?)"
             bind_params.push 1
           else
             query += "#{attribute} IS NULL"

+ 6 - 6
test/unit/ticket_selector_test.rb

@@ -776,16 +776,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
       },
     }
     ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
-    assert_equal(ticket_count, 1)
+    assert_equal(ticket_count, 2)
 
     ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
     assert_equal(ticket_count, 0)
 
     ticket_count, tickets = Ticket.selectors(condition, 10, customer1)
-    assert_equal(ticket_count, 1)
+    assert_equal(ticket_count, 0)
 
     ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
-    assert_equal(ticket_count, 0)
+    assert_equal(ticket_count, 2)
 
     condition = {
       'ticket.group_id' => {
@@ -798,16 +798,16 @@ class TicketSelectorTest < ActiveSupport::TestCase
       },
     }
     ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
-    assert_equal(ticket_count, 2)
+    assert_equal(ticket_count, 1)
 
     ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
     assert_equal(ticket_count, 0)
 
     ticket_count, tickets = Ticket.selectors(condition, 10, customer1)
-    assert_equal(ticket_count, 0)
+    assert_equal(ticket_count, 1)
 
     ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
-    assert_equal(ticket_count, 2)
+    assert_equal(ticket_count, 0)
 
     UserInfo.current_user_id = agent1.id
     condition = {