Fixed issue#383 - TicketSelector in Overview or SLA not working with filter for ticket customer or owner.

This commit is contained in:
Martin Edenhofer 2016-11-10 16:30:36 +01:00
parent a787d66486
commit c8eab7ca56
2 changed files with 27 additions and 2 deletions

View file

@ -501,9 +501,11 @@ condition example
selector = selector_raw.stringify_keys
raise "Invalid selector, operator missing #{selector.inspect}" if !selector['operator']
# validate value / allow empty but only if pre_condition exists
# validate value / allow empty but only if pre_condition exists and is not specific
if !selector.key?('value') || ((selector['value'].class == String || selector['value'].class == Array) && (selector['value'].respond_to?(:empty?) && selector['value'].empty?))
return nil if selector['pre_condition'].nil? || (selector['pre_condition'].respond_to?(:empty?) && selector['pre_condition'].empty?)
return nil if selector['pre_condition'].nil?
return nil if selector['pre_condition'].respond_to?(:empty?) && selector['pre_condition'].empty?
return nil if selector['pre_condition'] == 'specific'
end
# validate pre_condition values

View file

@ -773,6 +773,29 @@ class TicketSelectorTest < ActiveSupport::TestCase
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
assert_equal(ticket_count, 0)
condition = {
'ticket.group_id' => {
operator: 'is',
value: group.id,
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: 'specific',
#value: agent1.id, # value is not set, no result should be shown
},
}
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
assert_equal(ticket_count, nil)
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
assert_equal(ticket_count, nil)
ticket_count, tickets = Ticket.selectors(condition, 10, customer1)
assert_equal(ticket_count, nil)
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
assert_equal(ticket_count, nil)
condition = {
'ticket.group_id' => {
operator: 'is',