[Jifty-commit] r4368 - in Template-Declare: t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Nov 3 16:49:14 EDT 2007


Author: sterling
Date: Sat Nov  3 16:49:13 2007
New Revision: 4368

Added:
   Template-Declare/t/similar-aliases.t
Modified:
   Template-Declare/   (props changed)

Log:
 r13845 at dynpc145:  andrew | 2007-11-03 15:48:47 -0500
 Added a test to demonstrate a failure in aliased template resolution.


Added: Template-Declare/t/similar-aliases.t
==============================================================================
--- (empty file)
+++ Template-Declare/t/similar-aliases.t	Sat Nov  3 16:49:13 2007
@@ -0,0 +1,56 @@
+use warnings;
+use strict;
+
+# Reveals a problem T-D once had with matching aliases in two differen files:
+#
+# alias Foo under /foo
+# alias Admin::Foo under /admin/foo
+#
+# where each alias had a "list" or something other matching thing. The template
+# resolver could match /foo/list when looking for /admin/foo/list.
+
+package Foo;
+use base qw/ Template::Declare /;
+use Template::Declare::Tags;
+
+template 'list' => sub {
+    my $self = shift;
+    div { outs( 'This is aliased from ' . $self ) };
+};
+
+package Admin::Foo;
+use base qw/ Template::Declare /;
+use Template::Declare::Tags;
+
+template 'list' => sub {
+    my $self = shift;
+    div { outs( 'This is aliased from ' . $self ) };
+};
+
+package App;
+use base qw/ Template::Declare /;
+use Template::Declare::Tags;
+
+alias Foo under '/foo';
+alias Admin::Foo under '/admin/foo';
+
+package main;
+use Template::Declare::Tags;
+Template::Declare->init( roots => [ 'App' ] );
+
+use Test::More tests => 6;
+
+ok(Template::Declare->has_template('foo/list'), 'has a foo/list');
+ok(Template::Declare->has_template('admin/foo/list'), 'has an admin/foo/list');
+
+{
+    my $output = show('foo/list');
+    like($output, qr/\bThis is aliased\b/);
+    like($output, qr/\bfrom Foo\b/);
+}
+
+{
+    my $output = show('admin/foo/list');
+    like($output, qr/\bThis is aliased\b/);
+    like($output, qr/\bfrom Admin::Foo\b/);
+}


More information about the Jifty-commit mailing list