From: Sebastian Riedel Date: Sat, 26 Nov 2005 03:32:02 +0000 (+0000) Subject: Fixed forward to classes X-Git-Tag: 5.7099_04~821 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=86d993abfe04d54984bca9c1c5a91139ec1eec42 Fixed forward to classes --- diff --git a/Changes b/Changes index 331abc5..f6b00b7 100644 --- 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. diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 58d3eb6..99aec69 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -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 ) = @_; diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index ac641a9..4ceea4c 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -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 = diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm index 594dfa3..8630a98 100644 --- a/t/lib/TestApp.pm +++ b/t/lib/TestApp.pm @@ -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 { } diff --git a/t/lib/TestApp/Controller/Action/Forward.pm b/t/lib/TestApp/Controller/Action/Forward.pm index f966898..c6be731 100644 --- a/t/lib/TestApp/Controller/Action/Forward.pm +++ b/t/lib/TestApp/Controller/Action/Forward.pm @@ -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; diff --git a/t/live_component_controller_action_forward.t b/t/live_component_controller_action_forward.t index 58d0ed4..5b23653 100644 --- a/t/live_component_controller_action_forward.t +++ b/t/live_component_controller_action_forward.t @@ -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' ); + } + }