[Bps-public-commit] r19305 - RT-Extension-SLA/t
ruz at bestpractical.com
ruz at bestpractical.com
Mon Apr 20 13:56:46 EDT 2009
Author: ruz
Date: Mon Apr 20 13:56:46 2009
New Revision: 19305
Modified:
RT-Extension-SLA/t/due.t
Log:
* add tests for KeepInLoop thing
Modified: RT-Extension-SLA/t/due.t
==============================================================================
--- RT-Extension-SLA/t/due.t (original)
+++ RT-Extension-SLA/t/due.t Mon Apr 20 13:56:46 2009
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 52;
+use Test::More tests => 72;
require 't/utils.pl';
@@ -168,6 +168,116 @@
}
}
+diag 'check that reply to requestors dont unset due date with KeepInLoop';
+{
+ %RT::ServiceAgreements = (
+ Default => '2',
+ Levels => {
+ '2' => {
+ Response => { RealMinutes => 60*2 },
+ KeepInLoop => { RealMinutes => 60*4 },
+ },
+ },
+ );
+
+ my $root = RT::User->new( $RT::SystemUser );
+ $root->LoadByEmail('root at localhost');
+ ok $root->id, 'loaded root user';
+
+ # requestor creates
+ my $id;
+ my $due;
+ {
+ my $ticket = RT::Ticket->new( $root );
+ ($id) = $ticket->Create(
+ Queue => 'General',
+ Subject => 'xxx',
+ Requestor => $root->id,
+ );
+ ok $id, "created ticket #$id";
+
+ is $ticket->FirstCustomFieldValue('SLA'), '2', 'default sla';
+
+ $due = $ticket->DueObj->Unix;
+ ok $due > 0, 'Due date is set';
+ }
+
+ # non-requestor reply
+ {
+ my $ticket = RT::Ticket->new( $RT::SystemUser );
+ $ticket->Load( $id );
+ ok $ticket->id, "loaded ticket #$id";
+ $ticket->Correspond( Content => 'we are working on this.' );
+
+ $ticket = RT::Ticket->new( $root );
+ $ticket->Load( $id );
+ ok $ticket->id, "loaded ticket #$id";
+
+ my $tmp = $ticket->DueObj->Unix;
+ ok $tmp > 0, 'Due date is set';
+ ok $tmp > $due, "keep in loop is 4hours when response is 2hours";
+ $due = $tmp;
+ }
+
+ # non-requestor reply again
+ {
+ sleep 1;
+ my $ticket = RT::Ticket->new( $RT::SystemUser );
+ $ticket->Load( $id );
+ ok $ticket->id, "loaded ticket #$id";
+ $ticket->Correspond( Content => 'we are still working on this.' );
+
+ $ticket = RT::Ticket->new( $root );
+ $ticket->Load( $id );
+ ok $ticket->id, "loaded ticket #$id";
+
+ my $tmp = $ticket->DueObj->Unix;
+ ok $tmp > 0, 'Due date is set';
+ ok $tmp > $due, "keep in loop sligtly moved";
+ $due = $tmp;
+ }
+
+ # requestor reply
+ my $last_unreplied_due;
+ {
+ my $ticket = RT::Ticket->new( $root );
+ $ticket->Load( $id );
+ ok $ticket->id, "loaded ticket #$id";
+
+ $ticket->Correspond( Content => 'what\'s going on with my ticket?' );
+
+ $ticket = RT::Ticket->new( $root );
+ $ticket->Load( $id );
+ ok $ticket->id, "loaded ticket #$id";
+
+ my $tmp = $ticket->DueObj->Unix;
+ ok $tmp > 0, 'Due date is set';
+ ok $tmp < $due, "response deadline is 2 hours earlier";
+ $due = $tmp;
+
+ $last_unreplied_due = $due;
+ }
+
+ # sleep at least one second and requestor replies again
+ sleep 1;
+ {
+ my $ticket = RT::Ticket->new( $root );
+ $ticket->Load( $id );
+ ok $ticket->id, "loaded ticket #$id";
+
+ $ticket->Correspond( Content => 'HEY! Were is my answer?' );
+
+ $ticket = RT::Ticket->new( $root );
+ $ticket->Load( $id );
+ ok $ticket->id, "loaded ticket #$id";
+
+ my $tmp = $ticket->DueObj->Unix;
+ ok $tmp > 0, 'Due date is set';
+ is $tmp, $last_unreplied_due, 'due is unchanged';
+ $due = $tmp;
+ }
+}
+
diag 'check that replies dont affect resolve deadlines';
{
%RT::ServiceAgreements = (
More information about the Bps-public-commit
mailing list