Fixed ticket selector if user ist not set.

This commit is contained in:
Martin Edenhofer 2016-04-14 11:39:54 +02:00
parent 9469409cde
commit 8015303032
2 changed files with 8 additions and 8 deletions

View file

@ -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"

View file

@ -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 = {