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

thayes at bestpractical.com thayes at bestpractical.com
Fri Aug 10 18:24:53 EDT 2007


Author: thayes
Date: Fri Aug 10 18:24:52 2007
New Revision: 8507

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

Log:
 r8724 at toth:  toth | 2007-08-10 18:23:31 -0400
 * Minor formatting changes
 


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 10 18:24:52 2007
@@ -23,316 +23,316 @@
     
 
 
-    my $ir_obj = RT::Ticket->new(RT::SystemUser());
-    my $lock;
+my $ir_obj = RT::Ticket->new(RT::SystemUser());
+my $lock;
 
-    $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");
-    $agent->content_like(qr{<a href="/Ticket/Display.html\?id=$report&Lock=remove">Unlock</a>}i,
-                            "Unlock link found");
-    $lock = $ir_obj->Locked();
-    ok(($lock->Content->{'Type'} eq 'Hard'), "Lock is a Hard lock");
-    
-    ###Testing lock expiration###
-    ###Be sure to set LockExpiry to a short time (say, 30) in RT_SiteConfig.pm, or you'll be waiting
-    ###for a while for this test to finish###
-    
-    my $expire = RT->Config->Get('LockExpiry');
-    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 => 'Lock', n => '1'}, "Followed 'Lock' link again");
-    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");
-    $agent->content_like(qr{<div class="locked-by-you">\s*You have had this ticket locked for \d+}ims, "Comment page is locked");
-    $agent->form_number(3);
-    $agent->submit();
-    diag("Submitted Comment form") if $ENV{'TEST_VERBOSE'};
-    $agent->content_like(qr{<div class="locked-by-you">}, "IR $report is still locked");
-    
-    ###Testing Edit.html locking###
-    
-    $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">}, "IR $report is still locked");
-
-    $agent->follow_link_ok({text => 'Unlock', n => '1'}, "Unlocking IR $report");
-    $agent->content_like(qr{<div class="locked-by-you">\s*You had this ticket locked for \d+ \w+\. It is now unlocked\.}ims, "IR $report 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)
-    
-    
-    ###Testing Split.html locking###
-    
-    $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('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");
-    
-    
-    ###Testing Merge.html locking###
-    
-    display_ticket($agent, $report);
-    $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", $ir_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 $report moved to $ir_id2");
-    $report = $ir_id2;
-    $agent->follow_link_ok({text => 'Unlock', n => '1'}, "Removing hard lock on IR $report");
-    
-    
-    #Auto lock
-    diag("Testing auto lock") if $ENV{'TEST_VERBOSE'};
-    
-    ###Testing Update.html locking###
-    
-    $agent->follow_link_ok({text => 'Comment', n => '1'}, "Followed Comment link");
-    $agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket}ims, "Comment page is auto locked");
-    # Without this, the lock type doesn't seem to refresh, even on successive calls to Locked()
-    $ir_obj->Load($report);
-    $lock = $ir_obj->Locked();
-    ok(($lock->Content->{'Type'} eq 'Auto'), "Lock is an Auto lock");
-    sleep 5;
-    $agent->form_number(3);
-    $agent->click('SubmitTicket');
-    diag("Submitted Comment form") if $ENV{'TEST_VERBOSE'};
-    $agent->content_like(qr{<div class="locked-by-you">.+\. It is now unlocked\.}ims, "IR $report is still locked");
-    
-    
-    ###Testing Edit.html locking###
-    
-    $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");
-    $agent->form_number(3);
-    sleep 5;
-    $agent->click('SaveChanges');
-    diag("Submitted Edit form") if $ENV{'TEST_VERBOSE'};
-    $agent->content_like(qr{<div class="locked-by-you">.+\. It is now unlocked\.}ims, "IR $report 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);
-    sleep 5;
-    $agent->click('Create');
-    diag("Submitted Split form") if $ENV{'TEST_VERBOSE'};
-    $agent->content_like(qr{<div class="locked-by-you">\s*You had Ticket #$report locked for \d+ \w+. It is now unlocked\.}ims, "IR $report is not locked");
-    if($agent->content =~ qr{<li>Ticket (\d+) created in queue.*</li>}i) {
-        $ir_id2 = $1;
-    }
-    display_ticket($agent, $report);
-    $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", $ir_id2);
-    $agent->submit();
-    diag("Submitted Merge form") if $ENV{'TEST_VERBOSE'};
-    $agent->content_unlike(qr{<div class="locked-by-you">}ims, "Lock from $report not moved to $ir_id2");
-    $report = $ir_id2;
-   
-    #Now we need to set the owner to Nobody so that we can take the ticket for the Take tests
-    $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");
+$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");
+$agent->content_like(qr{<a href="/Ticket/Display.html\?id=$report&Lock=remove">Unlock</a>}i,
+                        "Unlock link found");
+$lock = $ir_obj->Locked();
+ok(($lock->Content->{'Type'} eq 'Hard'), "Lock is a Hard lock");
 
-    #Take lock
-    diag("Testing take lock") if $ENV{'TEST_VERBOSE'};
-    $agent->follow_link_ok({text => 'Take', n => '1'}, "Followed Take link");
-    $agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Got a lock from Taking");
-    $ir_obj->Load($report);
-    $lock = $ir_obj->Locked();
-    ok(($lock->Content->{'Type'} eq 'Take'), "Lock is a Take lock");
-    sleep 5;
-    $agent->follow_link_ok({text => '[New]', n => '1'}, "Followed New (incident to link to) link");
-    $agent->content_like(qr{<div class="locked-by-you">\s*You have had Ticket #$report locked for \d+ \w+\.}, "IR #$report is locked on Create Incident page");
-    $agent->form_number(3);
-    $agent->field('Subject', 'Incident linked to Lock Testing IR');
-    $agent->click('CreateIncident');
-    $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->content_unlike(qr{<div class="locked-by-you">}ims, "IR #$report is not locked");
-    
-    $agent->follow_link_ok({text => 'Lock', n => '1'}, "Hard locked to test multi-user lock");
+###Testing lock expiration###
+###Be sure to set LockExpiry to a short time (say, 30) in RT_SiteConfig.pm, or you'll be waiting
+###for a while for this test to finish###
 
+my $expire = RT->Config->Get('LockExpiry');
+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");
 
 
-    diag("Testing IR locking from other user's point of view");
+$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)
 
-    go_home($root);
-    display_ticket($root, $report);
-    $root->content_like(qr{<div class="locked">}, "IR #$report is locked by another");
-    $root->follow_link_ok({text => 'Break lock', n => '1'}, "Breaking lock on IR #$report");
-    $root->content_like(qr{<li>You have broken the lock on this ticket</li>}, "Lock on IR #$report is broken");
+###Testing Update.html locking###
 
+$agent->follow_link_ok({text => 'Comment', n => '1'}, "Followed Comment link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have had this ticket locked for \d+}ims, "Comment page is locked");
+$agent->form_number(3);
+$agent->submit();
+diag("Submitted Comment form") if $ENV{'TEST_VERBOSE'};
+$agent->content_like(qr{<div class="locked-by-you">}, "IR $report is still locked");
 
+###Testing Edit.html locking###
 
-diag("Testing Incident locking");
-# Create an incident
-my $inc = create_incident($agent, {Subject => $SUBJECT, Content => "bla", Owner => 'Nobody in particular &#40;Nobody&#41;' });
+$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">}, "IR $report is still locked");
 
-    my $inc_obj = RT::Ticket->new(RT::SystemUser());
+$agent->follow_link_ok({text => 'Unlock', n => '1'}, "Unlocking IR $report");
+$agent->content_like(qr{<div class="locked-by-you">\s*You had this ticket locked for \d+ \w+\. It is now unlocked\.}ims, "IR $report 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)
 
-    $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");
-    $agent->content_like(qr{<a href="/Ticket/Display.html\?id=$inc&Lock=remove">Unlock</a>}i,
-                            "Unlock link found");
-    $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">}, "Ticket $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);
+
+###Testing Split.html locking###
+
+$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);
-    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->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");
+
+###Testing Merge.html locking###
+
+display_ticket($agent, $report);
+$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", $ir_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 $report moved to $ir_id2");
+$report = $ir_id2;
+$agent->follow_link_ok({text => 'Unlock', n => '1'}, "Removing hard lock on IR $report");
+
+
+#Auto lock
+diag("Testing auto lock") if $ENV{'TEST_VERBOSE'};
+
+###Testing Update.html locking###
+
+$agent->follow_link_ok({text => 'Comment', n => '1'}, "Followed Comment link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket}ims, "Comment page is auto locked");
+# Without this, the lock type doesn't seem to refresh, even on successive calls to Locked()
+$ir_obj->Load($report);
+$lock = $ir_obj->Locked();
+ok(($lock->Content->{'Type'} eq 'Auto'), "Lock is an Auto lock");
+sleep 5;
+$agent->form_number(3);
+$agent->click('SubmitTicket');
+diag("Submitted Comment form") if $ENV{'TEST_VERBOSE'};
+$agent->content_like(qr{<div class="locked-by-you">.+\. It is now unlocked\.}ims, "IR $report is still locked");
+
+
+###Testing Edit.html locking###
+
+$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");
+$agent->form_number(3);
+sleep 5;
+$agent->click('SaveChanges');
+diag("Submitted Edit form") if $ENV{'TEST_VERBOSE'};
+$agent->content_like(qr{<div class="locked-by-you">.+\. It is now unlocked\.}ims, "IR $report 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);
+sleep 5;
+$agent->click('Create');
+diag("Submitted Split form") if $ENV{'TEST_VERBOSE'};
+$agent->content_like(qr{<div class="locked-by-you">\s*You had Ticket #$report locked for \d+ \w+. It is now unlocked\.}ims, "IR $report is not locked");
+if($agent->content =~ qr{<li>Ticket (\d+) created in queue.*</li>}i) {
+    $ir_id2 = $1;
+}
+display_ticket($agent, $report);
+$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", $ir_id2);
+$agent->submit();
+diag("Submitted Merge form") if $ENV{'TEST_VERBOSE'};
+$agent->content_unlike(qr{<div class="locked-by-you">}ims, "Lock from $report not moved to $ir_id2");
+$report = $ir_id2;
+
+#Now we need to set the owner to Nobody so that we can take the ticket for the Take tests
+$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");
+
+
+
+#Take lock
+diag("Testing take lock") if $ENV{'TEST_VERBOSE'};
+$agent->follow_link_ok({text => 'Take', n => '1'}, "Followed Take link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have locked this ticket\.}ims, "Got a lock from Taking");
+$ir_obj->Load($report);
+$lock = $ir_obj->Locked();
+ok(($lock->Content->{'Type'} eq 'Take'), "Lock is a Take lock");
+sleep 5;
+$agent->follow_link_ok({text => '[New]', n => '1'}, "Followed New (incident to link to) link");
+$agent->content_like(qr{<div class="locked-by-you">\s*You have had Ticket #$report locked for \d+ \w+\.}, "IR #$report is locked on Create Incident page");
+$agent->form_number(3);
+$agent->field('Subject', 'Incident linked to Lock Testing IR');
+$agent->click('CreateIncident');
+$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->content_unlike(qr{<div class="locked-by-you">}ims, "IR #$report is not locked");
+
+$agent->follow_link_ok({text => 'Lock', n => '1'}, "Hard locked to test multi-user lock");
+
+
+
+
+diag("Testing IR locking from other user's point of view");
+
+go_home($root);
+display_ticket($root, $report);
+$root->content_like(qr{<div class="locked">}, "IR #$report is locked by another");
+$root->follow_link_ok({text => 'Break lock', n => '1'}, "Breaking lock on IR #$report");
+$root->content_like(qr{<li>You have broken the lock on this ticket</li>}, "Lock on IR #$report is broken");
+
 
-    $agent->follow_link_ok({text => 'Lock', n => '1'}, "Hard locked to test multi-user lock");
 
+diag("Testing Incident locking");
+# Create an incident
+my $inc = create_incident($agent, {Subject => $SUBJECT, Content => "bla", Owner => 'Nobody in particular &#40;Nobody&#41;' });
 
 
-    diag("Testing Incident locking from other user's point of view");
+my $inc_obj = RT::Ticket->new(RT::SystemUser());
 
-    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");
+$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");
+$agent->content_like(qr{<a href="/Ticket/Display.html\?id=$inc&Lock=remove">Unlock</a>}i,
+                        "Unlock link found");
+$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");
 
 
 

Modified: rtir/branches/2.3-EXPERIMENTAL/t/rtir-test.pl
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/t/rtir-test.pl	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/t/rtir-test.pl	Fri Aug 10 18:24:52 2007
@@ -56,12 +56,12 @@
 }
 
 sub ticket_state {
-	my $agent = shift;
-	my $id = shift;
-	
-	display_ticket($agent, $id);
-	$agent->content =~ qr{State:\s*</td>\s*<td[^>]*?>\s*<span class="cf-value">([\w ]+)</span>}ism;
-	return $1;
+    my $agent = shift;
+    my $id = shift;
+    
+    display_ticket($agent, $id);
+    $agent->content =~ qr{State:\s*</td>\s*<td[^>]*?>\s*<span class="cf-value">([\w ]+)</span>}ism;
+    return $1;
 }
 
 sub ticket_state_is {
@@ -158,6 +158,7 @@
 
     $agent->follow_link_ok({text => $queue, n => "1"}, "Followed '$queue' link");
     $agent->follow_link_ok({text => "New ". $type{ $queue }, n => "1"}, "Followed 'New $type{$queue}' link");
+    
 
     # set the form
     $agent->form_number(3);
@@ -180,6 +181,15 @@
     my $cfs = shift || {};
 
     goto_create_rtir_ticket($agent, $queue);
+    
+    #Enable test scripts to pass in the name of the owner rather than the ID
+    if ($$fields{Owner} && $$fields{Owner} !~ /^\d+$/)
+    {
+        if($agent->content =~ qr{<option.+?value="(\d+)"\s*>$$fields{Owner}</option>}ims) {
+            $$fields{Owner} = $1;
+        }
+    }
+    
 
     $fields->{'Requestors'} ||= $RTIR_TEST_USER if $queue eq 'Investigations';
     while (my ($f, $v) = each %$fields) {
@@ -212,7 +222,7 @@
         $id = $1;
     }
     elsif ($content =~ /.*No permission to view newly created ticket #(\d+).*/g) {
-    	diag("\nNo permissions to view the ticket.\n") if($ENV{'TEST_VERBOSE'});
+        diag("\nNo permissions to view the ticket.\n") if($ENV{'TEST_VERBOSE'});
     }
     return $id;
 }
@@ -263,7 +273,7 @@
 
 sub LinkChildToIncident {
 
-	my $agent = shift;
+    my $agent = shift;
     my $id = shift;
     my $incident = shift;
 
@@ -273,11 +283,11 @@
     $agent->follow_link_ok({text => "[Link]", n => "1"}, "Followed 'Link(to Incident)' link");
 
     
-	# Check that the desired incident occurs in the list of available incidents; if not, keep
-	# going to the next page until you find it (or get to the last page and don't find it,
-	# whichever comes first)
+    # Check that the desired incident occurs in the list of available incidents; if not, keep
+    # going to the next page until you find it (or get to the last page and don't find it,
+    # whichever comes first)
     while($agent->content() !~ m|<a href="/Ticket/Display.html\?id=$incident">$incident</a>|) {
-    	last unless $agent->follow_link(text => 'Next Page');
+        last unless $agent->follow_link(text => 'Next Page');
     }
     
     $agent->form_number(3);
@@ -295,72 +305,72 @@
 
 
 sub merge_ticket {
-	my $agent = shift;
-	my $id = shift;
-	my $id_to_merge_to = shift;
-	
-	display_ticket($agent, $id);
-	
-	$agent->timeout(600);
-	
-	$agent->follow_link_ok({text => 'Merge', n => '1'}, "Followed 'Merge' link");
-	
-	$agent->content() =~ /Merge ([\w ]+) #$id:/i;
-	my $type = $1 || 'Ticket';
-	
-
-	# Check that the desired incident occurs in the list of available incidents; if not, keep
-	# going to the next page until you find it (or get to the last page and don't find it,
-	# whichever comes first)
+    my $agent = shift;
+    my $id = shift;
+    my $id_to_merge_to = shift;
+    
+    display_ticket($agent, $id);
+    
+    $agent->timeout(600);
+    
+    $agent->follow_link_ok({text => 'Merge', n => '1'}, "Followed 'Merge' link");
+    
+    $agent->content() =~ /Merge ([\w ]+) #$id:/i;
+    my $type = $1 || 'Ticket';
+    
+
+    # Check that the desired incident occurs in the list of available incidents; if not, keep
+    # going to the next page until you find it (or get to the last page and don't find it,
+    # whichever comes first)
     while($agent->content() !~ m|<a href="/Ticket/Display.html\?id=$id_to_merge_to">$id_to_merge_to</a>|) {
-    	my @ids = sort map s|<b>\s*<a href="/Ticket/Display.html?id=(\d+)">\1</a>\s*</b>|$1|, split /<td/, $agent->content();
-		my $max = pop @ids;
-		my $url = "Merge.html?id=$id&Order=ASC&Query=( 'CF.{_RTIR_State}' = 'new' OR 'CF.{_RTIR_State}' = 'open' AND 'id' > $max)";
-		my $weburl = RT->Config->Get('WebURL');
-		diag("IDs found: " . join ', ', @ids);
-		diag("Max ID: " . $max);
-		diag ("URL: " . $url);
-    	$agent->get("$weburl/RTIR/$url");
-    	last unless $agent->content() =~ qr|<b>\s*<a href="/Ticket/Display.html?id=(\d+)">\1</a>\s*</b>|sm;
-    }
-    
-	
-	$agent->form_number(3);
-	
-	
-	$agent->field("SelectedTicket", $id_to_merge_to);
+        my @ids = sort map s|<b>\s*<a href="/Ticket/Display.html?id=(\d+)">\1</a>\s*</b>|$1|, split /<td/, $agent->content();
+        my $max = pop @ids;
+        my $url = "Merge.html?id=$id&Order=ASC&Query=( 'CF.{_RTIR_State}' = 'new' OR 'CF.{_RTIR_State}' = 'open' AND 'id' > $max)";
+        my $weburl = RT->Config->Get('WebURL');
+        diag("IDs found: " . join ', ', @ids);
+        diag("Max ID: " . $max);
+        diag ("URL: " . $url);
+        $agent->get("$weburl/RTIR/$url");
+        last unless $agent->content() =~ qr|<b>\s*<a href="/Ticket/Display.html?id=(\d+)">\1</a>\s*</b>|sm;
+    }
+    
+    
+    $agent->form_number(3);
+    
+    
+    $agent->field("SelectedTicket", $id_to_merge_to);
     $agent->click_button(value => 'Merge');
     
     is ($agent->status, 200, "Attempting to merge $type #$id to ticket #$id_to_merge_to");
-	
-	$agent->content_like(qr{.*<ul class="action-results">\s*<li>Merge Successful</li>.*}i, 
-    	"Successfully merged $type #$id to ticket #$id_to_merge_to");
+    
+    $agent->content_like(qr{.*<ul class="action-results">\s*<li>Merge Successful</li>.*}i, 
+        "Successfully merged $type #$id to ticket #$id_to_merge_to");
 }
 
 
 sub create_incident_and_investigation {
-	my $agent = shift;
+    my $agent = shift;
     my $fields = shift || {};
     my $cfs = shift || {};
-	my $ir_id = shift;
+    my $ir_id = shift;
 
     $ir_id ? display_ticket($agent, $ir_id) : go_home($agent);
 
-	if($ir_id) {
-		# Select the "New" link from the Display page
-    	$agent->follow_link_ok({text => "[New]"}, "Followed 'New (Incident)' link");
-	}
-	else 
-	{
-		$agent->follow_link_ok({text => "Incidents"}, "Followed 'Incidents' link");
-		$agent->follow_link_ok({text => "New Incident", n => '1'}, "Followed 'New Incident' link");
-	}
+    if($ir_id) {
+        # Select the "New" link from the Display page
+        $agent->follow_link_ok({text => "[New]"}, "Followed 'New (Incident)' link");
+    }
+    else 
+    {
+        $agent->follow_link_ok({text => "Incidents"}, "Followed 'Incidents' link");
+        $agent->follow_link_ok({text => "New Incident", n => '1'}, "Followed 'New Incident' link");
+    }
 
-	# Fill out forms
+    # Fill out forms
     $agent->form_number(3);
 
     while (my ($f, $v) = each %$fields) {
-    	$agent->field($f, $v);
+        $agent->field($f, $v);
     }
 
     while (my ($f, $v) = each %$cfs) {
@@ -371,12 +381,12 @@
         ? "Attempting to create new incident and investigation linked to child $ir_id"
         : "Attempting to create new incident and investigation";
     is ($agent->status, 200, $msg);
-	$msg = $ir_id ? "Incident created from child $ir_id." : "Incident created.";
+    $msg = $ir_id ? "Incident created from child $ir_id." : "Incident created.";
 
     my $re = qr/.*Ticket (\d+) created in queue &#39;Incidents&#39;/;
     $agent->content_like( $re, $msg );
-  	my ($incident_id) = ($agent->content =~ $re);
-  	
+      my ($incident_id) = ($agent->content =~ $re);
+      
     $re = qr/.*Ticket (\d+) created in queue &#39;Investigations&#39;/;
     $agent->content_like( $re, "Investigation created for Incident $incident_id." );
     my ($investigation_id) = ($agent->content =~ $re);


More information about the Rt-commit mailing list