[Rt-commit] r17138 - rt/3.8/branches/ruleset/t/approval
clkao at bestpractical.com
clkao at bestpractical.com
Sun Dec 7 10:02:33 EST 2008
Author: clkao
Date: Sun Dec 7 10:02:33 2008
New Revision: 17138
Modified:
rt/3.8/branches/ruleset/t/approval/basic.t
Log:
test for approval all passed template.
Modified: rt/3.8/branches/ruleset/t/approval/basic.t
==============================================================================
--- rt/3.8/branches/ruleset/t/approval/basic.t (original)
+++ rt/3.8/branches/ruleset/t/approval/basic.t Sun Dec 7 10:02:33 2008
@@ -8,7 +8,7 @@
or plan skip_all => 'require Email::Abstract and Test::Email';
}
-plan tests => 29;
+plan tests => 33;
use RT;
use RT::Test;
@@ -18,23 +18,20 @@
my ($baseurl, $m) = RT::Test->started_ok;
-my ($user_a, $user_b) = (RT::User->new($RT::SystemUser), RT::User->new($RT::SystemUser));
-my ($user_c) = RT::User->new($RT::SystemUser);
-
-$user_a->Create( Name => 'CFO', Privileged => 1, EmailAddress => 'cfo at company.com');
-$user_b->Create( Name => 'CEO', Privileged => 1, EmailAddress => 'ceo at company.com');
-$user_c->Create( Name => 'minion', Privileged => 1, EmailAddress => 'minion at company.com');
-
my $q = RT::Queue->new($RT::SystemUser);
$q->Load('___Approvals');
-
$q->SetDisabled(0);
-my ($val, $msg);
-($val, $msg) = $user_a->PrincipalObj->GrantRight(Object =>$q, Right => $_)
- for qw(ModifyTicket OwnTicket ShowTicket);
-($val, $msg) = $user_b->PrincipalObj->GrantRight(Object =>$q, Right => $_)
- for qw(ModifyTicket OwnTicket ShowTicket);
+my %users;
+for my $user_name (qw(minion cfo ceo )) {
+ my $user = $users{$user_name} = RT::User->new($RT::SystemUser);
+ $user->Create( Name => uc($user_name),
+ Privileged => 1,
+ EmailAddress => $user_name.'@company.com');
+ my ($val, $msg);
+ ($val, $msg) = $user->PrincipalObj->GrantRight(Object =>$q, Right => $_)
+ for qw(ModifyTicket OwnTicket ShowTicket);
+}
# XXX: we need to make the first approval ticket open so notification is sent.
my $approvals =
@@ -135,7 +132,7 @@
mail_ok {
my $cfo = RT::CurrentUser->new;
- $cfo->Load( $user_a );
+ $cfo->Load( $users{cfo} );
$dependson_cfo->CurrentUser($cfo);
my $notes = MIME::Entity->build(
@@ -164,3 +161,25 @@
is_deeply([ $t->Status, $dependson_cfo->Status, $dependson_ceo->Status ],
[ 'new', 'resolved', 'open'], 'ticket state after cfo approval');
+
+mail_ok {
+ my $ceo = RT::CurrentUser->new;
+ $ceo->Load( $users{ceo} );
+
+ $dependson_ceo->CurrentUser($ceo);
+ my $notes = MIME::Entity->build(
+ Data => [ 'And consumed they will be.' ]
+ );
+ RT::I18N::SetMIMEEntityToUTF8($notes); # convert text parts into utf-8
+
+ my ( $notesval, $notesmsg ) = $dependson_ceo->Correspond( MIMEObj => $notes );
+ ok($notesval, $notesmsg);
+
+ my ($ok, $msg) = $dependson_ceo->SetStatus( Status => 'resolved' );
+ ok($ok, "ceo can approve - $msg");
+
+} { from => qr/RT System/,
+ to => 'minion at company.com',
+ subject => qr/Ticket Approved:/,
+ body => qr/approved by CEO.*Its Owner may now start to act on it.*notes: And consumed they will be/s
+};
More information about the Rt-commit
mailing list