X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flive_component_controller_action_go.t;h=b1088c9b4d213575c49ec5f7c6ba14ba1485d285;hb=f04fdedae056296d0fa97fbdcaa85b9811ca6a5b;hp=6f1f42ea859da6396ba27c7fffc93d3dfd77d1a9;hpb=be7ce1dcadffa68bbd99efb2366cfe1712dd678f;p=catagits%2FCatalyst-Runtime.git diff --git a/t/live_component_controller_action_go.t b/t/live_component_controller_action_go.t index 6f1f42e..b1088c9 100644 --- a/t/live_component_controller_action_go.t +++ b/t/live_component_controller_action_go.t @@ -10,7 +10,8 @@ our $iters; BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } -use Test::More tests => 50 * $iters; +use Test::More tests => 54 * $iters; +use Catalyst; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -25,6 +26,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 +49,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' ); @@ -93,7 +96,26 @@ sub run_tests { $expected, 'Executed actions' ); is( $response->content, $Catalyst::GO, "Go died as expected" ); } - + { + ok( + my $response = request('http://localhost/action/go/model'), + 'Request with args' + ); + is( $response->content, + q[FATAL ERROR: Couldn't go("Model::Foo"): Action cannot _DISPATCH. Did you try to go() a non-controller action?], + q[go('Model::...') test] + ); + } + { + ok( + my $response = request('http://localhost/action/go/view'), + 'Request with args' + ); + is( $response->content, + q[FATAL ERROR: Couldn't go("View::Dump"): Action cannot _DISPATCH. Did you try to go() a non-controller action?], + q[go('View::...') test] + ); + } { ok( my $response = @@ -101,7 +123,7 @@ sub run_tests { 'Request with args' ); ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content, 'old' ); + is( $response->content, 'old', 'go() with args (old)' ); } { @@ -111,7 +133,7 @@ sub run_tests { 'Request with args and method' ); ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content, 'new' ); + is( $response->content, 'new', 'go() with args (new)' ); } # test go with embedded args @@ -122,7 +144,7 @@ sub run_tests { 'Request' ); ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content, 'ok' ); + is( $response->content, 'ok', 'go() with args_embed_relative' ); } { @@ -132,7 +154,7 @@ sub run_tests { 'Request' ); ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content, 'ok' ); + is( $response->content, 'ok', 'go() with args_embed_absolute' ); } { my @expected = qw[ @@ -211,16 +233,18 @@ 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("TestApp"): Action has no namespace: cannot go() to a plain method or component, must be a :Action or some sort.), + 'Error message' + ); } {