Fixes #3551 - First response doesn't get solved after answering and state change to pending reminder.
This commit is contained in:
parent
bde3452f9b
commit
3330fe9ce7
4 changed files with 26 additions and 2 deletions
|
@ -39,7 +39,7 @@ class Escalation
|
||||||
end
|
end
|
||||||
|
|
||||||
def calculatable?
|
def calculatable?
|
||||||
!escalation_disabled? || preferences.close_at_changed?(ticket)
|
!escalation_disabled? || preferences.close_at_changed?(ticket) || preferences.last_contact_at_changed?(ticket)
|
||||||
end
|
end
|
||||||
|
|
||||||
def calculate!
|
def calculate!
|
||||||
|
|
|
@ -3,7 +3,7 @@ class Escalation
|
||||||
KEYS = %i[escalation_disabled
|
KEYS = %i[escalation_disabled
|
||||||
first_response_at last_update_at close_at escalation_at
|
first_response_at last_update_at close_at escalation_at
|
||||||
sla_id sla_updated_at
|
sla_id sla_updated_at
|
||||||
calendar_id calendar_updated_at].freeze
|
calendar_id calendar_updated_at last_contact_at].freeze
|
||||||
|
|
||||||
attr_reader :hash
|
attr_reader :hash
|
||||||
|
|
||||||
|
@ -39,6 +39,10 @@ class Escalation
|
||||||
@hash[:close_at] != ticket.close_at
|
@hash[:close_at] != ticket.close_at
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def last_contact_at_changed?(ticket)
|
||||||
|
@hash[:last_contact_at] != ticket.last_contact_at
|
||||||
|
end
|
||||||
|
|
||||||
def property_changes?(ticket)
|
def property_changes?(ticket)
|
||||||
%i[first_response_at last_update_at close_at].any? { |elem| send("#{elem}_changed?", ticket) }
|
%i[first_response_at last_update_at close_at].any? { |elem| send("#{elem}_changed?", ticket) }
|
||||||
end
|
end
|
||||||
|
@ -60,6 +64,7 @@ class Escalation
|
||||||
first_response_at: ticket.first_response_at,
|
first_response_at: ticket.first_response_at,
|
||||||
last_update_at: ticket.last_original_update_at,
|
last_update_at: ticket.last_original_update_at,
|
||||||
close_at: ticket.close_at,
|
close_at: ticket.close_at,
|
||||||
|
last_contact_at: ticket.last_contact_at,
|
||||||
sla_id: sla&.id,
|
sla_id: sla&.id,
|
||||||
sla_updated_at: sla&.updated_at,
|
sla_updated_at: sla&.updated_at,
|
||||||
calendar_id: sla&.calendar&.id,
|
calendar_id: sla&.calendar&.id,
|
||||||
|
|
|
@ -67,6 +67,14 @@ RSpec.describe ::Escalation do
|
||||||
|
|
||||||
expect(instance).to be_calculatable
|
expect(instance).to be_calculatable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'true when response to ticket comes while ticket has pending reminder' do
|
||||||
|
ticket.update(state: Ticket::State.find_by(name: 'pending reminder'))
|
||||||
|
|
||||||
|
without_update_escalation_information_callback { create(:'ticket/article', :outbound_email, ticket: ticket) }
|
||||||
|
|
||||||
|
expect(instance).to be_calculatable
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#calculate' do
|
describe '#calculate' do
|
||||||
|
|
|
@ -65,6 +65,17 @@ RSpec.shared_examples 'Ticket::Escalation' do
|
||||||
expect(ticket.close_diff_in_min).to be_nil
|
expect(ticket.close_diff_in_min).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with first response time resolved by answer + state pending reminder' do
|
||||||
|
before do
|
||||||
|
ticket.update(state: Ticket::State.find_by(name: 'pending reminder'))
|
||||||
|
create(:'ticket/article', :outbound_email, ticket: ticket, created_at: '2013-03-21 09:45:00 UTC', updated_at: '2013-03-21 09:45:00 UTC')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does set first_response_diff_in_min' do
|
||||||
|
expect(ticket.reload.first_response_diff_in_min).to eq(45)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'with first response in time' do
|
context 'with first response in time' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
Loading…
Reference in a new issue