X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flive_component_controller_action_default.t;h=e3c90fd4733fb8f1f13cc08c98c76aeb3fde3802;hb=f04fdedae056296d0fa97fbdcaa85b9811ca6a5b;hp=2e1d68b7c30e09fc8d6cd5d8a6ba9decc3e880d9;hpb=50cc3183118f1056427ab314b84b91fd0d9e1383;p=catagits%2FCatalyst-Runtime.git diff --git a/t/live_component_controller_action_default.t b/t/live_component_controller_action_default.t index 2e1d68b..e3c90fd 100644 --- a/t/live_component_controller_action_default.t +++ b/t/live_component_controller_action_default.t @@ -4,13 +4,13 @@ use strict; use warnings; use FindBin; -use lib "$FindBin::Bin/../../../lib"; +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 => 12*$iters; +use Test::More tests => 16 * $iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -29,7 +29,7 @@ sub run_tests { TestApp::Controller::Action::Default->begin TestApp::Controller::Action::Default->default TestApp::View::Dump::Request->process - TestApp->end + TestApp->end ]; my $expected = join( ", ", @expected ); @@ -53,16 +53,44 @@ sub run_tests { ); ok( $response = request('http://localhost/foo/bar/action'), 'Request' ); - is( $response->code, 404, 'Invalid URI returned 404' ); + is( $response->code, 500, 'Invalid URI returned 500' ); } - + # test that args are passed properly to default { my $creq; - my $expected = [ qw/action default arg1 arg2/ ]; - - ok( my $response = request('http://localhost/action/default/arg1/arg2'), 'Request' ); - ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' ); + my $expected = [qw/action default arg1 arg2/]; + + ok( my $response = request('http://localhost/action/default/arg1/arg2'), + 'Request' ); + ok( + eval '$creq = ' . $response->content, + 'Unserialize Catalyst::Request' + ); is_deeply( $creq->{arguments}, $expected, 'Arguments ok' ); } + + + # Test that /foo and /foo/ both do the same thing + { + my @expected = qw[ + TestApp::Controller::Action->begin + TestApp::Controller::Action->default + TestApp->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/action'), 'Request' ); + is( $response->header('X-Catalyst-Executed'), + $expected, + 'Executed actions for /action' + ); + + ok( $response = request('http://localhost/action/'), 'Request' ); + is( $response->header('X-Catalyst-Executed'), + $expected, + 'Executed actions for /action/' + ); + } }