[Catalyst-commits] r6241 - in trunk/Catalyst-Runtime: . lib/Catalyst t t/lib/TestApp/Controller/Action/Chained

bricas at dev.catalyst.perl.org bricas at dev.catalyst.perl.org
Thu Mar 29 21:03:24 GMT 2007


Author: bricas
Date: 2007-03-29 21:03:24 +0100 (Thu, 29 Mar 2007)
New Revision: 6241

Added:
   trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Action/Chained/PathPrefix.pm
Modified:
   trunk/Catalyst-Runtime/Changes
   trunk/Catalyst-Runtime/lib/Catalyst/Controller.pm
   trunk/Catalyst-Runtime/t/live_component_controller_action_chained.t
Log:
added PathPrefix from branch

Modified: trunk/Catalyst-Runtime/Changes
===================================================================
--- trunk/Catalyst-Runtime/Changes	2007-03-29 19:44:12 UTC (rev 6240)
+++ trunk/Catalyst-Runtime/Changes	2007-03-29 20:03:24 UTC (rev 6241)
@@ -14,6 +14,7 @@
         - Added $c->request->keywords for getting the keywords (a query string with
           no parameters).
         - Sending SIGHUP to the dev server will now cause it to restart.
+        - Added PathPrefix attribute
         - Allow "0" for a path in uri_for.
 
 5.7007  2007-03-13 14:18:00

Modified: trunk/Catalyst-Runtime/lib/Catalyst/Controller.pm
===================================================================
--- trunk/Catalyst-Runtime/lib/Catalyst/Controller.pm	2007-03-29 19:44:12 UTC (rev 6240)
+++ trunk/Catalyst-Runtime/lib/Catalyst/Controller.pm	2007-03-29 20:03:24 UTC (rev 6241)
@@ -292,6 +292,11 @@
     return ( 'ActionClass', $value );
 }
 
+sub _parse_PathPrefix_attr {
+    my ( $self, $c, $name, $value ) = @_;
+    return PathPart => $self->path_prefix;
+}
+
 1;
 
 __END__

Added: trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Action/Chained/PathPrefix.pm
===================================================================
--- trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Action/Chained/PathPrefix.pm	                        (rev 0)
+++ trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Action/Chained/PathPrefix.pm	2007-03-29 20:03:24 UTC (rev 6241)
@@ -0,0 +1,12 @@
+package TestApp::Controller::Action::Chained::PathPrefix;
+
+use strict;
+use warnings;
+
+use base qw/Catalyst::Controller/;
+
+# this is kinda the same thing as: sub instance : Path {}
+# it should respond to: /action/chained/pathprefix/*
+sub instance : Chained('/') PathPrefix Args(1) { }
+
+1;

Modified: trunk/Catalyst-Runtime/t/live_component_controller_action_chained.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_component_controller_action_chained.t	2007-03-29 19:44:12 UTC (rev 6240)
+++ trunk/Catalyst-Runtime/t/live_component_controller_action_chained.t	2007-03-29 20:03:24 UTC (rev 6241)
@@ -10,7 +10,7 @@
 
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
 
-use Test::More tests => 109*$iters;
+use Test::More tests => 112*$iters;
 use Catalyst::Test 'TestApp';
 
 if ( $ENV{CAT_BENCHMARK} ) {
@@ -766,4 +766,22 @@
         is( $response->content, '; ', 'Content OK' );
     }
 
+    #
+    #   PathPrefix
+    #
+    {
+        my @expected = qw[
+          TestApp::Controller::Action::Chained->begin
+          TestApp::Controller::Action::Chained::PathPrefix->instance
+          TestApp::Controller::Action::Chained->end
+        ];
+
+        my $expected = join( ", ", @expected );
+
+        ok( my $response = request('http://localhost/action/chained/pathprefix/1'),
+            "PathPrefix (as an endpoint)" );
+        is( $response->header('X-Catalyst-Executed'),
+            $expected, 'Executed actions' );
+        is( $response->content, '; 1', 'Content OK' );
+    }
 }




More information about the Catalyst-commits mailing list