diff --git a/app/models/ticket.rb b/app/models/ticket.rb index b51fa5c5d..830be69b5 100644 --- a/app/models/ticket.rb +++ b/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" diff --git a/test/unit/ticket_selector_test.rb b/test/unit/ticket_selector_test.rb index a2c1fca6e..388628050 100644 --- a/test/unit/ticket_selector_test.rb +++ b/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 = {