fix objects that evaulate to false. rafl
Marcus Ramberg [Wed, 10 Aug 2005 13:07:34 +0000 (13:07 +0000)]
Changes
lib/Catalyst/Dispatcher.pm
t/component/controller/action/forward.t
t/lib/TestApp/Controller/Action/Forward.pm

diff --git a/Changes b/Changes
index b6c0d39..3f9b5e3 100644 (file)
--- 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
index 3c6404a..9fc441e 100644 (file)
@@ -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);
index 58355af..fe2bd3a 100644 (file)
@@ -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
index 4fdf5ea..6a74ddd 100644 (file)
@@ -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 ) = @_;