Fixed issue#323 - Unable to create tickets if SLA with condition article.subject is set.
This commit is contained in:
parent
38250659b6
commit
f86bdcce88
3 changed files with 175 additions and 4 deletions
|
@ -76,8 +76,12 @@ returns
|
|||
preferences[:escalation_calculation] = {}
|
||||
|
||||
# nothing to change
|
||||
return false if !escalation_at
|
||||
return false if !escalation_at && !first_response_escalation_at && !update_escalation_at && !close_escalation_at
|
||||
self.escalation_at = nil
|
||||
self.first_response_escalation_at = nil
|
||||
self.escalation_at = nil
|
||||
self.update_escalation_at = nil
|
||||
self.close_escalation_at = nil
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -287,8 +291,8 @@ returns
|
|||
if !sla.condition || sla.condition.empty?
|
||||
sla_selected = sla
|
||||
elsif sla.condition
|
||||
query_condition, bind_condition = Ticket.selector2sql(sla.condition)
|
||||
ticket = Ticket.where(query_condition, *bind_condition).find_by(id: id)
|
||||
query_condition, bind_condition, tables = Ticket.selector2sql(sla.condition)
|
||||
ticket = Ticket.where(query_condition, *bind_condition).joins(tables).find_by(id: id)
|
||||
next if !ticket
|
||||
sla_selected = sla
|
||||
break
|
||||
|
|
|
@ -92,7 +92,7 @@ returns
|
|||
|
||||
list = []
|
||||
overviews.each { |overview|
|
||||
query_condition, bind_condition = Ticket.selector2sql(overview.condition, user)
|
||||
query_condition, bind_condition, tables = Ticket.selector2sql(overview.condition, user)
|
||||
|
||||
order_by = "#{overview.order[:by]} #{overview.order[:direction]}"
|
||||
if overview.group_by && !overview.group_by.empty?
|
||||
|
@ -102,6 +102,7 @@ returns
|
|||
ticket_result = Ticket.select('id, updated_at')
|
||||
.where(access_condition)
|
||||
.where(query_condition, *bind_condition)
|
||||
.joins(tables)
|
||||
.order(order_by)
|
||||
.limit(500)
|
||||
.pluck(:id, :updated_at)
|
||||
|
|
|
@ -1460,4 +1460,170 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
|
||||
end
|
||||
|
||||
test 'ticket ticket.title and article.subject' do
|
||||
|
||||
ticket = Ticket.create!(
|
||||
title: 'some title SLATEST1 for you',
|
||||
group: Group.lookup(name: 'Users'),
|
||||
customer_id: 2,
|
||||
state: Ticket::State.lookup(name: 'new'),
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-03-21 12:30:00 UTC',
|
||||
updated_at: '2016-03-21 12:30:00 UTC',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
article_inbound = Ticket::Article.create!(
|
||||
ticket_id: ticket.id,
|
||||
from: 'some_sender@example.com',
|
||||
to: 'some_recipient@example.com',
|
||||
subject: 'some title SLATEST2 for you',
|
||||
message_id: 'some@id',
|
||||
body: 'some message',
|
||||
internal: false,
|
||||
sender: Ticket::Article::Sender.where(name: 'Customer').first,
|
||||
type: Ticket::Article::Type.where(name: 'email').first,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
created_at: '2016-03-21 12:30:00 UTC',
|
||||
updated_at: '2016-03-21 12:30:00 UTC',
|
||||
)
|
||||
|
||||
calendar = Calendar.create_or_update(
|
||||
name: 'EU 5',
|
||||
timezone: 'Europe/Berlin',
|
||||
business_hours: {
|
||||
mon: {
|
||||
active: true,
|
||||
timeframes: [ ['09:00', '18:00'] ]
|
||||
},
|
||||
tue: {
|
||||
active: true,
|
||||
timeframes: [ ['09:00', '18:00'] ]
|
||||
},
|
||||
wed: {
|
||||
active: true,
|
||||
timeframes: [ ['09:00', '18:00'] ]
|
||||
},
|
||||
thu: {
|
||||
active: true,
|
||||
timeframes: [ ['09:00', '18:00'] ]
|
||||
},
|
||||
fri: {
|
||||
active: true,
|
||||
timeframes: [ ['09:00', '18:00'] ]
|
||||
},
|
||||
sat: {
|
||||
active: true,
|
||||
timeframes: [ ['09:00', '18:00'] ]
|
||||
},
|
||||
sun: {
|
||||
active: true,
|
||||
timeframes: [ ['09:00', '18:00'] ]
|
||||
},
|
||||
},
|
||||
default: true,
|
||||
ical_url: nil,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
|
||||
sla = Sla.create_or_update(
|
||||
name: 'test sla - ticket.title & article.subject',
|
||||
condition: {
|
||||
'ticket.priority_id' => {
|
||||
operator: 'is',
|
||||
value: %w(1 2 3),
|
||||
},
|
||||
'article.subject' => {
|
||||
operator: 'contains',
|
||||
value: 'SLATEST2',
|
||||
},
|
||||
},
|
||||
calendar_id: calendar.id,
|
||||
first_response_time: 60,
|
||||
update_time: 120,
|
||||
solution_time: 180,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
Scheduler.worker(true)
|
||||
ticket = Ticket.find(ticket.id)
|
||||
assert_equal(ticket.escalation_at.gmtime.to_s, '2016-03-21 13:30:00 UTC', 'ticket.escalation_at verify 1')
|
||||
assert_equal(ticket.first_response_escalation_at.gmtime.to_s, '2016-03-21 13:30:00 UTC', 'ticket.first_response_escalation_at verify 1')
|
||||
assert_equal(ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3')
|
||||
assert_equal(ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3')
|
||||
assert_equal(ticket.update_escalation_at.gmtime.to_s, '2016-03-21 14:30:00 UTC', 'ticket.update_escalation_at verify 1')
|
||||
assert_equal(ticket.close_escalation_at.gmtime.to_s, '2016-03-21 15:30:00 UTC', 'ticket.close_escalation_at verify 1')
|
||||
assert_equal(ticket.close_in_min, nil, 'ticket.close_in_min verify 3')
|
||||
assert_equal(ticket.close_diff_in_min, nil, 'ticket.close_diff_in_min# verify 3')
|
||||
|
||||
sla = Sla.create_or_update(
|
||||
name: 'test sla - ticket.title & article.subject',
|
||||
condition: {
|
||||
'ticket.priority_id' => {
|
||||
operator: 'is',
|
||||
value: %w(1 2 3),
|
||||
},
|
||||
'ticket.title' => {
|
||||
operator: 'contains',
|
||||
value: 'SLATEST1',
|
||||
},
|
||||
},
|
||||
calendar_id: calendar.id,
|
||||
first_response_time: 60,
|
||||
update_time: 120,
|
||||
solution_time: 180,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
Scheduler.worker(true)
|
||||
ticket = Ticket.find(ticket.id)
|
||||
assert_equal(ticket.escalation_at.gmtime.to_s, '2016-03-21 13:30:00 UTC', 'ticket.escalation_at verify 1')
|
||||
assert_equal(ticket.first_response_escalation_at.gmtime.to_s, '2016-03-21 13:30:00 UTC', 'ticket.first_response_escalation_at verify 1')
|
||||
assert_equal(ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3')
|
||||
assert_equal(ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3')
|
||||
assert_equal(ticket.update_escalation_at.gmtime.to_s, '2016-03-21 14:30:00 UTC', 'ticket.update_escalation_at verify 1')
|
||||
assert_equal(ticket.close_escalation_at.gmtime.to_s, '2016-03-21 15:30:00 UTC', 'ticket.close_escalation_at verify 1')
|
||||
assert_equal(ticket.close_in_min, nil, 'ticket.close_in_min verify 3')
|
||||
assert_equal(ticket.close_diff_in_min, nil, 'ticket.close_diff_in_min# verify 3')
|
||||
|
||||
sla = Sla.create_or_update(
|
||||
name: 'test sla - ticket.title & article.subject',
|
||||
condition: {
|
||||
'ticket.priority_id' => {
|
||||
operator: 'is',
|
||||
value: %w(1 2 3),
|
||||
},
|
||||
'ticket.title' => {
|
||||
operator: 'contains',
|
||||
value: 'SLATEST2',
|
||||
},
|
||||
},
|
||||
calendar_id: calendar.id,
|
||||
first_response_time: 60,
|
||||
update_time: 120,
|
||||
solution_time: 180,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
Scheduler.worker(true)
|
||||
ticket = Ticket.find(ticket.id)
|
||||
assert_equal(ticket.escalation_at, nil, 'ticket.escalation_at verify 1')
|
||||
assert_equal(ticket.first_response_escalation_at, nil, 'ticket.first_response_escalation_at verify 1')
|
||||
assert_equal(ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3')
|
||||
assert_equal(ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3')
|
||||
assert_equal(ticket.update_escalation_at, nil, 'ticket.update_escalation_at verify 1')
|
||||
assert_equal(ticket.close_escalation_at, nil, 'ticket.close_escalation_at verify 1')
|
||||
assert_equal(ticket.close_in_min, nil, 'ticket.close_in_min verify 3')
|
||||
assert_equal(ticket.close_diff_in_min, nil, 'ticket.close_diff_in_min# verify 3')
|
||||
|
||||
delete = sla.destroy
|
||||
assert(delete, 'sla destroy')
|
||||
|
||||
delete = ticket.destroy
|
||||
assert(delete, 'ticket destroy')
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue