Fixed issue#383 - TicketSelector in Overview or SLA not working with filter for ticket customer or owner.
This commit is contained in:
parent
a787d66486
commit
c8eab7ca56
2 changed files with 27 additions and 2 deletions
|
@ -501,9 +501,11 @@ condition example
|
||||||
selector = selector_raw.stringify_keys
|
selector = selector_raw.stringify_keys
|
||||||
raise "Invalid selector, operator missing #{selector.inspect}" if !selector['operator']
|
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?))
|
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
|
end
|
||||||
|
|
||||||
# validate pre_condition values
|
# validate pre_condition values
|
||||||
|
|
|
@ -773,6 +773,29 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||||
assert_equal(ticket_count, 0)
|
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 = {
|
condition = {
|
||||||
'ticket.group_id' => {
|
'ticket.group_id' => {
|
||||||
operator: 'is',
|
operator: 'is',
|
||||||
|
|
Loading…
Reference in a new issue