[Bps-public-commit] RT-Extension-TicketLocking branch, rtir-fixes, created. 0.12-15-gf3be794
Kevin Falcone
falcone at bestpractical.com
Tue Mar 25 17:14:47 EDT 2014
The branch, rtir-fixes has been created
at f3be79426b7af539c843ba2fe8743c4b37d4503f (commit)
- Log -----------------------------------------------------------------
commit 1dc08bedf759cd39723c469a37c3af9b69f3ec13
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Tue Mar 25 17:09:15 2014 -0400
Run on RTIR tickets, not just normal Tickets
diff --git a/html/Callbacks/RT-Extension-TicketLocking/Elements/Tabs/Privileged b/html/Callbacks/RT-Extension-TicketLocking/Elements/Tabs/Privileged
index 7c9b32d..e90297e 100644
--- a/html/Callbacks/RT-Extension-TicketLocking/Elements/Tabs/Privileged
+++ b/html/Callbacks/RT-Extension-TicketLocking/Elements/Tabs/Privileged
@@ -1,9 +1,10 @@
<%INIT>
my $request_path = $HTML::Mason::Commands::r->path_info;
-return unless $request_path =~ m{^/Ticket/};
+return unless $request_path =~ m{^/Ticket/|^/RTIR/};
return unless ( $DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/;
my $id = $1;
+return unless PageMenu()->child('actions');
my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
$Ticket->Load($id);
@@ -34,4 +35,4 @@ if ( my $Lock = $Ticket->Locked ) {
title => loc('Lock'),
);
}
-</%INIT>
\ No newline at end of file
+</%INIT>
commit fc64f9e1da7032f23347d1b78b1f4ace0f6f016b
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Tue Mar 25 17:09:35 2014 -0400
This method moved
Reported by Carlos Fuentes
diff --git a/html/Callbacks/RT-Extension-TicketLocking/RTIR/Display.html/TicketTakeOrSteal b/html/Callbacks/RT-Extension-TicketLocking/RTIR/Display.html/TicketTakeOrSteal
index c793b02..b8da6d1 100644
--- a/html/Callbacks/RT-Extension-TicketLocking/RTIR/Display.html/TicketTakeOrSteal
+++ b/html/Callbacks/RT-Extension-TicketLocking/RTIR/Display.html/TicketTakeOrSteal
@@ -5,7 +5,7 @@ $Results
</%ARGS>
<%INIT>
-if($Type eq 'Report' && !RT::IR::Ticket::IsLinkedToActiveIncidents($Ticket)) {
+if($Type eq 'Report' && !RT::IR->IsLinkedToActiveIncidents($Ticket)) {
$Ticket->Lock('Take');
push @$Results, 'You have a lock on this report until you link it to an incident';
}
commit b252539a414bc2a31ab7f1f21392cead91de6be2
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Tue Mar 25 17:10:15 2014 -0400
Reply.html moved to Reply/
diff --git a/html/Callbacks/RT-Extension-TicketLocking/RTIR/Incident/Reply.html/BeforeActionList b/html/Callbacks/RT-Extension-TicketLocking/RTIR/Incident/Reply/index.html/BeforeActionList
similarity index 100%
rename from html/Callbacks/RT-Extension-TicketLocking/RTIR/Incident/Reply.html/BeforeActionList
rename to html/Callbacks/RT-Extension-TicketLocking/RTIR/Incident/Reply/index.html/BeforeActionList
diff --git a/html/Callbacks/RT-Extension-TicketLocking/RTIR/Incident/Reply.html/BeforeDisplay b/html/Callbacks/RT-Extension-TicketLocking/RTIR/Incident/Reply/index.html/BeforeDisplay
similarity index 100%
rename from html/Callbacks/RT-Extension-TicketLocking/RTIR/Incident/Reply.html/BeforeDisplay
rename to html/Callbacks/RT-Extension-TicketLocking/RTIR/Incident/Reply/index.html/BeforeDisplay
diff --git a/html/Callbacks/RT-Extension-TicketLocking/RTIR/Incident/Reply.html/Initial b/html/Callbacks/RT-Extension-TicketLocking/RTIR/Incident/Reply/index.html/Initial
similarity index 100%
rename from html/Callbacks/RT-Extension-TicketLocking/RTIR/Incident/Reply.html/Initial
rename to html/Callbacks/RT-Extension-TicketLocking/RTIR/Incident/Reply/index.html/Initial
commit 8cc13ddd2fdd494040778df678fc876a6bf7f140
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Tue Mar 25 17:10:38 2014 -0400
Merge.html moved to Merge
diff --git a/html/Callbacks/RT-Extension-TicketLocking/RTIR/Merge.html/BeforeActionList b/html/Callbacks/RT-Extension-TicketLocking/RTIR/Merge/index.html/BeforeActionList
similarity index 100%
rename from html/Callbacks/RT-Extension-TicketLocking/RTIR/Merge.html/BeforeActionList
rename to html/Callbacks/RT-Extension-TicketLocking/RTIR/Merge/index.html/BeforeActionList
diff --git a/html/Callbacks/RT-Extension-TicketLocking/RTIR/Merge.html/Initial b/html/Callbacks/RT-Extension-TicketLocking/RTIR/Merge/index.html/Initial
similarity index 100%
rename from html/Callbacks/RT-Extension-TicketLocking/RTIR/Merge.html/Initial
rename to html/Callbacks/RT-Extension-TicketLocking/RTIR/Merge/index.html/Initial
diff --git a/html/Callbacks/RT-Extension-TicketLocking/RTIR/Merge.html/MergeTicketSelected b/html/Callbacks/RT-Extension-TicketLocking/RTIR/Merge/index.html/MergeTicketSelected
similarity index 100%
rename from html/Callbacks/RT-Extension-TicketLocking/RTIR/Merge.html/MergeTicketSelected
rename to html/Callbacks/RT-Extension-TicketLocking/RTIR/Merge/index.html/MergeTicketSelected
commit 00f618bc3e82ea749834737b97aa52b9171fa506
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Tue Mar 25 17:11:55 2014 -0400
Delete all the copied code from RT::IR::Test::Web
Add a separate login item that returns an RT::IR::Test::Web
instead of an RT::Test::Web
diff --git a/xt/test_suite.pl b/xt/test_suite.pl
index 2717681..f756b88 100644
--- a/xt/test_suite.pl
+++ b/xt/test_suite.pl
@@ -1,13 +1,10 @@
#!/usr/bin/perl
-# Load this in test scripts with: require "t/test_suite.pl";
-# *AFTER* loading in Test::More.
-
-
use strict;
use warnings;
use HTTP::Cookies;
+require RT::IR::Test::Web;
### after: use lib qw(@RT_LIB_PATH@);
use lib qw(/opt/rt4/local/lib /opt/rt4/lib);
@@ -24,44 +21,13 @@ sub default_agent {
return $agent;
}
-sub set_custom_field {
- my $agent = shift;
- my $cf_name = shift;
- my $val = shift;
- my $field_name = $agent->value($cf_name) or return 0;
- $agent->field($field_name, $val);
- return 1;
-}
-
-sub display_ticket {
- my $agent = shift;
- my $id = shift;
-
- $agent->get_ok("/RTIR/Display.html?id=$id", "Loaded Display page for Ticket #$id");
-}
-
-sub ticket_state_is {
- my $agent = shift;
- my $id = shift;
- my $state = shift;
- my $desc = shift || "State of the ticket #$id is '$state'";
- display_ticket( $agent, $id );
- $agent->content =~ qr{State:\s*</td>\s*<td[^>]*?>\s*<span class="cf-value">([\w ]+)</span>}ism;
- return is($1, $state, $desc);
-}
-
-
-sub create_user {
- my $user_obj = rtir_user();
-
- ok($user_obj->Id > 0, "Successfully found the user");
-
- my $group_obj = RT::Group->new(RT::SystemUser());
- $group_obj->LoadUserDefinedGroup("DutyTeam");
- ok($group_obj->Id > 0, "Successfully found the DutyTeam group");
-
- $group_obj->AddMember($user_obj->Id);
- ok($group_obj->HasMember($user_obj->PrincipalObj), "user is in the group");
+sub default_rtir_agent {
+ my $agent = new RT::IR::Test::Web;
+ $agent->cookie_jar( HTTP::Cookies->new );
+ my $u = rtir_user(MemberOf => 'DutyTeam');
+ $agent->login($RTIR_TEST_USER, $RTIR_TEST_PASS);
+ $agent->get_ok("/index.html", "loaded home page");
+ return $agent;
}
sub rtir_user {
@@ -71,212 +37,16 @@ sub rtir_user {
EmailAddress => "$RTIR_TEST_USER\@example.com",
RealName => "$RTIR_TEST_USER Smith",
Privileged => 1,
+ @_,
);
return $u;
}
-sub create_incident {
- return create_rtir_ticket_ok( shift, 'Incidents', @_ );
-}
-sub create_ir {
- return create_rtir_ticket_ok( shift, 'Incident Reports', @_ );
-}
-sub create_investigation {
- return create_rtir_ticket_ok( shift, 'Investigations', @_ );
-}
-sub create_block {
- return create_rtir_ticket_ok( shift, 'Blocks', @_ );
-}
-
-sub goto_create_rtir_ticket {
- my $agent = shift;
- my $queue = shift;
-
- my %type = (
- 'Incident Reports' => 'Report',
- 'Investigations' => 'Investigation',
- 'Blocks' => 'Block',
- 'Incidents' => 'Incident'
- );
-
- $agent->get_ok("/RTIR/index.html", "loaded home page");
-
- $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);
-}
-
-sub create_rtir_ticket_ok {
- my $agent = shift;
- my $queue = shift;
-
- my $id = create_rtir_ticket( $agent, $queue, @_ );
- ok $id, "Created ticket #$id in queue '$queue' successfully.";
- return $id;
-}
-
-sub create_rtir_ticket
-{
- my $agent = shift;
- my $queue = shift;
- my $fields = shift || {};
- 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) {
- $agent->field($f, $v);
- }
-
- while (my ($f, $v) = each %$cfs) {
- set_custom_field($agent, $f, $v);
- }
-
- my %create = (
- 'Incident Reports' => 'Create',
- 'Investigations' => 'Create',
- 'Blocks' => 'Create',
- 'Incidents' => 'CreateIncident'
- );
- # Create it!
- $agent->click( $create{ $queue } );
-
- is ($agent->status, 200, "Attempted to create the ticket");
-
- return get_ticket_id($agent);
-}
-
-sub get_ticket_id {
- my $agent = shift;
- my $content = $agent->content();
- my $id = 0;
- if ($content =~ /.*Ticket (\d+) created.*/g) {
- $id = $1;
- }
- elsif ($content =~ /.*No permission to view newly created ticket #(\d+).*/g) {
- diag "No permissions to view the ticket" if $ENV{'TEST_VERBOSE'};
- }
- else {
- diag "Couldn't find ticket id in:\n$content" if $ENV{'TEST_VERBOSE'};
- }
- return $id;
-}
-
-
-sub create_incident_for_ir {
- my $agent = shift;
- my $ir_id = shift;
- my $fields = shift || {};
- my $cfs = shift || {};
-
- display_ticket($agent, $ir_id);
-
- # Select the "New" link from the Display page
- $agent->follow_link_ok({text => "[New]"}, "Followed 'New (Incident)' link");
-
- $agent->form_number(3);
-
- while (my ($f, $v) = each %$fields) {
- $agent->field($f, $v);
- }
-
- while (my ($f, $v) = each %$cfs) {
- set_custom_field($agent, $f, $v);
- }
-
- $agent->click("CreateIncident");
-
- is ($agent->status, 200, "Attempting to create new incident linked to child $ir_id");
-
- ok ($agent->content =~ /.*Ticket (\d+) created in queue.*/g, "Incident created from child $ir_id.");
- my $incident_id = $1;
-
-# diag("incident ID is $incident_id");
- return $incident_id;
-}
-
-sub ok_and_content_like {
- my $agent = shift;
- my $re = shift;
- my $desc = shift || "looks good";
-
- is($agent->status, 200, "request successful");
- #like($agent->content, $re, $desc);
- $agent->content_like($re, $desc);
-}
-
-
-sub create_incident_and_investigation {
- my $agent = shift;
- my $fields = shift || {};
- my $cfs = shift || {};
- my $ir_id = shift;
-
- $ir_id ? display_ticket($agent, $ir_id)
- : $agent->get_ok("/index.html", "loaded home page");
-
- 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
- $agent->form_number(3);
-
- while (my ($f, $v) = each %$fields) {
- $agent->field($f, $v);
- }
-
- while (my ($f, $v) = each %$cfs) {
- set_custom_field($agent, $f, $v);
- }
- $agent->click("CreateWithInvestigation");
- my $msg = $ir_id
- ? "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.";
-
- my $re = qr/.*Ticket (\d+) created in queue 'Incidents'/;
- $agent->content_like( $re, $msg );
- my ($incident_id) = ($agent->content =~ $re);
-
- $re = qr/.*Ticket (\d+) created in queue 'Investigations'/;
- $agent->content_like( $re, "Investigation created for Incident $incident_id." );
- my ($investigation_id) = ($agent->content =~ $re);
-
- return ($incident_id, $investigation_id);
-}
-
sub create_ticket {
my $agent = shift;
my $queue = shift || 'General';
- return create_rtir_ticket($agent, $queue, @_)
- if $queue eq 'Incidents'
- || $queue eq 'Blocks'
- || $queue eq 'Investigations'
- || $queue eq 'Incident Reports';
-
my $fields = shift || {};
my $cfs = shift || {};
commit f3be79426b7af539c843ba2fe8743c4b37d4503f
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Tue Mar 25 17:12:37 2014 -0400
Switch to modern RT::Test that can load/init RTIR for us
Change to using as many RT::IR::Test::Web methods as possible
Update messages where needed
Parts of this are still really inconsistent with changes in RTIR, not
sure where the blame lies (in this module or in the RTIR changes).
Still fails tests about halfway through, but this is as far as I got.
diff --git a/xt/rtir.t b/xt/rtir.t
index 4c5190c..0d5b425 100644
--- a/xt/rtir.t
+++ b/xt/rtir.t
@@ -3,14 +3,13 @@
use strict;
use warnings;
-use Test::More;
-require "t/test_suite.pl";
-eval 'use RT::IR; 1' or plan skip_all => 'RTIR not installed';
-plan tests => 128;
+use RT::Test requires => ['RT::IR'], testing => 'RT::Extension::TicketLocking', tests => undef;
+require "xt/test_suite.pl";
-use_ok('RT::Extension::TicketLocking');
-create_user();
-my $agent = default_agent();
+my ($baseurl, $default_agent) = RT::Test->started_ok;
+diag($baseurl);
+
+my $agent = default_rtir_agent();
use HTTP::Cookies;
my $root = new RT::Test::Web;
@@ -23,22 +22,22 @@ my $SUBJECT = "foo " . rand;
diag("Testing Incident locking") if $ENV{'TEST_VERBOSE'};
# Create an incident
-my $inc = create_incident($agent,
+my $inc = $agent->create_incident(
{Subject => $SUBJECT, Content => "bla",
Owner => 'Nobody in particular (Nobody)' }
);
-
my $inc_obj = RT::Ticket->new(RT::SystemUser());
$inc_obj->Load($inc);
-is($inc_obj->Id, $inc, "report has right ID");
+is($inc_obj->Id, $inc, "Incident 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 => 'Take', n => '1'}, "Followed 'Take' link");
$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");
my $lock = $inc_obj->Locked();
@@ -71,23 +70,20 @@ sleep 5; #Otherwise, we run the risk of getting "You have locked this ticket"
$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->follow_link_ok({text => "Back to ticket #$inc", n => '1'}, "Returned to ticket");
$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->content_like(qr{You have unlocked this ticket. It was locked for \d+ \w+\.}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");
@@ -104,8 +100,8 @@ 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->display_ticket($inc);
+$agent->content_like(qr{ss="locked-by-you">\s*You have had this Ticket locked for \d+ \w+\.\W+</div>}ims, "Incident $inc is still locked");
$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);
@@ -132,7 +128,6 @@ $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()
@@ -155,7 +150,7 @@ $agent->content_like(qr{<div class="locked-by-you">\s*You had Ticket #$inc locke
if($agent->content =~ qr{<li>Ticket (\d+) created in queue.*</li>}i) {
$inc_id2 = $1;
}
-display_ticket($agent, $inc);
+$agent->display_ticket($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);
@@ -172,7 +167,7 @@ $agent->follow_link_ok({text => 'Lock', n => '1'}, "Hard locked to test multi-us
diag("Testing Incident locking from other user's point of view");
-display_ticket($root, $inc);
+$root->display_ticket($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");
@@ -242,7 +237,7 @@ $agent->content_like(qr{<div class="locked-by-you">\s*You have had Ticket #$repo
###Testing Merge.html locking###
-display_ticket($agent, $report);
+$agent->display_ticket($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);
@@ -293,7 +288,7 @@ $agent->content_like(qr{<div class="locked-by-you">\s*You had Ticket #$report lo
if($agent->content =~ qr{<li>Ticket (\d+) created in queue.*</li>}i) {
$ir_id2 = $1;
}
-display_ticket($agent, $report);
+$agent->display_ticket($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);
@@ -373,7 +368,7 @@ $agent->follow_link_ok({text => 'Lock', n => '1'}, "Hard locked to test multi-us
diag("Testing IR locking from other user's point of view");
$root->get_ok( '/RTIR/index.html', 'go home');
-display_ticket($root, $report);
+$root->display_ticket($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");
@@ -387,4 +382,6 @@ $root->content_like(qr{<li>You have broken the lock on this ticket</li>}, "Lock
$agent->follow_link_ok({text => 'Logout', n => '1'}, "Logging out rtir_test_user");
$root->follow_link_ok({text => 'Logout', n => '1'}, "Logging out root");
+undef $default_agent;
+done_testing;
1;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list