Fixed forward to classes
Sebastian Riedel [Sat, 26 Nov 2005 03:32:02 +0000 (03:32 +0000)]
Changes
lib/Catalyst.pm
lib/Catalyst/Dispatcher.pm
t/lib/TestApp.pm
t/lib/TestApp/Controller/Action/Forward.pm
t/live_component_controller_action_forward.t

diff --git a/Changes b/Changes
index 331abc5..f6b00b7 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 This file documents the revision history for Perl extension Catalyst.
 
+5.59
+        - Fixed forward to classes ($c->forward(qw/MyApp foo/))
+
 5.58    2005-11-24 10:51:00
         - Added ExtUtils::AutoInstall support
        - Allow overriding path in Catalyst::Helper.
index 58d3eb6..99aec69 100644 (file)
@@ -54,7 +54,7 @@ __PACKAGE__->engine_class('Catalyst::Engine::CGI');
 __PACKAGE__->request_class('Catalyst::Request');
 __PACKAGE__->response_class('Catalyst::Response');
 
-our $VERSION = '5.58';
+our $VERSION = '5.59';
 
 sub import {
     my ( $class, @arguments ) = @_;
index ac641a9..4ceea4c 100644 (file)
@@ -120,8 +120,10 @@ sub forward {
 
     unless ($result) {
 
-        my $class  = ref($command) || ref( $c->component($command) );
-        my $method = shift         || 'process';
+        my $class = ref($command)
+          || ref( $c->component($command) )
+          || $c->component($command);
+        my $method = shift || 'process';
 
         unless ($class) {
             my $error =
index 594dfa3..8630a98 100644 (file)
@@ -50,6 +50,11 @@ sub execute {
     return $c->SUPER::execute(@_);
 }
 
+sub class_forward_test_method {
+    my ( $self, $c ) = @_;
+    $c->response->headers->header( 'X-Class-Forward-Test-Method' => 1 );
+}
+
 {
     no warnings 'redefine';
     sub Catalyst::Log::error { }
index f966898..c6be731 100644 (file)
@@ -15,7 +15,7 @@ sub two : Private {
 
 sub three : Local {
     my ( $self, $c ) = @_;
-    $c->forward($self, 'four');
+    $c->forward( $self, 'four' );
 }
 
 sub four : Private {
@@ -31,7 +31,7 @@ sub five : Local {
 sub jojo : Local {
     my ( $self, $c ) = @_;
     $c->forward('one');
-    $c->forward($c->controller('Action::Forward'), 'three');
+    $c->forward( $c->controller('Action::Forward'), 'three' );
 }
 
 sub inheritance : Local {
@@ -65,19 +65,24 @@ sub args : Local {
 
 sub args_embed_relative : Local {
     my ( $self, $c ) = @_;
-    $c->forward( 'embed/ok' );
+    $c->forward('embed/ok');
 }
 
 sub args_embed_absolute : Local {
     my ( $self, $c ) = @_;
-    $c->forward( '/action/forward/embed/ok' );
+    $c->forward('/action/forward/embed/ok');
 }
 
 sub embed : Local {
     my ( $self, $c, $ok ) = @_;
-    
+
     $ok ||= 'not ok';
-    $c->res->body( $ok );
+    $c->res->body($ok);
+}
+
+sub class_forward_test_action : Local {
+    my ( $self, $c ) = @_;
+    $c->forward(qw/TestApp class_forward_test_method/);
 }
 
 1;
index 58d0ed4..5b23653 100644 (file)
@@ -10,7 +10,7 @@ our $iters;
 
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
 
-use Test::More tests => 44 * $iters;
+use Test::More tests => 47 * $iters;
 use Catalyst::Test 'TestApp';
 
 if ( $ENV{CAT_BENCHMARK} ) {
@@ -222,4 +222,17 @@ sub run_tests {
             'Content is a serialized Catalyst::Request'
         );
     }
+
+    # test class forwards
+    {
+        ok(
+            my $response = request(
+                'http://localhost/action/forward/class_forward_test_action'),
+            'Request'
+        );
+        ok( $response->is_success, 'Response Successful 2xx' );
+        is( $response->header('X-Class-Forward-Test-Method'), 1,
+            'Test Method' );
+    }
+
 }