[Catalyst-commits] r9926 - in Catalyst-Runtime/5.80/trunk: . lib/Catalyst/DispatchType t/aggregate t/lib/TestApp/Controller/Action

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Tue Apr 28 21:41:51 GMT 2009


Author: t0m
Date: 2009-04-28 22:41:51 +0100 (Tue, 28 Apr 2009)
New Revision: 9926

Modified:
   Catalyst-Runtime/5.80/trunk/Changes
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Regex.pm
   Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_regexp.t
   Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Regexp.pm
Log:
Patch for uri_for_action with regex dispatch from RT#39369

Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes	2009-04-28 20:58:15 UTC (rev 9925)
+++ Catalyst-Runtime/5.80/trunk/Changes	2009-04-28 21:41:51 UTC (rev 9926)
@@ -19,6 +19,8 @@
         - Additional tests for setup_stats method. (t0m)
         - Fix log levels in Catalyst::Log to be properly additive. (t0m)
         - Fix RT#43375 by sorting results before testing them (t0m)
+        - Fixes for uri_for_action when using Catalyst::DispatchType::Regex
+          + tests from RT#39369 (norbi)
 
 5.80002 2009-04-22 01:28:36
         - Fix CATALYST_DEBUG and MYAPP_DEBUG environment variables

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Regex.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Regex.pm	2009-04-28 20:58:15 UTC (rev 9925)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Regex.pm	2009-04-28 21:41:51 UTC (rev 9926)
@@ -150,11 +150,13 @@
             my $final = '/';
             my @captures = @$captures;
             while (my ($front, $rest) = split(/\(/, $re, 2)) {
+                last unless defined $rest;
                 ($rest, $re) =
                     Text::Balanced::extract_bracketed("(${rest}", '(');
                 next REGEX unless @captures;
                 $final .= $front.shift(@captures);
             }
+            $final .= $re;
             next REGEX if @captures;
             return $final;
          }

Modified: Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_regexp.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_regexp.t	2009-04-28 20:58:15 UTC (rev 9925)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_regexp.t	2009-04-28 21:41:51 UTC (rev 9926)
@@ -10,7 +10,7 @@
 
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
 
-use Test::More tests => 33*$iters;
+use Test::More tests => 38*$iters;
 use Catalyst::Test 'TestApp';
 
 use Catalyst::Request;
@@ -118,4 +118,24 @@
             'Test Class'
         );
     }
+    
+    {
+        my $url = 'http://localhost/action/regexp/redirect/life/universe/42/everything';
+        ok( my $response = request($url),
+            'Request' );
+        ok( $response->is_redirect, 'Response is redirect' );
+        is( $response->header('X-Catalyst-Action'),
+            '^action/regexp/redirect/(\w+)/universe/(\d+)/everything$', 'Test Action' );
+        is(
+            $response->header('X-Test-Class'),
+            'TestApp::Controller::Action::Regexp',
+            'Test Class'
+        );
+        is(
+            $response->header('location'),
+            $url,
+            'Redirect URI is the same as the request URI'
+        );
+    }
 }
+

Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Regexp.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Regexp.pm	2009-04-28 20:58:15 UTC (rev 9925)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Regexp.pm	2009-04-28 21:41:51 UTC (rev 9926)
@@ -18,4 +18,13 @@
     $c->forward('TestApp::View::Dump::Request');
 }
 
+sub four : Action Regex('^action/regexp/redirect/(\w+)/universe/(\d+)/everything$') {
+    my ( $self, $c ) = @_;
+    $c->res->redirect(
+        $c->uri_for($c->action, $c->req->captures,
+            @{$c->req->arguments}, $c->req->params
+        )
+    );
+}
+
 1;




More information about the Catalyst-commits mailing list