[Rt-commit] r19877 - in rtir/2.5/trunk: . lib/RT t t/constituency t/incident t/lib/RT/IR
ruz at bestpractical.com
ruz at bestpractical.com
Wed Jun 3 16:48:09 EDT 2009
Author: ruz
Date: Wed Jun 3 16:48:09 2009
New Revision: 19877
Removed:
rtir/2.5/trunk/t/rtir-test.pl
Modified:
rtir/2.5/trunk/ (props changed)
rtir/2.5/trunk/Makefile.PL
rtir/2.5/trunk/lib/RT/IR.pm
rtir/2.5/trunk/t/000-mason-syntax.t
rtir/2.5/trunk/t/001-basic-RTIR.t
rtir/2.5/trunk/t/002-test-reject.t
rtir/2.5/trunk/t/003-resolve-IR-when-all-incidents-resolved.t
rtir/2.5/trunk/t/004-rtfm-in-rtir.t
rtir/2.5/trunk/t/005-resolve-investigations.t
rtir/2.5/trunk/t/006-saved-searches.t
rtir/2.5/trunk/t/008-workflow-blocks.t
rtir/2.5/trunk/t/009-attachments-processing.t
rtir/2.5/trunk/t/010-bulk-reject.t
rtir/2.5/trunk/t/011-merge.t
rtir/2.5/trunk/t/013-custom-field-ip.t
rtir/2.5/trunk/t/015-make-clicky.t
rtir/2.5/trunk/t/016-date-due.t
rtir/2.5/trunk/t/016-date-started.t
rtir/2.5/trunk/t/019-watchers-on-create.t
rtir/2.5/trunk/t/019-webui-block-fields.t
rtir/2.5/trunk/t/020-incident-and-investigation.t
rtir/2.5/trunk/t/021-gnupg-on-create.t
rtir/2.5/trunk/t/022-gnupg-on-update.t
rtir/2.5/trunk/t/023-gnupg-on-incident.t
rtir/2.5/trunk/t/constituency/acl.t
rtir/2.5/trunk/t/constituency/basics.t
rtir/2.5/trunk/t/constituency/email.t
rtir/2.5/trunk/t/constituency/email_outgoing.t
rtir/2.5/trunk/t/constituency/propagation-inherit.t
rtir/2.5/trunk/t/constituency/propagation-no.t
rtir/2.5/trunk/t/constituency/propagation-reject.t
rtir/2.5/trunk/t/incident/abandon.t
rtir/2.5/trunk/t/incident/bulk-abandon.t
rtir/2.5/trunk/t/incident/split.t
rtir/2.5/trunk/t/lib/RT/IR/Test.pm
rtir/2.5/trunk/t/mail/skip_notification.t
Log:
* sync 2.4->2.5
r19633 at Macintosh (orig r19621): ruz | 2009-05-11 22:04:41 +0300
* delete the only use of YAML we had for debugging
r19746 at Macintosh (orig r19734): ruz | 2009-05-20 13:03:02 +0300
* move everything from t/rtir-test.pl into t/lib/RT/IR/Test.pm
r19756 at Macintosh (orig r19744): ruz | 2009-05-20 20:05:37 +0300
* provide correct RTFM's path if we're in CHIMPS environment
Modified: rtir/2.5/trunk/Makefile.PL
==============================================================================
--- rtir/2.5/trunk/Makefile.PL (original)
+++ rtir/2.5/trunk/Makefile.PL Wed Jun 3 16:48:09 2009
@@ -48,9 +48,9 @@
substitute( {
RT_LIB_PATH => join( ' ', $local_lib_path, $lib_path ),
},
- 't/rtir-test.pl',
'etc/upgrade/upgrade.pl',
'etc/add_constituency',
+ 't/lib/RT/IR/Test.pm',
);
tests("t/*.t t/*/*.t");
Modified: rtir/2.5/trunk/lib/RT/IR.pm
==============================================================================
--- rtir/2.5/trunk/lib/RT/IR.pm (original)
+++ rtir/2.5/trunk/lib/RT/IR.pm Wed Jun 3 16:48:09 2009
@@ -449,9 +449,7 @@
}
$_[-1] = [$queue, $new_queue];
} else {
- use YAML;
- $RT::Logger->crit( "$self is not a ticket object like I expected"
- . YAML::Dump($self) );
+ $RT::Logger->crit("$self is not a ticket object like I expected");
}
};
}
Modified: rtir/2.5/trunk/t/000-mason-syntax.t
==============================================================================
--- rtir/2.5/trunk/t/000-mason-syntax.t (original)
+++ rtir/2.5/trunk/t/000-mason-syntax.t Wed Jun 3 16:48:09 2009
@@ -3,7 +3,8 @@
use strict;
use warnings;
-use Test::More tests => 1;
+use lib 't/lib';
+use RT::IR::Test tests => 4;
my $ok = 1;
Modified: rtir/2.5/trunk/t/001-basic-RTIR.t
==============================================================================
--- rtir/2.5/trunk/t/001-basic-RTIR.t (original)
+++ rtir/2.5/trunk/t/001-basic-RTIR.t Wed Jun 3 16:48:09 2009
@@ -2,9 +2,9 @@
use strict;
use warnings;
+use lib 't/lib';
-require "t/rtir-test.pl";
-use Test::More tests => 25;
+use RT::IR::Test tests => 25;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/002-test-reject.t
==============================================================================
--- rtir/2.5/trunk/t/002-test-reject.t (original)
+++ rtir/2.5/trunk/t/002-test-reject.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 115;
+use lib "t/lib";
+use RT::IR::Test tests => 115;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/003-resolve-IR-when-all-incidents-resolved.t
==============================================================================
--- rtir/2.5/trunk/t/003-resolve-IR-when-all-incidents-resolved.t (original)
+++ rtir/2.5/trunk/t/003-resolve-IR-when-all-incidents-resolved.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 33;
+use lib "t/lib";
+use RT::IR::Test tests => 33;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/004-rtfm-in-rtir.t
==============================================================================
--- rtir/2.5/trunk/t/004-rtfm-in-rtir.t (original)
+++ rtir/2.5/trunk/t/004-rtfm-in-rtir.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 19;
+use lib "t/lib";
+use RT::IR::Test tests => 19;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/005-resolve-investigations.t
==============================================================================
--- rtir/2.5/trunk/t/005-resolve-investigations.t (original)
+++ rtir/2.5/trunk/t/005-resolve-investigations.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 24;
+use lib "t/lib";
+use RT::IR::Test tests => 24;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/006-saved-searches.t
==============================================================================
--- rtir/2.5/trunk/t/006-saved-searches.t (original)
+++ rtir/2.5/trunk/t/006-saved-searches.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 19;
+use lib "t/lib";
+use RT::IR::Test tests => 19;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/008-workflow-blocks.t
==============================================================================
--- rtir/2.5/trunk/t/008-workflow-blocks.t (original)
+++ rtir/2.5/trunk/t/008-workflow-blocks.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 112;
+use lib "t/lib";
+use RT::IR::Test tests => 112;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/009-attachments-processing.t
==============================================================================
--- rtir/2.5/trunk/t/009-attachments-processing.t (original)
+++ rtir/2.5/trunk/t/009-attachments-processing.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 54;
+use lib "t/lib";
+use RT::IR::Test tests => 54;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/010-bulk-reject.t
==============================================================================
--- rtir/2.5/trunk/t/010-bulk-reject.t (original)
+++ rtir/2.5/trunk/t/010-bulk-reject.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 47;
+use lib "t/lib";
+use RT::IR::Test tests => 47;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/011-merge.t
==============================================================================
--- rtir/2.5/trunk/t/011-merge.t (original)
+++ rtir/2.5/trunk/t/011-merge.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 118;
+use lib "t/lib";
+use RT::IR::Test tests => 118;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/013-custom-field-ip.t
==============================================================================
--- rtir/2.5/trunk/t/013-custom-field-ip.t (original)
+++ rtir/2.5/trunk/t/013-custom-field-ip.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 486;
+use lib "t/lib";
+use RT::IR::Test tests => 486;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/015-make-clicky.t
==============================================================================
--- rtir/2.5/trunk/t/015-make-clicky.t (original)
+++ rtir/2.5/trunk/t/015-make-clicky.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 35;
+use lib "t/lib";
+use RT::IR::Test tests => 35;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/016-date-due.t
==============================================================================
--- rtir/2.5/trunk/t/016-date-due.t (original)
+++ rtir/2.5/trunk/t/016-date-due.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 14;
+use lib "t/lib";
+use RT::IR::Test tests => 14;
my $duty_a = RT::Test->load_or_create_user(
Name => 'duty a',
Modified: rtir/2.5/trunk/t/016-date-started.t
==============================================================================
--- rtir/2.5/trunk/t/016-date-started.t (original)
+++ rtir/2.5/trunk/t/016-date-started.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 73;
+use lib "t/lib";
+use RT::IR::Test tests => 73;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/019-watchers-on-create.t
==============================================================================
--- rtir/2.5/trunk/t/019-watchers-on-create.t (original)
+++ rtir/2.5/trunk/t/019-watchers-on-create.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 54;
+use lib "t/lib";
+use RT::IR::Test tests => 54;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/019-webui-block-fields.t
==============================================================================
--- rtir/2.5/trunk/t/019-webui-block-fields.t (original)
+++ rtir/2.5/trunk/t/019-webui-block-fields.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 18;
+use lib "t/lib";
+use RT::IR::Test tests => 18;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/020-incident-and-investigation.t
==============================================================================
--- rtir/2.5/trunk/t/020-incident-and-investigation.t (original)
+++ rtir/2.5/trunk/t/020-incident-and-investigation.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 26;
+use lib "t/lib";
+use RT::IR::Test tests => 26;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/021-gnupg-on-create.t
==============================================================================
--- rtir/2.5/trunk/t/021-gnupg-on-create.t (original)
+++ rtir/2.5/trunk/t/021-gnupg-on-create.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 58;
+use lib "t/lib";
+use RT::IR::Test tests => 58;
use File::Temp qw(tempdir);
Modified: rtir/2.5/trunk/t/022-gnupg-on-update.t
==============================================================================
--- rtir/2.5/trunk/t/022-gnupg-on-update.t (original)
+++ rtir/2.5/trunk/t/022-gnupg-on-update.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 65;
+use lib "t/lib";
+use RT::IR::Test tests => 65;
use File::Temp qw(tempdir);
RT::Test->set_mail_catcher;
Modified: rtir/2.5/trunk/t/023-gnupg-on-incident.t
==============================================================================
--- rtir/2.5/trunk/t/023-gnupg-on-incident.t (original)
+++ rtir/2.5/trunk/t/023-gnupg-on-incident.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 39;
+use lib "t/lib";
+use RT::IR::Test tests => 39;
use File::Temp qw(tempdir);
my @rights_backup = RT::Test->store_rights;
Modified: rtir/2.5/trunk/t/constituency/acl.t
==============================================================================
--- rtir/2.5/trunk/t/constituency/acl.t (original)
+++ rtir/2.5/trunk/t/constituency/acl.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 13;
+use lib "t/lib";
+use RT::IR::Test tests => 13;
use_ok('RT::IR');
Modified: rtir/2.5/trunk/t/constituency/basics.t
==============================================================================
--- rtir/2.5/trunk/t/constituency/basics.t (original)
+++ rtir/2.5/trunk/t/constituency/basics.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 175;
+use lib "t/lib";
+use RT::IR::Test tests => 175;
RT::Test->set_mail_catcher;
Modified: rtir/2.5/trunk/t/constituency/email.t
==============================================================================
--- rtir/2.5/trunk/t/constituency/email.t (original)
+++ rtir/2.5/trunk/t/constituency/email.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 65;
+use lib "t/lib";
+use RT::IR::Test tests => 65;
# Test must be run wtih RT_SiteConfig:
# Set(@MailPlugins, 'Auth::MailFrom');
Modified: rtir/2.5/trunk/t/constituency/email_outgoing.t
==============================================================================
--- rtir/2.5/trunk/t/constituency/email_outgoing.t (original)
+++ rtir/2.5/trunk/t/constituency/email_outgoing.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 36;
+use lib "t/lib";
+use RT::IR::Test tests => 36;
RT->Config->Set( '_RTIR_Constituency_default' => 'EDUNET' );
Modified: rtir/2.5/trunk/t/constituency/propagation-inherit.t
==============================================================================
--- rtir/2.5/trunk/t/constituency/propagation-inherit.t (original)
+++ rtir/2.5/trunk/t/constituency/propagation-inherit.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 200;
+use lib "t/lib";
+use RT::IR::Test tests => 200;
use_ok('RT::IR');
RT->Config->Set('_RTIR_Constituency_Propagation' => 'inherit');
Modified: rtir/2.5/trunk/t/constituency/propagation-no.t
==============================================================================
--- rtir/2.5/trunk/t/constituency/propagation-no.t (original)
+++ rtir/2.5/trunk/t/constituency/propagation-no.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 113;
+use lib "t/lib";
+use RT::IR::Test tests => 113;
use_ok('RT::IR');
RT->Config->Set('_RTIR_Constituency_Propagation' => 'no');
Modified: rtir/2.5/trunk/t/constituency/propagation-reject.t
==============================================================================
--- rtir/2.5/trunk/t/constituency/propagation-reject.t (original)
+++ rtir/2.5/trunk/t/constituency/propagation-reject.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 204;
+use lib "t/lib";
+use RT::IR::Test tests => 204;
use_ok('RT::IR');
RT->Config->Set('_RTIR_Constituency_Propagation' => 'reject');
Modified: rtir/2.5/trunk/t/incident/abandon.t
==============================================================================
--- rtir/2.5/trunk/t/incident/abandon.t (original)
+++ rtir/2.5/trunk/t/incident/abandon.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 52;
+use lib "t/lib";
+use RT::IR::Test tests => 52;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/incident/bulk-abandon.t
==============================================================================
--- rtir/2.5/trunk/t/incident/bulk-abandon.t (original)
+++ rtir/2.5/trunk/t/incident/bulk-abandon.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 102;
+use lib "t/lib";
+use RT::IR::Test tests => 102;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/incident/split.t
==============================================================================
--- rtir/2.5/trunk/t/incident/split.t (original)
+++ rtir/2.5/trunk/t/incident/split.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 21;
+use lib "t/lib";
+use RT::IR::Test tests => 21;
RT::Test->started_ok;
my $agent = default_agent();
Modified: rtir/2.5/trunk/t/lib/RT/IR/Test.pm
==============================================================================
--- rtir/2.5/trunk/t/lib/RT/IR/Test.pm (original)
+++ rtir/2.5/trunk/t/lib/RT/IR/Test.pm Wed Jun 3 16:48:09 2009
@@ -5,8 +5,37 @@
use base qw(Test::More);
use Cwd;
+### after: use lib qw(@RT_LIB_PATH@);
+use lib qw(/opt/rt3/local/lib /opt/rt3/lib);
+
eval 'use RT::Test; 1'
- or Test::More::plan skip_all => 'requires 3.8 to run tests. You may need to set PERL5LIB=/path/to/rt/lib';
+ or Test::More::plan skip_all => "requires 3.8 to run tests. Error:\n$@\nYou may need to set PERL5LIB=/path/to/rt/lib";
+
+use RT::Test::Web;
+
+our @EXPORT = qw(
+ default_agent
+ set_custom_field
+ display_ticket
+ ticket_state
+ ticket_state_is
+ ticket_is_linked_to_inc
+ ticket_is_not_linked_to_inc
+ rtir_user
+ create_incident
+ create_ir
+ create_investigation
+ create_block
+ goto_create_rtir_ticket
+ create_rtir_ticket_ok
+ create_rtir_ticket
+ get_ticket_id
+ create_incident_for_ir
+ ok_and_content_like
+ LinkChildToIncident
+ merge_ticket
+ create_incident_and_investigation
+);
sub import_extra {
my $class = shift;
@@ -36,6 +65,10 @@
my $old_func = \&RT::Plugin::_BasePath;
*RT::Plugin::_BasePath = sub {
return $cwd if $_[0]->{name} eq 'RT::IR';
+ if ( $_[0]->{name} eq 'RT::FM' ) {
+ my ($path) = map $ENV{$_}, grep /^CHIMPS_RTFM.*_ROOT$/, keys %ENV;
+ return $path;
+ }
return $old_func->(@_);
};
}
@@ -63,4 +96,358 @@
require RT::IR;
}
+my $RTIR_TEST_USER = "rtir_test_user";
+my $RTIR_TEST_PASS = "rtir_test_pass";
+
+sub default_agent {
+ my $agent = new RT::Test::Web;
+ require HTTP::Cookies;
+ $agent->cookie_jar( HTTP::Cookies->new );
+ rtir_user();
+ $agent->login($RTIR_TEST_USER, $RTIR_TEST_PASS);
+ $agent->get_ok("/RTIR/index.html", "Loaded home page");
+ 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 {
+ 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 {
+ 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 Test::More::is($1, $state, $desc);
+}
+
+sub ticket_is_linked_to_inc {
+ my $agent = shift;
+ my $id = shift;
+ my $incs = shift;
+ display_ticket( $agent, $id );
+ foreach my $inc( ref $incs? @$incs : ($incs) ) {
+ my $desc = shift || "Ticket #$id is linked to the Incident #$inc";
+ $agent->content_like(
+ qr{Incident:\s*</td>\s*<td[^>]*?>.*?<a\s+href="/RTIR/Display.html\?id=\Q$inc\E">\Q$inc\E:\s+}ism,
+ $desc
+ ) or return 0;
+ }
+ return 1;
+}
+
+sub ticket_is_not_linked_to_inc {
+ my $agent = shift;
+ my $id = shift;
+ my $incs = shift;
+ display_ticket( $agent, $id );
+ foreach my $inc( @$incs ) {
+ my $desc = shift || "Ticket #$id is not linked to the Incident #$inc";
+ diag $agent->content;
+ $agent->content_unlike(
+ qr{Incident:\s*</td>\s*<td[^>]*?>.*?<a\s+href="/RTIR/Display.html\?id=\Q$inc\E">\Q$inc\E:\s+}ism,
+ $desc
+ ) or return 0;
+ }
+ return 1;
+}
+
+sub rtir_user {
+ return RT::Test->load_or_create_user(
+ Name => $RTIR_TEST_USER,
+ Password => $RTIR_TEST_PASS,
+ EmailAddress => "$RTIR_TEST_USER\@example.com",
+ RealName => "$RTIR_TEST_USER Smith",
+ MemberOf => 'DutyTeam',
+ );
+}
+
+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, @_ );
+ Test::More::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 } );
+
+ Test::More::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("\nNo permissions to view the ticket.\n") if($ENV{'TEST_VERBOSE'});
+ $id = $1;
+ }
+ 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");
+
+ Test::More::is ($agent->status, 200, "Attempting to create new incident linked to child $ir_id");
+
+ Test::More::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";
+
+ Test::More::is($agent->status, 200, "request successful");
+ #like($agent->content, $re, $desc);
+ $agent->content_like($re, $desc);
+}
+
+
+sub LinkChildToIncident {
+
+ my $agent = shift;
+ my $id = shift;
+ my $incident = shift;
+
+ display_ticket($agent, $id);
+
+ # Select the "Link" link from the Display page
+ $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)
+ while($agent->content() !~ m|<a href="/Ticket/Display.html\?id=$incident">$incident</a>|) {
+ last unless $agent->follow_link(text => 'Next');
+ }
+
+ $agent->form_number(3);
+
+ $agent->field("SelectedTicket", $incident);
+
+ $agent->click("LinkChild");
+
+ Test::More::is ($agent->status, 200, "Attempting to link child $id to Incident $incident");
+
+ Test::More::ok ($agent->content =~ /Ticket\s+$id:\s*Ticket\s+$id\s+member\s+of\s+Ticket\s+$incident/gs, "Incident $incident linked successfully.");
+
+ return;
+}
+
+
+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)
+ 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);
+ $agent->click_button(value => 'Merge');
+
+ Test::More::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");
+}
+
+
+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("/RTIR/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";
+ Test::More::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);
+}
+
1;
Modified: rtir/2.5/trunk/t/mail/skip_notification.t
==============================================================================
--- rtir/2.5/trunk/t/mail/skip_notification.t (original)
+++ rtir/2.5/trunk/t/mail/skip_notification.t Wed Jun 3 16:48:09 2009
@@ -3,8 +3,8 @@
use strict;
use warnings;
-require "t/rtir-test.pl";
-use Test::More tests => 19;
+use lib "t/lib";
+use RT::IR::Test tests => 19;
RT->Config->Set( '_RTIR_Constituency_default' => 'EDUNET' );
More information about the Rt-commit
mailing list