X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flive_component_controller_action_go.t;h=544166d4795b957d52a10c0ca065b1a2849f281b;hb=d09eb4339b4d37a6bb51f837d0ea02f3c26f4486;hp=ac0112de065c390939068c58c50690f16ea65be1;hpb=9bfaf006d5c1cde4938a32e97e1cc58f1c5befa4;p=catagits%2FCatalyst-Runtime.git diff --git a/t/live_component_controller_action_go.t b/t/live_component_controller_action_go.t index ac0112d..544166d 100644 --- a/t/live_component_controller_action_go.t +++ b/t/live_component_controller_action_go.t @@ -10,7 +10,7 @@ our $iters; BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } -use Test::More tests => 47 * $iters; +use Test::More tests => 50 * $iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -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,20 +213,39 @@ 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' ); + } + + { + my @expected = qw[ + TestApp::Controller::Action::Go->begin + TestApp::Controller::Action::Go->go_chained + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->foo + TestApp::Controller::Action::Chained::Foo->spoon + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/action/go/go_chained'), 'go to chained + subcontroller endpoint' ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, '; 1', 'Content OK' ); } } + + sub _begin { local $_ = shift; s/->(.*)$/->begin/;