[Rt-commit] rt branch, new-style-templates, updated. rt-3.8.8-192-g1b2ce07
Shawn Moore
sartak at bestpractical.com
Wed Jul 21 00:32:42 EDT 2010
The branch, new-style-templates has been updated
via 1b2ce0753ed82a15ee0593d7a5ca3ec325f9826a (commit)
via 8aad35fa5430b79d414174d34ec43790eeeea162 (commit)
from 271d8cdd619df8c1cba1165e2f09eb88e090d45c (commit)
Summary of changes:
lib/RT/Template_Overlay.pm | 14 +++++++-------
t/api/template-simple.t | 28 +++++++++++++++++++++++-----
2 files changed, 30 insertions(+), 12 deletions(-)
- Log -----------------------------------------------------------------
commit 8aad35fa5430b79d414174d34ec43790eeeea162
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Jul 21 00:33:40 2010 -0400
Move the ref-ification into _ParseContentFull since it's a Text::Template-ism
diff --git a/lib/RT/Template_Overlay.pm b/lib/RT/Template_Overlay.pm
index 9fc5e97..48d3fac 100755
--- a/lib/RT/Template_Overlay.pm
+++ b/lib/RT/Template_Overlay.pm
@@ -402,13 +402,6 @@ sub _ParseContent {
$args{'loc'} = sub { $self->loc(@_) };
}
- foreach my $key ( keys %args ) {
- next unless ref $args{ $key };
- next if ref $args{ $key } =~ /^(ARRAY|HASH|SCALAR|CODE)$/;
- my $val = $args{ $key };
- $args{ $key } = \$val;
- }
-
if ($self->Type eq 'Full') {
return $self->_ParseContentFull(
Content => $content,
@@ -432,6 +425,13 @@ sub _ParseContentFull {
@_,
);
+ foreach my $key ( keys %{ $args{TemplateArgs} } ) {
+ my $val = $args{TemplateArgs}{ $key };
+ next unless ref $val;
+ next if ref $val =~ /^(ARRAY|HASH|SCALAR|CODE)$/;
+ $args{TemplateArgs}{ $key } = \$val;
+ }
+
my $template = Text::Template->new(
TYPE => 'STRING',
SOURCE => $args{Content},
commit 1b2ce0753ed82a15ee0593d7a5ca3ec325f9826a
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Jul 21 00:34:25 2010 -0400
More and better tests!
diff --git a/t/api/template-simple.t b/t/api/template-simple.t
index 79d18b9..123fb05 100644
--- a/t/api/template-simple.t
+++ b/t/api/template-simple.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
use RT;
-use RT::Test tests => 48;
+use RT::Test tests => 83;
my $ticket = RT::Ticket->new($RT::SystemUser);
my ($id, $msg) = $ticket->Create(
@@ -31,11 +31,29 @@ TemplateTest(
);
TemplateTest(
+ Content => "\ntest { \$Ticket->Subject }",
+ FullOutput => "test template testing",
+ SimpleOutput => "test template testing",
+);
+
+TemplateTest(
+ Content => "\ntest { \$Nonexistent }",
+ FullOutput => "test ",
+ SimpleOutput => "test { \$Nonexistent }",
+);
+
+TemplateTest(
Content => "\ntest { \$Ticket->Nonexistent }",
FullOutput => undef,
SimpleOutput => "test { \$Ticket->Nonexistent }",
);
+TemplateTest(
+ Content => "\ntest { \$Nonexistent->Nonexistent }",
+ FullOutput => undef,
+ SimpleOutput => "test { \$Nonexistent->Nonexistent }",
+);
+
my $counter = 0;
sub IndividualTemplateTest {
local $Test::Builder::Level = $Test::Builder::Level + 1;
@@ -53,9 +71,9 @@ sub IndividualTemplateTest {
Content => $args{Content},
);
- ok($t->id, "Created template");
- is($t->Name, $args{Name}, "template name");
- is($t->Content, $args{Content}, "content");
+ ok($t->id, "Created $args{Type} template");
+ is($t->Name, $args{Name}, "$args{Type} template name");
+ is($t->Content, $args{Content}, "$args{Type} content");
is($t->Type, $args{Type}, "template type");
my ($ok, $msg) = $t->Parse(
@@ -64,7 +82,7 @@ sub IndividualTemplateTest {
);
if (defined $args{Output}) {
ok($ok, $msg);
- is($t->MIMEObj->stringify_body, $args{Output}, "template's output");
+ is($t->MIMEObj->stringify_body, $args{Output}, "$args{Type} template's output");
}
else {
ok(!$ok, "expected failure: $msg");
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list