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=cb4f0dc7979dd994c9cba656afc36867b6536c9d;hb=6365b5279cf3bbecd61735b3b744809983a7bfdc;hpb=4dca6c081be62b6542fda0a8098e8787dd5bcae2 diff --git a/t/live_component_controller_action_chained.t b/t/live_component_controller_action_chained.t index cb4f0dc..411542e 100644 --- a/t/live_component_controller_action_chained.t +++ b/t/live_component_controller_action_chained.t @@ -10,7 +10,7 @@ our $iters; BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } -use Test::More tests => 109*$iters; +use Test::More tests => 118*$iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -766,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' ); + } + }