From: Marcus Ramberg Date: Wed, 10 Aug 2005 13:07:34 +0000 (+0000) Subject: fix objects that evaulate to false. rafl X-Git-Tag: 5.7099_04~1252 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=a1c8f974699a855b480845bb0e0afb570f346e99 fix objects that evaulate to false. rafl --- diff --git a/Changes b/Changes index b6c0d39..3f9b5e3 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ This file documents the revision history for Perl extension Catalyst. +5.32 2005-xx-xx xx:xx:00 + - Dispatcher might fail if object returns false. + 5.31 2005-06-04 12:35:00 - helpers now create .new files where files already exist and differ diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 3c6404a..9fc441e 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -152,7 +152,7 @@ sub forward { unless ( @{$results} ) { - unless ( $c->components->{$command} ) { + unless ( defined( $c->components->{$command} ) ) { my $error = qq/Couldn't forward to command "$command". Invalid action or component./; $c->error($error); diff --git a/t/component/controller/action/forward.t b/t/component/controller/action/forward.t index 58355af..fe2bd3a 100644 --- a/t/component/controller/action/forward.t +++ b/t/component/controller/action/forward.t @@ -6,7 +6,7 @@ use warnings; use FindBin; use lib "$FindBin::Bin/../../../lib"; -use Test::More tests => 24; +use Test::More tests => 31; use Catalyst::Test 'TestApp'; @@ -41,6 +41,24 @@ use Catalyst::Test 'TestApp'; { my @expected = qw[ TestApp::Controller::Action::Forward->begin + TestApp::Controller::Action::Forward->six + TestApp::View::Dump::False->process + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/action/forward/six'), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), 'action/forward/six', 'Main Class Action' ); + is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Forward', 'Test Class' ); + is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); + like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' ); +} + +{ + my @expected = qw[ + TestApp::Controller::Action::Forward->begin TestApp::Controller::Action::Forward->jojo TestApp::Controller::Action::Forward->one TestApp::Controller::Action::Forward->two diff --git a/t/lib/TestApp/Controller/Action/Forward.pm b/t/lib/TestApp/Controller/Action/Forward.pm index 4fdf5ea..6a74ddd 100644 --- a/t/lib/TestApp/Controller/Action/Forward.pm +++ b/t/lib/TestApp/Controller/Action/Forward.pm @@ -28,6 +28,11 @@ sub five : Local { $c->forward('TestApp::View::Dump::Request'); } +sub six : Local { + my ( $self, $c ) = @_; + $c->forward('TestApp::View::Dump::False'); +} + sub jojo : Local { my ( $self, $c ) = @_;