From: Florian Ragwitz Date: Sun, 1 Mar 2009 21:02:52 +0000 (+0000) Subject: Add failing test for passing arguments to visited chained actions. X-Git-Tag: 5.80001~68 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=626053191a3ba8c5f4ac8bd831009e962842c469 Add failing test for passing arguments to visited chained actions. Courtesy of Radoslaw Zielinski. --- diff --git a/t/aggregate/live_component_controller_action_visit.t b/t/aggregate/live_component_controller_action_visit.t index 96fe762..f5a373d 100644 --- a/t/aggregate/live_component_controller_action_visit.t +++ b/t/aggregate/live_component_controller_action_visit.t @@ -10,7 +10,7 @@ our $iters; BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } -use Test::More tests => 54 * $iters; +use Test::More tests => 60 * $iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -271,10 +271,13 @@ sub run_tests { my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/action/visit/visit_chained'), 'visit to chained + subcontroller endpoint' ); - is( $response->header('X-Catalyst-Executed'), - $expected, 'Executed actions' ); - is( $response->content, '; 1', 'Content OK' ); + for my $i ( 1..3 ) { + ok( my $response = request("http://localhost/action/visit/visit_chained/$i"), + "visit to chained + subcontroller endpoint for $i" ); + is( $response->header('X-Catalyst-Executed'), + $expected, "Executed actions for $i" ); + is( $response->content, "; $i", "Content OK for $i" ); + } } } diff --git a/t/lib/TestApp/Controller/Action/Chained.pm b/t/lib/TestApp/Controller/Action/Chained.pm index 6acc378..0efdcca 100644 --- a/t/lib/TestApp/Controller/Action/Chained.pm +++ b/t/lib/TestApp/Controller/Action/Chained.pm @@ -15,7 +15,11 @@ sub begin :Private { } # # Simple parent/child action test # -sub foo :PathPart('chained/foo') :CaptureArgs(1) :Chained('/') { } +sub foo :PathPart('chained/foo') :CaptureArgs(1) :Chained('/') { + my ( $self, $c, @args ) = @_; + die "missing argument" unless @args; + die "more than 1 argument" if @args > 1; +} sub endpoint :PathPart('end') :Chained('/action/chained/foo') :Args(1) { } # diff --git a/t/lib/TestApp/Controller/Action/Visit.pm b/t/lib/TestApp/Controller/Action/Visit.pm index 3011a75..0447d34 100644 --- a/t/lib/TestApp/Controller/Action/Visit.pm +++ b/t/lib/TestApp/Controller/Action/Visit.pm @@ -62,7 +62,9 @@ sub visit_die : Local { sub visit_chained : Local { my ( $self, $c, $val ) = @_; - $c->visit('/action/chained/foo/spoon',[1]); + $val eq 1 ? $c->visit( '/action/chained/foo/spoon', [$val] ) + : $val eq 2 ? $c->visit( qw/ Action::Chained::Foo spoon /, [$val] ) + : $c->visit( $c->controller('Action::Chained::Foo')->action_for('spoon'), [$val] ) } sub view : Local {