- sub foo :Path { ... } now works!
Matt S Trout [Tue, 1 Nov 2005 03:02:52 +0000 (03:02 +0000)]
lib/Catalyst/DispatchType/Path.pm
t/live/component/controller/action/path.t
t/live/lib/TestApp/Controller/Action/Path.pm

index 81603d5..e9ed811 100644 (file)
@@ -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 );
index 5df8312..7221e8b 100644 (file)
@@ -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'
+        );
+    }
 }
index 2c19f0e..fd82c0c 100644 (file)
@@ -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;