[Rt-commit] rt branch, new-style-templates, updated. rt-3.8.8-209-gbbf4626

Shawn Moore sartak at bestpractical.com
Mon Jul 26 15:54:13 EDT 2010


The branch, new-style-templates has been updated
       via  bbf4626365e126e2c7faa81c26ecb85dfc29d657 (commit)
      from  d32274b59b9c770af4bc10411088c14ca7b1f0c1 (commit)

Summary of changes:
 lib/RT/Template_Overlay.pm |   15 ++++++++++++++-
 t/api/template-simple.t    |   35 +++++++++++++++++++++++++++++++++--
 2 files changed, 47 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit bbf4626365e126e2c7faa81c26ecb85dfc29d657
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Jul 26 15:55:58 2010 -0400

    Add queue and owner variables to simple templates

diff --git a/lib/RT/Template_Overlay.pm b/lib/RT/Template_Overlay.pm
index 068f427..a949767 100755
--- a/lib/RT/Template_Overlay.pm
+++ b/lib/RT/Template_Overlay.pm
@@ -524,9 +524,22 @@ sub _MassageSimpleTemplateArgs {
     my $template_args = $args{TemplateArgs};
 
     if (my $ticket = $template_args->{Ticket}) {
-        for my $column (qw/Subject/) {
+        for my $column (qw/Subject Queue/) {
             $template_args->{"Ticket".$column} = $ticket->$column;
         }
+
+        $template_args->{"TicketQueueId"}   = $ticket->Queue;
+        $template_args->{"TicketQueueName"} = $ticket->QueueObj->Name;
+
+        $template_args->{"TicketOwnerId"}    = $ticket->Owner;
+        $template_args->{"TicketOwnerName"}  = $ticket->OwnerObj->Name;
+        $template_args->{"TicketOwnerEmailAddress"} = $ticket->OwnerObj->EmailAddress;
+    }
+
+    if (my $txn = $template_args->{Transaction}) {
+        for my $column (qw//) {
+            $template_args->{"Transaction".$column} = $txn->$column;
+        }
     }
 }
 
diff --git a/t/api/template-simple.t b/t/api/template-simple.t
index cf7447f..a60f450 100644
--- a/t/api/template-simple.t
+++ b/t/api/template-simple.t
@@ -1,12 +1,13 @@
 use strict;
 use warnings;
 use RT;
-use RT::Test tests => 107;
+use RT::Test tests => 167;
 
 my $ticket = RT::Ticket->new($RT::SystemUser);
 my ($id, $msg) = $ticket->Create(
     Subject   => "template testing",
     Queue     => "General",
+    Owner     => 'root at localhost',
     Requestor => ["dom\@example.com"],
 );
 ok($id, "Created ticket");
@@ -37,6 +38,36 @@ TemplateTest(
 );
 
 TemplateTest(
+    Content      => "\ntest { \$TicketQueueId }",
+    FullOutput   => "test ",
+    SimpleOutput => "test 1",
+);
+
+TemplateTest(
+    Content      => "\ntest { \$TicketQueueName }",
+    FullOutput   => "test ",
+    SimpleOutput => "test General",
+);
+
+TemplateTest(
+    Content      => "\ntest { \$TicketOwnerId }",
+    FullOutput   => "test ",
+    SimpleOutput => "test 12",
+);
+
+TemplateTest(
+    Content      => "\ntest { \$TicketOwnerName }",
+    FullOutput   => "test ",
+    SimpleOutput => "test root",
+);
+
+TemplateTest(
+    Content      => "\ntest { \$TicketOwnerEmailAddress }",
+    FullOutput   => "test ",
+    SimpleOutput => "test root\@localhost",
+);
+
+TemplateTest(
     Content      => "\ntest { \$Nonexistent }",
     FullOutput   => "test ",
     SimpleOutput => "test { \$Nonexistent }",
@@ -56,7 +87,7 @@ TemplateTest(
 
 TemplateTest(
     Content      => "\ntest { \$Ticket->OwnerObj->Name }",
-    FullOutput   => "test Nobody",
+    FullOutput   => "test root",
     SimpleOutput => "test { \$Ticket->OwnerObj->Name }",
 );
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list