[Catalyst-commits] r7938 - in Catalyst-Runtime/5.70/trunk: . lib/Catalyst t t/lib/TestApp/Controller

bricas at dev.catalyst.perl.org bricas at dev.catalyst.perl.org
Mon Jun 23 14:38:24 BST 2008


Author: bricas
Date: 2008-06-23 14:38:24 +0100 (Mon, 23 Jun 2008)
New Revision: 7938

Modified:
   Catalyst-Runtime/5.70/trunk/Changes
   Catalyst-Runtime/5.70/trunk/lib/Catalyst/Controller.pm
   Catalyst-Runtime/5.70/trunk/t/lib/TestApp/Controller/Root.pm
   Catalyst-Runtime/5.70/trunk/t/live_component_controller_action_regexp.t
Log:
Fix for LocalRegex when used in the Root controller

Modified: Catalyst-Runtime/5.70/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.70/trunk/Changes	2008-06-22 10:30:20 UTC (rev 7937)
+++ Catalyst-Runtime/5.70/trunk/Changes	2008-06-23 13:38:24 UTC (rev 7938)
@@ -1,6 +1,7 @@
 # This file documents the revision history for Perl extension Catalyst.
 
 5.7xxx  xxx
+        - Fix for LocalRegex when used in the Root controller
         - Get some of the optional_* tests working from dirs with spaces (RT #26455)
         - Fix Catalyst::Utils::home() when application .pm is in the current dir (RT #34437)
         - Added the ability to remove parameters in req->uri_with() by passing in

Modified: Catalyst-Runtime/5.70/trunk/lib/Catalyst/Controller.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/lib/Catalyst/Controller.pm	2008-06-22 10:30:20 UTC (rev 7937)
+++ Catalyst-Runtime/5.70/trunk/lib/Catalyst/Controller.pm	2008-06-23 13:38:24 UTC (rev 7938)
@@ -270,7 +270,11 @@
 sub _parse_LocalRegex_attr {
     my ( $self, $c, $name, $value ) = @_;
     unless ( $value =~ s/^\^// ) { $value = "(?:.*?)$value"; }
-    return ( 'Regex', '^' . $self->path_prefix($c) . "/${value}" );
+
+    my $prefix = $self->path_prefix( $c );
+    $prefix .= '/' if length( $prefix );
+   
+    return ( 'Regex', "^${prefix}${value}" );
 }
 
 sub _parse_LocalRegexp_attr { shift->_parse_LocalRegex_attr(@_); }

Modified: Catalyst-Runtime/5.70/trunk/t/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/t/lib/TestApp/Controller/Root.pm	2008-06-22 10:30:20 UTC (rev 7937)
+++ Catalyst-Runtime/5.70/trunk/t/lib/TestApp/Controller/Root.pm	2008-06-23 13:38:24 UTC (rev 7938)
@@ -13,4 +13,11 @@
     $c->forward('TestApp::View::Dump::Request');
 }
 
+sub localregex : LocalRegex('^localregex$') {
+    my ( $self, $c ) = @_;
+    $c->res->header( 'X-Test-Class' => ref($self) );
+    $c->response->content_type('text/plain; charset=utf-8');
+    $c->forward('TestApp::View::Dump::Request');
+}
+
 1;

Modified: Catalyst-Runtime/5.70/trunk/t/live_component_controller_action_regexp.t
===================================================================
--- Catalyst-Runtime/5.70/trunk/t/live_component_controller_action_regexp.t	2008-06-22 10:30:20 UTC (rev 7937)
+++ Catalyst-Runtime/5.70/trunk/t/live_component_controller_action_regexp.t	2008-06-23 13:38:24 UTC (rev 7938)
@@ -10,7 +10,7 @@
 
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
 
-use Test::More tests => 28*$iters;
+use Test::More tests => 33*$iters;
 use Catalyst::Test 'TestApp';
 
 use Catalyst::Request;
@@ -103,4 +103,19 @@
         is( $req->captures->[ 0 ], 'mandatory', 'mandatory capture' );
         is( $req->captures->[ 1 ], '/optional', 'optional capture' );
     }
+
+    # test localregex in the root controller
+    {
+        ok( my $response = request('http://localhost/localregex'),
+            'Request' );
+        ok( $response->is_success, 'Response Successful 2xx' );
+        is( $response->content_type, 'text/plain', 'Response Content-Type' );
+        is( $response->header('X-Catalyst-Action'),
+            '^localregex$', 'Test Action' );
+        is(
+            $response->header('X-Test-Class'),
+            'TestApp::Controller::Root',
+            'Test Class'
+        );
+    }
 }




More information about the Catalyst-commits mailing list