From: Matt S Trout Date: Tue, 1 Nov 2005 03:02:52 +0000 (+0000) Subject: - sub foo :Path { ... } now works! X-Git-Tag: 5.7099_04~1070 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=b74baa06c48a64bc5f1217f26d325e24fbc51528 - sub foo :Path { ... } now works! --- diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index 81603d5..e9ed811 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -65,7 +65,10 @@ sub register { my @register; foreach my $r ( @{ $attrs->{Path} || [] } ) { - unless ( $r =~ m!^/! ) { # It's a relative path + unless ( $r ) { + $r = $action->namespace; + } + elsif ( $r !~ m!^/! ) { # It's a relative path $r = $action->namespace . "/$r"; } push( @register, $r ); diff --git a/t/live/component/controller/action/path.t b/t/live/component/controller/action/path.t index 5df8312..7221e8b 100644 --- a/t/live/component/controller/action/path.t +++ b/t/live/component/controller/action/path.t @@ -10,7 +10,7 @@ our $iters; BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } -use Test::More tests => 12*$iters; +use Test::More tests => 18*$iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -67,4 +67,23 @@ sub run_tests { 'Content is a serialized Catalyst::Request' ); } + + { + ok( my $response = request('http://localhost/action/path/'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'action/path', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Path', + 'Test Class' + ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Request' \)$/s, + 'Content is a serialized Catalyst::Request' + ); + } } diff --git a/t/live/lib/TestApp/Controller/Action/Path.pm b/t/live/lib/TestApp/Controller/Action/Path.pm index 2c19f0e..fd82c0c 100644 --- a/t/live/lib/TestApp/Controller/Action/Path.pm +++ b/t/live/lib/TestApp/Controller/Action/Path.pm @@ -13,4 +13,9 @@ sub two : Action Path("åäö") { $c->forward('TestApp::View::Dump::Request'); } +sub three :Path { + my ( $self, $c ) = @_; + $c->forward('TestApp::View::Dump::Request'); +} + 1;