From 02c271385627421d90eb0daeaf5b8713abdd1165 Mon Sep 17 00:00:00 2001 From: Johannes Nickel Date: Thu, 13 Jun 2013 15:19:50 +0200 Subject: [PATCH] fest zum test --- app/models/ticket.rb | 7 +++++++ test/unit/ticket_test.rb | 36 ++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/app/models/ticket.rb b/app/models/ticket.rb index b8fb5bd17..17ab6a5d3 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -618,6 +618,9 @@ class Ticket < ApplicationModel end if self.first_response# && !self.first_response_in_min self.first_response_in_min = TimeCalculation.business_time_diff( self.created_at, self.first_response, sla_selected.data, sla_selected.timezone ) + self.first_response_in_min = escalation_suspend( self.first_response, 'real', sla_selected ) + + #self.first_response_in_min = TimeCalculation.business_time_diff( self.first_response_in_min, extended_escalation.to_i, sla_selected.data, sla_selected.timezone ) end # set sla time if sla_selected.first_response_time && self.first_response_in_min @@ -655,9 +658,13 @@ class Ticket < ApplicationModel end if self.close_time# && !self.close_time_in_min self.close_time_in_min = TimeCalculation.business_time_diff( self.created_at, self.close_time, sla_selected.data, sla_selected.timezone ) + puts '#### 1 ' + self.close_time_in_min.to_s + self.close_time_in_min == escalation_suspend( self.close_time, 'real', sla_selected ) + puts '#### 2 ' + self.close_time_in_min.to_s end # set sla time if sla_selected.close_time && self.close_time_in_min + puts '#### 3 ' + sla_selected.close_time.to_s + ' - ' + self.close_time_in_min.to_s self.close_time_diff_in_min = sla_selected.close_time - self.close_time_in_min end self.callback_loop = true diff --git a/test/unit/ticket_test.rb b/test/unit/ticket_test.rb index 496e36509..7d34240aa 100644 --- a/test/unit/ticket_test.rb +++ b/test/unit/ticket_test.rb @@ -618,19 +618,19 @@ class TicketTest < ActiveSupport::TestCase ) # set ticket from 11:00 to pending - History.history_create( - :history_type => 'updated', - :history_object => 'Ticket', - :history_attribute => 'ticket_state', - :o_id => ticket.id, - :id_to => 3, - :id_from => 2, - :value_from => 'open', - :value_to => 'pending', - :created_by_id => 1, - :created_at => '2013-06-04 11:00:00', - :updated_at => '2013-06-04 11:00:00' - ) + #History.history_create( + # :history_type => 'updated', + # :history_object => 'Ticket', + # :history_attribute => 'ticket_state', + # :o_id => ticket.id, + # :id_to => 3, + # :id_from => 2, + # :value_from => 'open', + # :value_to => 'pending', + # :created_by_id => 1, + # :created_at => '2013-06-04 11:00:00', + # :updated_at => '2013-06-04 11:00:00' + #) # set first response in time ticket.update_attributes( @@ -644,7 +644,7 @@ class TicketTest < ActiveSupport::TestCase :o_id => ticket.id, :id_to => 3, :id_from => 2, - :value_from => 'pending', + :value_from => 'open', :value_to => 'closed', :created_by_id => 1, :created_at => '2013-06-04 12:00:00', @@ -675,12 +675,12 @@ class TicketTest < ActiveSupport::TestCase ticket = Ticket.find(ticket.id) assert_equal( ticket.escalation_time.gmtime.to_s, '2013-06-04 12:00:00 UTC', 'ticket.escalation_time verify 1' ) #check escal. time because first resp. is already done assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 11:30:00 UTC', 'ticket.first_response_escal_date verify 1' ) - #assert_equal( ticket.first_response_in_min, 75, 'ticket.first_response_in_min verify 3' ) - #assert_equal( ticket.first_response_diff_in_min, 45, 'ticket.first_response_diff_in_min verify 3' ) + assert_equal( ticket.first_response_in_min, 75, 'ticket.first_response_in_min verify 3' ) + assert_equal( ticket.first_response_diff_in_min, 45, 'ticket.first_response_diff_in_min verify 3' ) #assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 12:30:00 UTC', 'ticket.update_time_escal_date verify 1' ) #assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.close_time_escal_date verify 1' ) - #assert_equal( ticket.close_time_in_min, 90, 'ticket.first_response_in_min verify 3' ) - #assert_equal( ticket.close_time_diff_in_min, 150, 'ticket.first_response_diff_in_min verify 3' ) + assert_equal( ticket.close_time_in_min, 150, 'ticket.close_time_in_min verify 3' ) + assert_equal( ticket.close_time_diff_in_min, 150, 'ticket.close_time_diff_in_min# verify 3' ) delete = sla.destroy assert( delete, "sla destroy" )