[Catalyst-dev] patch for namespace bug introduced in r7385

Peter Karman peter at peknet.com
Wed May 21 14:18:31 GMT 2008


The patch below is a test exposing the namespace bug introduced in r7385. This patch is
against 5.70/trunk.

The fix is simply to remove the $c->{namespace} ....
line in Catalyst::Action->dispatch().

It's not clear to me why the current context namespace needs to change at all. But in any
case, this test shows the result of changing it.

Index: t/live_component_controller_action_forward.t
===================================================================
--- t/live_component_controller_action_forward.t        (revision 7765)
+++ t/live_component_controller_action_forward.t        (working copy)
@@ -10,7 +10,7 @@

 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }

-use Test::More tests => 47 * $iters;
+use Test::More tests => 50 * $iters;
 use Catalyst::Test 'TestApp';

 if ( $ENV{CAT_BENCHMARK} ) {
@@ -234,5 +234,16 @@
         is( $response->header('X-Class-Forward-Test-Method'), 1,
             'Test Method' );
     }
+
+    # test uri_for re r7385
+    {
+        ok( my $response = request(
+            'http://localhost/action/forward/forward_to_uri_check'),
+            'forward_to_uri_check request');
+
+        ok( $response->is_success, 'forward_to_uri_check successful');
+        is( $response->content, 'http://localhost/action/forward/foo/bar',
+             'forward_to_uri_check correct namespace');
+    }

 }
Index: t/lib/TestApp/Controller/Action/Forward.pm
===================================================================
--- t/lib/TestApp/Controller/Action/Forward.pm  (revision 7765)
+++ t/lib/TestApp/Controller/Action/Forward.pm  (working copy)
@@ -85,4 +85,9 @@
     $c->forward(qw/TestApp class_forward_test_method/);
 }

+sub forward_to_uri_check : Local {
+    my ( $self, $c ) = @_;
+    $c->forward( 'Action::ForwardTo', 'uri_check' );
+}
+
 1;
Index: t/lib/TestApp/Controller/Action/ForwardTo.pm
===================================================================
--- t/lib/TestApp/Controller/Action/ForwardTo.pm        (revision 0)
+++ t/lib/TestApp/Controller/Action/ForwardTo.pm        (revision 0)
@@ -0,0 +1,11 @@
+package TestApp::Controller::Action::ForwardTo;
+
+use strict;
+use base 'TestApp::Controller::Action';
+
+sub uri_check : Private {
+    my ( $self, $c ) = @_;
+    $c->res->body( $c->uri_for('foo/bar') );
+}
+
+1;

-- 
Peter Karman  .  peter at peknet.com  .  http://peknet.com/




More information about the Catalyst-dev mailing list