[Catalyst-commits] r7778 - in Catalyst-Runtime/5.70/trunk: . lib/Catalyst/DispatchType t t/lib

bricas at dev.catalyst.perl.org bricas at dev.catalyst.perl.org
Fri May 23 17:54:31 BST 2008


Author: bricas
Date: 2008-05-23 17:54:30 +0100 (Fri, 23 May 2008)
New Revision: 7778

Added:
   Catalyst-Runtime/5.70/trunk/t/custom_live_path_bug.t
   Catalyst-Runtime/5.70/trunk/t/lib/TestAppPathBug.pm
Modified:
   Catalyst-Runtime/5.70/trunk/Changes
   Catalyst-Runtime/5.70/trunk/lib/Catalyst/DispatchType/Path.pm
Log:
Fix regression for "sub foo : Path {}" in the root controller which was introduced when attempting to allow "0" as a Path.

Modified: Catalyst-Runtime/5.70/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.70/trunk/Changes	2008-05-23 14:58:07 UTC (rev 7777)
+++ Catalyst-Runtime/5.70/trunk/Changes	2008-05-23 16:54:30 UTC (rev 7778)
@@ -3,6 +3,8 @@
 5.7014  ---
         - Fix regression for relative uri_for arguments after a forward()
           introduced in 5.7013 (Peter Karman)
+        - Fix regression for "sub foo : Path {}" in the root controller which
+          was introduced when attempting to allow "0" as a Path.
 
 5.7013  2008-05-16 18:20:00
         - Provide backwards compatability methods in Catalyst::Stats

Modified: Catalyst-Runtime/5.70/trunk/lib/Catalyst/DispatchType/Path.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/lib/Catalyst/DispatchType/Path.pm	2008-05-23 14:58:07 UTC (rev 7777)
+++ Catalyst-Runtime/5.70/trunk/lib/Catalyst/DispatchType/Path.pm	2008-05-23 16:54:30 UTC (rev 7778)
@@ -47,7 +47,7 @@
 sub match {
     my ( $self, $c, $path ) = @_;
 
-    $path = '/' if !defined $path;
+    $path = '/' if !defined $path || !length $path;
 
     foreach my $action ( @{ $self->{paths}->{$path} || [] } ) {
         next unless $action->match($c);

Added: Catalyst-Runtime/5.70/trunk/t/custom_live_path_bug.t
===================================================================
--- Catalyst-Runtime/5.70/trunk/t/custom_live_path_bug.t	                        (rev 0)
+++ Catalyst-Runtime/5.70/trunk/t/custom_live_path_bug.t	2008-05-23 16:54:30 UTC (rev 7778)
@@ -0,0 +1,39 @@
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+our $iters;
+
+BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
+
+use Test::More tests => 2*$iters;
+use Catalyst::Test 'TestAppPathBug';
+
+if ( $ENV{CAT_BENCHMARK} ) {
+    require Benchmark;
+    Benchmark::timethis( $iters, \&run_tests );
+}
+else {
+    for ( 1 .. $iters ) {
+        run_tests();
+    }
+}
+    
+sub run_tests {
+    SKIP:
+    {
+        if ( $ENV{CATALYST_SERVER} ) {
+            skip 'Using remote server', 2;
+        }
+        
+        {
+            my $expected = 'This is the foo method.';
+            ok( my $response = request('http://localhost/'), 'response ok' );
+            is( $response->content, $expected, 'Content OK' );
+        }
+    }
+}

Added: Catalyst-Runtime/5.70/trunk/t/lib/TestAppPathBug.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/t/lib/TestAppPathBug.pm	                        (rev 0)
+++ Catalyst-Runtime/5.70/trunk/t/lib/TestAppPathBug.pm	2008-05-23 16:54:30 UTC (rev 7778)
@@ -0,0 +1,19 @@
+use strict;
+use warnings;
+
+package TestAppPathBug;
+
+use Catalyst;
+
+our $VERSION = '0.01';
+
+__PACKAGE__->config( name => 'TestAppPathBug', root => '/some/dir' );
+
+__PACKAGE__->setup;
+
+sub foo : Path {
+    my ( $self, $c ) = @_;
+    $c->res->body( 'This is the foo method.' );
+}
+
+1;




More information about the Catalyst-commits mailing list