[Rt-commit] r17154 - in rt/3.8/branches/ruleset: lib/RT lib/RT/Approval/Rule
clkao at bestpractical.com
clkao at bestpractical.com
Tue Dec 9 10:59:21 EST 2008
Author: clkao
Date: Tue Dec 9 10:59:16 2008
New Revision: 17154
Added:
rt/3.8/branches/ruleset/lib/RT/Approval/Rule/Created.pm
Modified:
rt/3.8/branches/ruleset/lib/RT/Approval.pm
rt/3.8/branches/ruleset/lib/RT/Ticket_Overlay.pm
rt/3.8/branches/ruleset/t/approval/basic.t
Log:
automatically open leaves of the approval tree with
transactionbatch.
Modified: rt/3.8/branches/ruleset/lib/RT/Approval.pm
==============================================================================
--- rt/3.8/branches/ruleset/lib/RT/Approval.pm (original)
+++ rt/3.8/branches/ruleset/lib/RT/Approval.pm Tue Dec 9 10:59:16 2008
@@ -10,6 +10,7 @@
'RT::Approval::Rule::NewPending',
'RT::Approval::Rule::Rejected',
'RT::Approval::Rule::Passed',
+ 'RT::Approval::Rule::Created',
]);
1;
Added: rt/3.8/branches/ruleset/lib/RT/Approval/Rule/Created.pm
==============================================================================
--- (empty file)
+++ rt/3.8/branches/ruleset/lib/RT/Approval/Rule/Created.pm Tue Dec 9 10:59:16 2008
@@ -0,0 +1,23 @@
+package RT::Approval::Rule::Created;
+use strict;
+use warnings;
+use base 'RT::Approval::Rule';
+
+use constant _Stage => 'TransactionBatch';
+
+use constant Description => "Notify Owner of their ticket has been approved by some or all approvers"; # loc
+
+sub Prepare {
+ my $self = shift;
+ return unless $self->SUPER::Prepare();
+
+ $self->TransactionObj->Type eq 'Create' &&
+ !$self->TicketObj->HasUnresolvedDependencies( Type => 'approval' );
+}
+
+sub Commit {
+ my $self = shift;
+ $self->RunScripAction('Open Tickets' => 'Blank');
+}
+
+1;
Modified: rt/3.8/branches/ruleset/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/3.8/branches/ruleset/lib/RT/Ticket_Overlay.pm (original)
+++ rt/3.8/branches/ruleset/lib/RT/Ticket_Overlay.pm Tue Dec 9 10:59:16 2008
@@ -3164,6 +3164,15 @@
TransactionObj => $batch->[0],
Type => join( ',', map $_->Type, grep defined, @{$batch} )
);
+
+ # Entry point of the rule system
+ my $rules = RT::Ruleset->FindAllRules(
+ Stage => 'TransactionBatch',
+ TicketObj => $self,
+ TransactionObj => $batch->[0],
+ Type => join( ',', map $_->Type, grep defined, @{$batch} )
+ );
+ RT::Ruleset->CommitRules($rules);
}
# }}}
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 Tue Dec 9 10:59:16 2008
@@ -8,14 +8,14 @@
or plan skip_all => 'require Email::Abstract and Test::Email';
}
-plan tests => 38;
+plan tests => 37;
use RT;
use RT::Test;
use RT::Test::Email;
RT->Config->Set( LogToScreen => 'debug' );
-
+RT->Config->Set( UseTransactionBatch => 1 );
my ($baseurl, $m) = RT::Test->started_ok;
my $q = RT::Queue->new($RT::SystemUser);
@@ -91,7 +91,11 @@
$t->Create(Subject => "PO for stationary",
Owner => "root", Requestor => 'minion',
Queue => $q->Id);
-} { from => qr/PO via RT/,
+} { from => qr/RT System/,
+ to => 'cfo at company.com',
+ subject => qr/New Pending Approval: CFO Approval/,
+ body => qr/pending your approval.*Your approval is requested.*Blah/s
+},{ from => qr/PO via RT/,
to => 'minion at company.com',
subject => qr/PO for stationary/,
body => qr/automatically generated in response/
@@ -101,19 +105,6 @@
is ($t->ReferredToBy->Count,2, "referred to by the two tickets");
-# open the approval tickets that are ready for approval
-mail_ok {
- for my $ticket ($t->AllDependsOn) {
- next if $ticket->Type ne 'approval' && $ticket->Status ne 'new';
- next if $ticket->HasUnresolvedDependencies( Type => 'approval' );
- $ticket->SetStatus('open');
- }
-} { from => qr/RT System/,
- to => 'cfo at company.com',
- subject => qr/New Pending Approval: CFO Approval/,
- body => qr/pending your approval.*Your approval is requested.*Blah/s
-};
-
my $deps = $t->DependsOn;
is ($deps->Count, 1, "The ticket we created depends on one other ticket");
my $dependson_ceo= $deps->First->TargetObj;
More information about the Rt-commit
mailing list