X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Faggregate%2Flive_component_controller_action_chained.t;h=b0be89828e944cb53da1ac167b450cbf127c51a8;hb=2689f8a4d4914dc316857f50eea2cf03788b7030;hp=f315984bfb43cb6d429f35bcba2ead01f62a28f5;hpb=857c821af199982eac42097d3e385edc913e217c;p=catagits%2FCatalyst-Runtime.git diff --git a/t/aggregate/live_component_controller_action_chained.t b/t/aggregate/live_component_controller_action_chained.t index f315984..b0be898 100644 --- a/t/aggregate/live_component_controller_action_chained.t +++ b/t/aggregate/live_component_controller_action_chained.t @@ -10,7 +10,7 @@ our $iters; BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } -use Test::More tests => 143*$iters; +use Test::More; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -815,7 +815,7 @@ sub run_tests { my @expected = qw[ TestApp::Controller::Action::Chained::Root->rootsub TestApp::Controller::Action::Chained::Root->endpointsub - TestApp->end + TestApp::Controller::Root->end ]; my $expected = join( ", ", @expected ); @@ -908,6 +908,51 @@ sub run_tests { is( $response->content => 'a; anchor.html', 'Content OK' ); } + # CaptureArgs(1) PathPart('...') should win over CaptureArgs(2) PathPart('') + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained::CaptureArgs->base + TestApp::Controller::Action::Chained::CaptureArgs->one_arg + TestApp::Controller::Action::Chained::CaptureArgs->edit_one_arg + TestApp::Controller::Action::Chained::CaptureArgs->end + ]; + + my $expected = join( ", ", @expected ); + + # should dispatch to /base/one_args/edit_one_arg + ok( my $response = request('http://localhost/captureargs/one/edit'), + 'Correct arg order ran' ); + TODO: { + local $TODO = 'Known bug'; + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, 'base; one_arg; edit_one_arg', 'Content OK' ); + } + } + + # PathPart('...') Args(1) should win over CaptureArgs(2) PathPart('') + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained::CaptureArgs->base + TestApp::Controller::Action::Chained::CaptureArgs->test_one_arg + TestApp::Controller::Action::Chained::CaptureArgs->end + ]; + + my $expected = join( ", ", @expected ); + + # should dispatch to /base/test_one_arg + ok( my $response = request('http://localhost/captureargs/test/one'), + 'Correct pathpart/arg ran' ); + TODO: { + local $TODO = 'Known bug'; + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, 'base; test_plus_arg; one;', 'Content OK' ); + } + } + # # Args(0) should win over Args() if we actually have no arguments. { @@ -987,8 +1032,6 @@ sub run_tests { # doc/* # # request for doc/search should end up in doc/* -TODO: { - local $TODO = 'gbjk never got off his ass and fixed this'; { my @expected = qw[ TestApp::Controller::Action::Chained->begin @@ -1000,8 +1043,52 @@ TODO: { ok( my $response = request('http://localhost/chained/doc/search'), "we prefer static path parts earlier in the chain" ); - is( $response->header('X-Catalyst-Executed'), - $expected, 'Executed actions' ); + TODO: { + local $TODO = 'gbjk never got off his ass and fixed this'; + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + } + } + + { + ok( my $content = + get('http://localhost/chained/capture%2Farg%3B/return_arg/foo%2Fbar%3B'), + 'request with URI-encoded arg' ); + like( $content, qr{foo/bar;\z}, 'args decoded' ); + like( $content, qr{capture/arg;}, 'captureargs decoded' ); + } + { + ok( my $content = + get('http://localhost/chained/return_arg_decoded/foo%2Fbar%3B'), + 'request with URI-encoded arg' ); + like( $content, qr{foo/bar;\z}, 'args decoded' ); + } + + # Test round tripping, specifically the / character %2F in uri_for: + # not being able to feed it back action + captureargs and args into uri for + # and result in the original request uri is a major piece of suck ;) + foreach my $thing ( + ['foo', 'bar'], + ['foo%2Fbar', 'baz'], + ['foo', 'bar%2Fbaz'], + ['foo%2Fbar', 'baz%2Fquux'], + ['foo%2Fbar', 'baz%2Fquux', { foo => 'bar', 'baz' => 'quux%2Ffrood'}], + ['foo%2Fbar', 'baz%2Fquux', { foo => 'bar', 'baz%2Ffnoo' => 'quux%2Ffrood'}], + ) { + my $path = '/chained/roundtrip_urifor/' . + $thing->[0] . '/' . $thing->[1]; + $path .= '?' . join('&', + map { $_ .'='. $thing->[2]->{$_}} + sort keys %{$thing->[2]}) if $thing->[2]; + ok( my $content = + get('http://localhost/' . $path), + 'request ' . $path . ' ok'); + # Just check that the path matches, as who the hell knows or cares + # where the app is based (live tests etc) + ok( index($content, $path) > 1, 'uri can round trip through uri_for' ) + or diag("Expected $path, got $content"); } -}; } + +done_testing; +