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

bricas at dev.catalyst.perl.org bricas at dev.catalyst.perl.org
Thu Aug 2 15:18:23 GMT 2007


Author: bricas
Date: 2007-08-02 15:18:21 +0100 (Thu, 02 Aug 2007)
New Revision: 6609

Modified:
   trunk/Catalyst-Runtime/Changes
   trunk/Catalyst-Runtime/lib/Catalyst/Dispatcher.pm
   trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Action/Regexp.pm
   trunk/Catalyst-Runtime/t/live_component_controller_action_regexp.t
Log:
remove warning for undef captures

Modified: trunk/Catalyst-Runtime/Changes
===================================================================
--- trunk/Catalyst-Runtime/Changes	2007-08-01 14:22:14 UTC (rev 6608)
+++ trunk/Catalyst-Runtime/Changes	2007-08-02 14:18:21 UTC (rev 6609)
@@ -1,10 +1,10 @@
 This file documents the revision history for Perl extension Catalyst.
 
 5.7008
-	- add undef warning for uri_for
+        - Add undef warning for uri_for
         - Fix bug where a nested component would be setup twice
         - Make ensure_class_loaded behave better with malformed class name
-	- Make _register_plugin use ensure_class_loaded
+        - Make _register_plugin use ensure_class_loaded
         - Remove 'Argument "??" isn't numeric in sprintf' warning
           (Emanuele Zeppieri)
         - Fixed a bug where Content-Length could be set to 0 if a filehandle
@@ -12,6 +12,7 @@
         - Fixed issue where development server running in fork mode did not
           properly exit after a write error.
           (http://rt.cpan.org/Ticket/Display.html?id=27135)
+        - Remove warning for captures that are undef
 
 5.7007  2007-03-13 14:18:00
         - Many performance improvements by not using URI.pm:

Modified: trunk/Catalyst-Runtime/lib/Catalyst/Dispatcher.pm
===================================================================
--- trunk/Catalyst-Runtime/lib/Catalyst/Dispatcher.pm	2007-08-01 14:22:14 UTC (rev 6608)
+++ trunk/Catalyst-Runtime/lib/Catalyst/Dispatcher.pm	2007-08-02 14:18:21 UTC (rev 6609)
@@ -282,7 +282,7 @@
         unshift @args, $arg;
     }
 
-    s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg for @{$c->req->captures||[]};
+    s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg for grep { defined } @{$c->req->captures||[]};
 
     $c->log->debug( 'Path is "' . $c->req->match . '"' )
       if ( $c->debug && $c->req->match );

Modified: trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Action/Regexp.pm
===================================================================
--- trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Action/Regexp.pm	2007-08-01 14:22:14 UTC (rev 6608)
+++ trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Action/Regexp.pm	2007-08-02 14:18:21 UTC (rev 6609)
@@ -13,4 +13,9 @@
     $c->forward('TestApp::View::Dump::Request');
 }
 
+sub three : Action LocalRegex('^(mandatory)(/optional)?$'){
+    my ( $self, $c ) = @_;
+    $c->forward('TestApp::View::Dump::Request');
+}
+
 1;

Modified: trunk/Catalyst-Runtime/t/live_component_controller_action_regexp.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_component_controller_action_regexp.t	2007-08-01 14:22:14 UTC (rev 6608)
+++ trunk/Catalyst-Runtime/t/live_component_controller_action_regexp.t	2007-08-02 14:18:21 UTC (rev 6609)
@@ -10,7 +10,7 @@
 
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
 
-use Test::More tests => 12*$iters;
+use Test::More tests => 28*$iters;
 use Catalyst::Test 'TestApp';
 
 if ( $ENV{CAT_BENCHMARK} ) {
@@ -61,4 +61,44 @@
             'Content is a serialized Catalyst::Request'
         );
     }
+
+    {
+        ok( my $response = request('http://localhost/action/regexp/mandatory'),
+            'Request' );
+        ok( $response->is_success, 'Response Successful 2xx' );
+        is( $response->content_type, 'text/plain', 'Response Content-Type' );
+        is( $response->header('X-Catalyst-Action'),
+            '^action/regexp/(mandatory)(/optional)?$', 'Test Action' );
+        is(
+            $response->header('X-Test-Class'),
+            'TestApp::Controller::Action::Regexp',
+            'Test Class'
+        );
+        my $content = $response->content;
+        my $req = eval $content; 
+
+        is( scalar @{ $req->captures }, 2, 'number of captures' );
+        is( $req->captures->[ 0 ], 'mandatory', 'mandatory capture' );
+        ok( !defined $req->captures->[ 1 ], 'optional capture' );
+    }
+
+    {
+        ok( my $response = request('http://localhost/action/regexp/mandatory/optional'),
+            'Request' );
+        ok( $response->is_success, 'Response Successful 2xx' );
+        is( $response->content_type, 'text/plain', 'Response Content-Type' );
+        is( $response->header('X-Catalyst-Action'),
+            '^action/regexp/(mandatory)(/optional)?$', 'Test Action' );
+        is(
+            $response->header('X-Test-Class'),
+            'TestApp::Controller::Action::Regexp',
+            'Test Class'
+        );
+        my $content = $response->content;
+        my $req = eval $content; 
+
+        is( scalar @{ $req->captures }, 2, 'number of captures' );
+        is( $req->captures->[ 0 ], 'mandatory', 'mandatory capture' );
+        is( $req->captures->[ 1 ], '/optional', 'optional capture' );
+    }
 }




More information about the Catalyst-commits mailing list