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

rafl at dev.catalyst.perl.org rafl at dev.catalyst.perl.org
Fri Oct 17 08:27:45 BST 2008


Author: rafl
Date: 2008-10-17 08:27:44 +0100 (Fri, 17 Oct 2008)
New Revision: 8559

Modified:
   Catalyst-Runtime/5.80/trunk/Changes
   Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm
   Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_forward.t
   Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Forward.pm
Log:
Fix forwarding to Catalyst::Action objects.

Patch by Caelum++

Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes	2008-10-17 06:52:23 UTC (rev 8558)
+++ Catalyst-Runtime/5.80/trunk/Changes	2008-10-17 07:27:44 UTC (rev 8559)
@@ -1,5 +1,6 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+        - Fix forwarding to Catalyst::Action objects (Rafael Kitover).
         - Fix links to the mailing lists (Florian Ragwitz).
         - Use Class::MOP instead of Class::Inspector (Florian Ragwitz).
         - Change Catalyst::Test to use Sub::Exporter (Florian Ragwitz).

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm	2008-10-17 06:52:23 UTC (rev 8558)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm	2008-10-17 07:27:44 UTC (rev 8559)
@@ -133,8 +133,13 @@
     my $action;
 
     # go to a string path ("/foo/bar/gorch")
-    # or action object which stringifies to that
-    $action = $self->_invoke_as_path( $c, "$command", \@args );
+    # or action object
+    if (Scalar::Util::blessed($command) && $command->isa('Catalyst::Action')) {
+        $action = $command;
+    }
+    else {
+        $action = $self->_invoke_as_path( $c, "$command", \@args );
+    }
 
     # go to a component ( "MyApp::*::Foo" or $c->component("...")
     # - a path or an object)

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm	2008-10-17 06:52:23 UTC (rev 8558)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm	2008-10-17 07:27:44 UTC (rev 8559)
@@ -2481,6 +2481,8 @@
 
 bricas: Brian Cassidy <bricas at cpan.org>
 
+Caelum: Rafael Kitover <rkitover at io.com>
+
 chansen: Christian Hansen
 
 chicks: Christopher Hicks

Modified: Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_forward.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_forward.t	2008-10-17 06:52:23 UTC (rev 8558)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_forward.t	2008-10-17 07:27:44 UTC (rev 8559)
@@ -10,7 +10,7 @@
 
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
 
-use Test::More tests => 50 * $iters;
+use Test::More tests => 53 * $iters;
 use Catalyst::Test 'TestApp';
 
 if ( $ENV{CAT_BENCHMARK} ) {
@@ -245,4 +245,15 @@
         is( $response->content, '/action/forward/foo/bar',
              'forward_to_uri_check correct namespace');
     }
+
+    # test forwarding to Catalyst::Action objects
+    {
+        ok( my $response = request(
+            'http://localhost/action/forward/to_action_object'),
+            'forward/to_action_object request');
+
+        ok( $response->is_success, 'forward/to_action_object successful');
+        is( $response->content, 'mtfnpy',
+             'forward/to_action_object forwards correctly');
+    }
 }

Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Forward.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Forward.pm	2008-10-17 06:52:23 UTC (rev 8558)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Forward.pm	2008-10-17 07:27:44 UTC (rev 8559)
@@ -57,6 +57,11 @@
     $c->res->body( $c->req->args->[0] );
 }
 
+sub to_action_object : Local {
+    my ( $self, $c ) = @_;
+    $c->forward($self->action_for('embed'), [qw/mtfnpy/]);
+}
+
 sub args : Local {
     my ( $self, $c, $val ) = @_;
     die "Expected argument 'new', got '$val'" unless $val eq 'new';




More information about the Catalyst-commits mailing list