[Bps-public-commit] r9481 - RT-Extension-SLA/t

ruz at bestpractical.com ruz at bestpractical.com
Fri Oct 26 21:50:56 EDT 2007


Author: ruz
Date: Fri Oct 26 21:50:56 2007
New Revision: 9481

Modified:
   RT-Extension-SLA/t/due.t

Log:
* add more tests

Modified: RT-Extension-SLA/t/due.t
==============================================================================
--- RT-Extension-SLA/t/due.t	(original)
+++ RT-Extension-SLA/t/due.t	Fri Oct 26 21:50:56 2007
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 10;
+use Test::More tests => 46;
 
 require 't/utils.pl';
 
@@ -114,7 +114,23 @@
         ok $due <= 0, 'Due date is not set';
     }
 
+    # non-requestor reply again
+    {
+        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 $due = $ticket->DueObj->Unix;
+        ok $due <= 0, 'Due date is not set';
+    }
+
     # requestor reply
+    my $last_unreplied_due;
     {
         my $ticket = RT::Ticket->new( $root );
         $ticket->Load( $id );
@@ -128,6 +144,26 @@
 
         my $due = $ticket->DueObj->Unix;
         ok $due > 0, 'Due date is set again';
+
+        $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 $due = $ticket->DueObj->Unix;
+        ok $due > 0, 'Due date is still set';
+        is $due, $last_unreplied_due, 'due is unchanged';
     }
 }
 
@@ -195,3 +231,66 @@
     }
 }
 
+diag 'check that owner is not treated as requestor';
+{
+    %RT::SLA = (
+        Default => '2',
+        Levels => {
+            '2' => { Response => { RealMinutes => 60*2 } },
+        },
+    );
+
+    my $root = RT::User->new( $RT::SystemUser );
+    $root->LoadByEmail('root at localhost');
+    ok $root->id, 'loaded root user';
+
+    # requestor creates and he is owner
+    my $id;
+    {
+        my $ticket = RT::Ticket->new( $root );
+        ($id) = $ticket->Create(
+            Queue => 'General',
+            Subject => 'xxx',
+            Requestor => $root->id,
+            Owner => $root->id,
+        );
+        ok $id, "created ticket #$id";
+
+        is $ticket->FirstCustomFieldValue('SLA'), '2', 'default sla';
+        is $ticket->Owner, $root->id, 'correct owner';
+
+        my $due = $ticket->DueObj->Unix;
+        ok $due <= 0, 'Due date is not set';
+    }
+}
+
+diag 'check that response deadline is left alone when there is no requestor';
+{
+    %RT::SLA = (
+        Default => '2',
+        Levels => {
+            '2' => { Response => { RealMinutes => 60*2 } },
+        },
+    );
+
+    my $root = RT::User->new( $RT::SystemUser );
+    $root->LoadByEmail('root at localhost');
+    ok $root->id, 'loaded root user';
+
+    # create a ticket without requestor
+    my $id;
+    {
+        my $ticket = RT::Ticket->new( $root );
+        ($id) = $ticket->Create(
+            Queue => 'General',
+            Subject => 'xxx',
+        );
+        ok $id, "created ticket #$id";
+
+        is $ticket->FirstCustomFieldValue('SLA'), '2', 'default sla';
+
+        my $due = $ticket->DueObj->Unix;
+        ok $due <= 0, 'Due date is not set';
+    }
+}
+



More information about the Bps-public-commit mailing list