From: Brian Cassidy Date: Fri, 23 May 2008 16:54:30 +0000 (+0000) Subject: Fix regression for "sub foo : Path {}" in the root controller which was introduced... X-Git-Tag: 5.7099_04~72 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=eb221f9654404bdad5bd0dc5157e3a04bc272fa4 Fix regression for "sub foo : Path {}" in the root controller which was introduced when attempting to allow "0" as a Path. --- diff --git a/Changes b/Changes index 97b7dca..1d8d804 100644 --- a/Changes +++ b/Changes @@ -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 diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index d983d8a..16a2314 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -47,7 +47,7 @@ first action that matches, if any; if not, returns 0. 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); diff --git a/t/custom_live_path_bug.t b/t/custom_live_path_bug.t new file mode 100644 index 0000000..9bbbd55 --- /dev/null +++ b/t/custom_live_path_bug.t @@ -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' ); + } + } +} diff --git a/t/lib/TestAppPathBug.pm b/t/lib/TestAppPathBug.pm new file mode 100644 index 0000000..3d3b11b --- /dev/null +++ b/t/lib/TestAppPathBug.pm @@ -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;