From: Matt S Trout Date: Thu, 22 Jun 2006 14:51:49 +0000 (+0000) Subject: Added test for optional :Args when using :ChildOf X-Git-Tag: 5.7099_04~492 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=47f9968d8f98b55d7f1620ade066fcf52feeb42d Added test for optional :Args when using :ChildOf r10064@cain (orig r4395): phaylon | 2006-06-17 20:09:39 +0000 --- diff --git a/t/lib/TestApp/Controller/Action/ChildOf.pm b/t/lib/TestApp/Controller/Action/ChildOf.pm index 8370582..5f91d88 100644 --- a/t/lib/TestApp/Controller/Action/ChildOf.pm +++ b/t/lib/TestApp/Controller/Action/ChildOf.pm @@ -73,6 +73,11 @@ sub priority_b1 :PathPart('childof/priority_b') :ChildOf('/') :Args(3) { } sub priority_b2 :PathPart('childof/priority_b') :ChildOf('/') :Captures(1) { } sub priority_b2_end :PathPart('end') :ChildOf('priority_b2') :Args(1) { } +# +# Optional specification of :Args in endpoint +# +sub opt_args :PathPart('childof/opt_args') :ChildOf('/') { } + sub end :Private { my ($self, $c) = @_; my $out = join('; ', map { join(', ', @$_) } diff --git a/t/live_component_controller_action_childof.t b/t/live_component_controller_action_childof.t index 4c32a15..8ae78d2 100644 --- a/t/live_component_controller_action_childof.t +++ b/t/live_component_controller_action_childof.t @@ -10,7 +10,7 @@ our $iters; BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } -use Test::More tests => 57*$iters; +use Test::More tests => 60*$iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -405,4 +405,24 @@ sub run_tests { $expected, 'Executed actions' ); is( $response->content, '1; 2; 3', 'Content OK' ); } + + # + # The :Args attribute is optional, we check the action not specifying + # it with these tests. + # + { + my @expected = qw[ + TestApp::Controller::Action::ChildOf->begin + TestApp::Controller::Action::ChildOf->opt_args + TestApp::Controller::Action::ChildOf->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/childof/opt_args/1/2/3'), + 'Optional :Args attribute working' ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, '; 1, 2, 3', 'Content OK' ); + } }