X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Flive_component_controller_action_chained.t;h=411542ec58bc80fb0f521db1fe42bd020e68f446;hp=523821d58dcc9e9f8a41e1c6c2d0c619764896a9;hb=6365b5279cf3bbecd61735b3b744809983a7bfdc;hpb=10ae2631516d23f105f7879aabe54a5033ea629a diff --git a/t/live_component_controller_action_chained.t b/t/live_component_controller_action_chained.t index 523821d..411542e 100644 --- a/t/live_component_controller_action_chained.t +++ b/t/live_component_controller_action_chained.t @@ -8,9 +8,9 @@ use lib "$FindBin::Bin/lib"; our $iters; -BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } +BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } -use Test::More tests => 106*$iters; +use Test::More tests => 118*$iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -729,6 +729,24 @@ sub run_tests { } # + # Test chained actions in the root controller + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained::Root->rootsub + TestApp::Controller::Action::Chained::Root->endpointsub + TestApp->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/rootsub/1/endpointsub/2'), 'chained in root namespace' ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, '', 'Content OK' ); + } + + # # Complex path with multiple empty pathparts # { @@ -748,4 +766,66 @@ sub run_tests { is( $response->content, '; ', 'Content OK' ); } + # + # Higher Args() hiding more specific CaptureArgs chains sections + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->cc_base + TestApp::Controller::Action::Chained->cc_link + TestApp::Controller::Action::Chained->cc_anchor + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join ', ', @expected; + + ok( my $response = request('http://localhost/chained/choose_capture/anchor.html'), + 'Choose between an early Args() and a later more ideal chain' ); + is( $response->header('X-Catalyst-Executed') => $expected, 'Executed actions'); + is( $response->content => '; ', 'Content OK' ); + } + + # + # Less specific chain not being seen correctly due to earlier looser capture + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->cc_base + TestApp::Controller::Action::Chained->cc_b + TestApp::Controller::Action::Chained->cc_b_link + TestApp::Controller::Action::Chained->cc_b_anchor + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join ', ', @expected; + + ok( my $response = request('http://localhost/chained/choose_capture/b/a/anchor.html'), + 'Choose between a more specific chain and an earlier looser one' ); + is( $response->header('X-Catalyst-Executed') => $expected, 'Executed actions'); + is( $response->content => 'a; ', 'Content OK' ); + } + + # + # Check we get the looser one when it's the correct match + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->cc_base + TestApp::Controller::Action::Chained->cc_a + TestApp::Controller::Action::Chained->cc_a_link + TestApp::Controller::Action::Chained->cc_a_anchor + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join ', ', @expected; + + ok( my $response = request('http://localhost/chained/choose_capture/a/a/anchor.html'), + 'Choose between a more specific chain and an earlier looser one' ); + is( $response->header('X-Catalyst-Executed') => $expected, 'Executed actions'); + is( $response->content => 'a; anchor.html', 'Content OK' ); + } + }