From: Brian Cassidy Date: Fri, 8 Aug 2008 14:08:12 +0000 (+0000) Subject: go() cannot dispatch to anon. actions, fix code and tests to match. X-Git-Tag: 5.7099_04~30 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=2034b8c345e4ff560ca0b568f343a3ec5aa6417f go() cannot dispatch to anon. actions, fix code and tests to match. --- diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 96364e6..262301a 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -176,7 +176,7 @@ sub go { my ( $c, $command ) = @_; my ( $action, $args ) = $self->_command2action(@_); - unless ($action) { + unless ($action && defined $action->namespace) { my $error = qq/Couldn't go to command "$command": / . qq/Invalid action or component./; diff --git a/t/live_component_controller_action_go.t b/t/live_component_controller_action_go.t index 6f1f42e..544166d 100644 --- a/t/live_component_controller_action_go.t +++ b/t/live_component_controller_action_go.t @@ -25,6 +25,16 @@ else { sub run_tests { { + # Test go to global private action + ok( my $response = request('http://localhost/action/go/global'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'action/go/global', 'Main Class Action' ); + } + + { my @expected = qw[ TestApp::Controller::Action::Go->one TestApp::Controller::Action::Go->two @@ -38,16 +48,8 @@ sub run_tests { @expected = map { /Action/ ? (_begin($_), $_) : ($_) } @expected; my $expected = join( ", ", @expected ); - # Test go to global private action - ok( my $response = request('http://localhost/action/go/global'), - 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content_type, 'text/plain', 'Response Content-Type' ); - is( $response->header('X-Catalyst-Action'), - 'action/go/global', 'Main Class Action' ); - # Test go to chain of actions. - ok( $response = request('http://localhost/action/go/one'), + ok( my $response = request('http://localhost/action/go/one'), 'Request' ); ok( $response->is_success, 'Response Successful 2xx' ); is( $response->content_type, 'text/plain', 'Response Content-Type' ); @@ -211,16 +213,15 @@ sub run_tests { ); } - # test class go + # test class go -- MUST FAIL! { ok( my $response = request( 'http://localhost/action/go/class_go_test_action'), 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->header('X-Class-Go-Test-Method'), 1, - 'Test Method' ); + ok( !$response->is_success, 'Response Fails' ); + is( $response->content, q(FATAL ERROR: Couldn't go to command "TestApp": Invalid action or component.), 'Error message' ); } {