[Rt-commit] r8607 - in rtir/branches/2.3-EXPERIMENTAL: .

thayes at bestpractical.com thayes at bestpractical.com
Fri Aug 17 11:36:16 EDT 2007


Author: thayes
Date: Fri Aug 17 11:36:15 2007
New Revision: 8607

Modified:
   rtir/branches/2.3-EXPERIMENTAL/   (props changed)
   rtir/branches/2.3-EXPERIMENTAL/t/017-locking.t

Log:
 r8845 at toth:  toth | 2007-08-17 11:35:56 -0400
 * Added a test for linking an IR to an existing incident (previously only had one for a new incident)
 * Moved tests for Incidents before tests for IR, so that the IR is guaranteed to have at least one incident to link to for the Take lock tests, even on a clean database
 


Modified: rtir/branches/2.3-EXPERIMENTAL/t/017-locking.t
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/t/017-locking.t	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/t/017-locking.t	Fri Aug 17 11:36:15 2007
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 109;
+use Test::More tests => 117;
 use HTTP::Cookies;
 
 require "t/rtir-test.pl";
@@ -17,26 +17,26 @@
 
 my $SUBJECT = "foo " . rand;
 
-diag("Testing Incident Report locking");
-# Create a report
-my $report = create_ir($agent, {Subject => $SUBJECT, Content => "bla", Owner => 'Nobody in particular (Nobody)' });
-    
 
 
-my $ir_obj = RT::Ticket->new(RT::SystemUser());
-my $lock;
+diag("Testing Incident locking")  if $ENV{'TEST_VERBOSE'};
+# Create an incident
+my $inc = create_incident($agent, {Subject => $SUBJECT, Content => "bla", Owner => 'Nobody in particular (Nobody)' });
 
-$ir_obj->Load($report);
-is($ir_obj->Id, $report, "report has right ID");
-is($ir_obj->Subject, $SUBJECT, "subject is right");
+
+my $inc_obj = RT::Ticket->new(RT::SystemUser());
+
+$inc_obj->Load($inc);
+is($inc_obj->Id, $inc, "report has right ID");
+is($inc_obj->Subject, $SUBJECT, "subject is right");
 
 #Hard lock
 diag("Testing hard lock") if $ENV{'TEST_VERBOSE'};
 
-$agent->goto_ticket($report);
+$agent->goto_ticket($inc);
 $agent->follow_link_ok({text => 'Lock', n => '1'}, "Followed 'Lock' link");
-$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Added a hard lock on ticket $report");
-$lock = $ir_obj->Locked();
+$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Added a hard lock on ticket $inc");
+my $lock = $inc_obj->Locked();
 ok(($lock->Content->{'Type'} eq 'Hard'), "Lock is a Hard lock");
 
 ###Testing lock expiration###
@@ -49,9 +49,9 @@
     skip 'Not testing lock expiry--expiration feature turned off', 4 unless $expire;
     sleep $expire;
 
-    $agent->follow_link_ok({text => 'Display', n =>'1'}, "Going back to display page for IR #$report");
-    $agent->content_unlike(qr{<div class="locked-by-you">}, "IR #$report not locked anymore (lock expired)");
-    ok(!$ir_obj->Locked(), "Lock not in the database");
+    $agent->follow_link_ok({text => 'Display', n =>'1'}, "Going back to display page for Incident #$inc");
+    $agent->content_unlike(qr{<div class="locked-by-you">}, "Incident #$inc not locked anymore (lock expired)");
+    ok(!$inc_obj->Locked(), "Lock not in the database");
 
 
     $agent->follow_link_ok({text => 'Lock', n => '1'}, "Followed 'Lock' link again");
@@ -59,6 +59,141 @@
 
 sleep 5;    #Otherwise, we run the risk of getting "You have locked this ticket" (see /Elements/ShowLock)
 
+
+###Testing Reply.html locking###
+
+$agent->follow_link_ok({text => 'Reply to Reporters', n => '1'}, "Followed Reply to Reporters link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have had this ticket locked for \d+}ims, "Reply to Reporters page is locked");
+$agent->form_number(3);
+$agent->click('SubmitTicket');
+diag("Submitted Reply form") if $ENV{'TEST_VERBOSE'};
+$agent->content_like(qr{<div class="locked-by-you">}, "Incident $inc is still locked");
+
+
+$agent->follow_link_ok({text => 'Edit', n => '1'}, "Followed Edit link");
+
+$agent->content_like(qr{<div class="locked-by-you">\s*You have had this ticket locked for \d+}ims, "Edit page is locked");
+
+$agent->form_number(3);
+$agent->submit();
+diag("Submitted Edit form") if $ENV{'TEST_VERBOSE'};
+$agent->content_like(qr{<div class="locked-by-you">}, "Incident $inc is still locked");
+
+$agent->follow_link_ok({text => 'Unlock', n => '1'}, "Unlocking Incident $inc");
+$agent->content_like(qr{<div class="locked-by-you">\s*You had this ticket locked for \d+ \w+\. It is now unlocked\.}ims, "Incident $inc is not locked");
+$agent->follow_link_ok({text => 'Lock', n => '1'}, "Followed 'Lock' link again");
+sleep 5;    #Otherwise, we run the risk of getting "You have locked this ticket" (see /Elements/ShowLock)
+$agent->follow_link_ok({text => 'Split', n => '1'}, "Followed Split link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have had this ticket locked for \d+}ims, "Split page is still locked");
+$agent->form_number(3);
+my $nobody;
+if($agent->content =~ qr{<option.+?value="(\d+)"\s*>Nobody in particular &#40;Nobody&#41;</option>}ims) {
+    $nobody = $1;
+    $agent->field('Owner', $nobody);
+}
+$agent->click('CreateIncident');
+diag("Submitted Split form") if $ENV{'TEST_VERBOSE'};
+my $inc_id2;
+if($agent->content =~ qr{<li>Ticket (\d+) created in queue.*</li>}i) {
+    $inc_id2 = $1;
+}
+$agent->content_like(qr{<div class="locked-by-you">\s*You have had Ticket #$inc locked for \d+ \w+\.\W+</div>}ims, "Incident $inc is still locked");
+display_ticket($agent, $inc);
+$agent->follow_link_ok({text => 'Merge', n => '1'}, "Followed Merge link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have had this ticket locked for \d+}ims, "Merge page is still locked");
+$agent->form_number(3);
+
+$agent->field("SelectedTicket", $inc_id2);
+$agent->submit();
+diag("Submitted Merge form") if $ENV{'TEST_VERBOSE'};
+$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Lock from $inc moved to $inc_id2");
+$inc = $inc_id2;
+$agent->follow_link_ok({text => 'Unlock', n => '1'}, "Removing hard lock on Incident $inc");
+
+
+#Auto lock
+diag("Testing auto lock") if $ENV{'TEST_VERBOSE'};
+
+ 
+###Testing Reply.html locking###
+
+$agent->follow_link_ok({text => 'Reply to Reporters', n => '1'}, "Followed Reply to Reporters link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Reply to Reporters page is locked");
+sleep 5;
+$agent->form_number(3);
+$agent->click('SubmitTicket');
+diag("Submitted Reply form") if $ENV{'TEST_VERBOSE'};
+$agent->content_like(qr{<div class="locked-by-you">\s*You had this ticket locked for \d+ \w+\. It is now unlocked\.}ims, "Incident $inc is still locked");
+
+
+$agent->follow_link_ok({text => 'Edit', n => '1'}, "Followed Edit link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket}ims, "Edit page is auto locked");
+# Without this, the lock type doesn't seem to refresh, even on successive calls to Locked()
+$inc_obj->Load($inc);
+$lock = $inc_obj->Locked();
+ok(($lock->Content->{'Type'} eq 'Auto'), "Lock is an Auto lock");
+$agent->form_number(3);
+$agent->submit();
+diag("Submitted Edit form") if $ENV{'TEST_VERBOSE'};
+$agent->content_unlike(qr{<div class="locked-by-you">.+\.It is now unlocked\.}ims, "Incident $inc is not locked");
+
+$agent->follow_link_ok({text => 'Split', n => '1'}, "Followed Split link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket}ims, "Split page is auto locked");
+$agent->form_number(3);
+$agent->field('Owner', $nobody);
+sleep 5;
+$agent->click('CreateIncident');
+diag("Submitted Split form") if $ENV{'TEST_VERBOSE'};
+$agent->content_like(qr{<div class="locked-by-you">\s*You had Ticket #$inc locked for \d+ \w+. It is now unlocked\.}ims, "Incident $inc is not locked");
+if($agent->content =~ qr{<li>Ticket (\d+) created in queue.*</li>}i) {
+    $inc_id2 = $1;
+}
+display_ticket($agent, $inc);
+$agent->follow_link_ok({text => 'Merge', n => '1'}, "Followed Merge link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Merge page is locked");
+$agent->form_number(3);
+
+$agent->field("SelectedTicket", $inc_id2);
+$agent->submit();
+diag("Submitted Merge form") if $ENV{'TEST_VERBOSE'};
+$agent->content_unlike(qr{<div class="locked-by-you">}ims, "Lock from $inc not moved to $inc_id2");
+$inc = $inc_id2;
+
+$agent->follow_link_ok({text => 'Lock', n => '1'}, "Hard locked to test multi-user lock");
+
+
+
+diag("Testing Incident locking from other user's point of view");
+
+display_ticket($root, $inc);
+$root->content_like(qr{<div class="locked">}, "Incident #$inc is locked by another");
+$root->follow_link_ok({text => 'Break lock', n => '1'}, "Breaking lock on Incident #$inc");
+$root->content_like(qr{<li>You have broken the lock on this ticket</li>}, "Lock on Incident #$inc is broken");
+
+
+diag("Testing Incident Report locking")  if $ENV{'TEST_VERBOSE'};
+# Create a report
+my $report = create_ir($agent, {Subject => $SUBJECT, Content => "bla", Owner => 'Nobody in particular &#40;Nobody&#41;' });
+    
+
+
+my $ir_obj = RT::Ticket->new(RT::SystemUser());
+
+$ir_obj->Load($report);
+is($ir_obj->Id, $report, "report has right ID");
+is($ir_obj->Subject, $SUBJECT, "subject is right");
+
+#Hard lock
+diag("Testing hard lock") if $ENV{'TEST_VERBOSE'};
+
+$agent->goto_ticket($report);
+$agent->follow_link_ok({text => 'Lock', n => '1'}, "Followed 'Lock' link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Added a hard lock on ticket $report");
+$lock = $ir_obj->Locked();
+ok(($lock->Content->{'Type'} eq 'Hard'), "Lock is a Hard lock");
+
+sleep 5;    #Otherwise, we run the risk of getting "You have locked this ticket" (see /Elements/ShowLock)
+
 ###Testing Update.html locking###
 
 $agent->follow_link_ok({text => 'Comment', n => '1'}, "Followed Comment link");
@@ -89,18 +224,14 @@
 $agent->follow_link_ok({text => 'Split', n => '1'}, "Followed Split link");
 $agent->content_like(qr{<div class="locked-by-you">\s*You have had this ticket locked for \d+}ims, "Split page is still locked");
 $agent->form_number(3);
-my $nobody;
-if($agent->content =~ qr{<option.+?value="(\d+)"\s*>Nobody in particular &#40;Nobody&#41;</option>}ims) {
-    $nobody = $1;
-    $agent->field('Owner', $nobody);
-}
+$agent->field('Owner', $nobody);
 $agent->click('Create');
 diag("Submitted Split form") if $ENV{'TEST_VERBOSE'};
 my $ir_id2;
 if($agent->content =~ qr{<li>Ticket (\d+) created in queue.*</li>}i) {
     $ir_id2 = $1;
 }
-$agent->content_like(qr{<div class="locked-by-you">\s*You have had Ticket #$report locked for \d+ \w+\.}ims, "IR $report is still locked");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have had Ticket #$report locked for \d+ \w+\.\W+</div>}ims, "IR $report is still locked");
 
 ###Testing Merge.html locking###
 
@@ -192,6 +323,27 @@
 $agent->goto_ticket($report);
 $agent->content_unlike(qr{<div class="locked-by-you">}ims, "IR #$report is not locked");
 
+###Testing linking to existing incident###
+$agent->follow_link_ok({text => '[Unlink]', n => '1'}, "Followed Unlink link");
+$agent->follow_link_ok({text => 'Edit', n => '1'}, "Followed Edit link");
+$agent->form_number(3);
+$agent->field('Owner', $nobody);
+$agent->click('SaveChanges');
+$agent->content_like(qr{<li>Owner changed from \w+ to Nobody</li>}, "Owner changed to Nobody");
+$agent->follow_link_ok({text => 'Take', n => '1'}, "Followed Take link again");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Got a lock from Taking");
+sleep 5;
+$agent->follow_link_ok({text => '[Link]', n => '1'}, "Followed Link (to existing incident) link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have had this ticket locked for \d+ \w+\.}, "IR still locked on Link To Incident page");
+###Pick a ticket to link to (we don't really care which)
+$agent->content =~ qr{<input type="radio" name="SelectedTicket" value="(\d+)"\s*/>}ims;
+my $inc_to_link_to = $1;
+$agent->form_number(3);
+$agent->field('SelectedTicket', $inc_to_link_to);
+$agent->click('LinkChild');
+$agent->content_like(qr{<div class="locked-by-you">\s*You had Ticket #$report locked for \d+ \w+. It is now unlocked\.}ims, "Removed IR #$report Take lock");
+
+$agent->goto_ticket($report);
 $agent->follow_link_ok({text => 'Lock', n => '1'}, "Hard locked to test multi-user lock");
 
 
@@ -207,133 +359,6 @@
 
 
 
-diag("Testing Incident locking");
-# Create an incident
-my $inc = create_incident($agent, {Subject => $SUBJECT, Content => "bla", Owner => 'Nobody in particular &#40;Nobody&#41;' });
-
-
-my $inc_obj = RT::Ticket->new(RT::SystemUser());
-
-$inc_obj->Load($inc);
-is($inc_obj->Id, $inc, "report has right ID");
-is($inc_obj->Subject, $SUBJECT, "subject is right");
-
-#Hard lock
-diag("Testing hard lock") if $ENV{'TEST_VERBOSE'};
-
-$agent->goto_ticket($inc);
-$agent->follow_link_ok({text => 'Lock', n => '1'}, "Followed 'Lock' link");
-$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Added a hard lock on ticket $inc");
-$lock = $inc_obj->Locked();
-ok(($lock->Content->{'Type'} eq 'Hard'), "Lock is a Hard lock");
-sleep 5;    #Otherwise, we run the risk of getting "You have locked this ticket" (see /Elements/ShowLock)
-
-
-###Testing Reply.html locking###
-
-$agent->follow_link_ok({text => 'Reply to Reporters', n => '1'}, "Followed Reply to Reporters link");
-$agent->content_like(qr{<div class="locked-by-you">\s*You have had this ticket locked for \d+}ims, "Reply to Reporters page is locked");
-$agent->form_number(3);
-$agent->click('SubmitTicket');
-diag("Submitted Reply form") if $ENV{'TEST_VERBOSE'};
-$agent->content_like(qr{<div class="locked-by-you">}, "Incident $inc is still locked");
-
-
-$agent->follow_link_ok({text => 'Edit', n => '1'}, "Followed Edit link");
-
-$agent->content_like(qr{<div class="locked-by-you">\s*You have had this ticket locked for \d+}ims, "Edit page is locked");
-
-$agent->form_number(3);
-$agent->submit();
-diag("Submitted Edit form") if $ENV{'TEST_VERBOSE'};
-$agent->content_like(qr{<div class="locked-by-you">}, "Incident $inc is still locked");
-
-$agent->follow_link_ok({text => 'Unlock', n => '1'}, "Unlocking Incident $inc");
-$agent->content_like(qr{<div class="locked-by-you">\s*You had this ticket locked for \d+ \w+\. It is now unlocked\.}ims, "Incident $inc is not locked");
-$agent->follow_link_ok({text => 'Lock', n => '1'}, "Followed 'Lock' link again");
-sleep 5;    #Otherwise, we run the risk of getting "You have locked this ticket" (see /Elements/ShowLock)
-$agent->follow_link_ok({text => 'Split', n => '1'}, "Followed Split link");
-$agent->content_like(qr{<div class="locked-by-you">\s*You have had this ticket locked for \d+}ims, "Split page is still locked");
-$agent->form_number(3);
-$agent->field('Owner', $nobody);
-$agent->click('CreateIncident');
-diag("Submitted Split form") if $ENV{'TEST_VERBOSE'};
-my $inc_id2;
-if($agent->content =~ qr{<li>Ticket (\d+) created in queue.*</li>}i) {
-    $inc_id2 = $1;
-}
-$agent->content_like(qr{<div class="locked-by-you">\s*You have had Ticket #$inc locked for \d+ \w+\.}ims, "Incident $inc is still locked");
-display_ticket($agent, $inc);
-$agent->follow_link_ok({text => 'Merge', n => '1'}, "Followed Merge link");
-$agent->content_like(qr{<div class="locked-by-you">\s*You have had this ticket locked for \d+}ims, "Merge page is still locked");
-$agent->form_number(3);
-
-$agent->field("SelectedTicket", $inc_id2);
-$agent->submit();
-diag("Submitted Merge form") if $ENV{'TEST_VERBOSE'};
-$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Lock from $inc moved to $inc_id2");
-$inc = $inc_id2;
-$agent->follow_link_ok({text => 'Unlock', n => '1'}, "Removing hard lock on Incident $inc");
-
-
-#Auto lock
-diag("Testing auto lock") if $ENV{'TEST_VERBOSE'};
-
- 
-###Testing Reply.html locking###
-
-$agent->follow_link_ok({text => 'Reply to Reporters', n => '1'}, "Followed Reply to Reporters link");
-$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Reply to Reporters page is locked");
-sleep 5;
-$agent->form_number(3);
-$agent->click('SubmitTicket');
-diag("Submitted Reply form") if $ENV{'TEST_VERBOSE'};
-$agent->content_like(qr{<div class="locked-by-you">\s*You had this ticket locked for \d+ \w+\. It is now unlocked\.}ims, "Incident $inc is still locked");
-
-
-$agent->follow_link_ok({text => 'Edit', n => '1'}, "Followed Edit link");
-$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket}ims, "Edit page is auto locked");
-# Without this, the lock type doesn't seem to refresh, even on successive calls to Locked()
-$inc_obj->Load($inc);
-$lock = $inc_obj->Locked();
-ok(($lock->Content->{'Type'} eq 'Auto'), "Lock is an Auto lock");
-$agent->form_number(3);
-$agent->submit();
-diag("Submitted Edit form") if $ENV{'TEST_VERBOSE'};
-$agent->content_unlike(qr{<div class="locked-by-you">.+\.It is now unlocked\.}ims, "Incident $inc is not locked");
-
-$agent->follow_link_ok({text => 'Split', n => '1'}, "Followed Split link");
-$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket}ims, "Split page is auto locked");
-$agent->form_number(3);
-$agent->field('Owner', $nobody);
-sleep 5;
-$agent->click('CreateIncident');
-diag("Submitted Split form") if $ENV{'TEST_VERBOSE'};
-$agent->content_like(qr{<div class="locked-by-you">\s*You had Ticket #$inc locked for \d+ \w+. It is now unlocked\.}ims, "Incident $inc is not locked");
-if($agent->content =~ qr{<li>Ticket (\d+) created in queue.*</li>}i) {
-    $inc_id2 = $1;
-}
-display_ticket($agent, $inc);
-$agent->follow_link_ok({text => 'Merge', n => '1'}, "Followed Merge link");
-$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Merge page is locked");
-$agent->form_number(3);
-
-$agent->field("SelectedTicket", $inc_id2);
-$agent->submit();
-diag("Submitted Merge form") if $ENV{'TEST_VERBOSE'};
-$agent->content_unlike(qr{<div class="locked-by-you">}ims, "Lock from $inc not moved to $inc_id2");
-$report = $inc_id2;
-
-$agent->follow_link_ok({text => 'Lock', n => '1'}, "Hard locked to test multi-user lock");
-
-
-
-diag("Testing Incident locking from other user's point of view");
-
-display_ticket($root, $inc);
-$root->content_like(qr{<div class="locked">}, "Incident #$inc is locked by another");
-$root->follow_link_ok({text => 'Break lock', n => '1'}, "Breaking lock on Incident #$inc");
-$root->content_like(qr{<li>You have broken the lock on this ticket</li>}, "Lock on Incident #$inc is broken");
 
 
 


More information about the Rt-commit mailing list