Skip Menu |

This queue is for tickets about the Catalyst-Runtime CPAN distribution.

Report information
The Basics
Id: 43752
Status: resolved
Priority: 0/
Queue: Catalyst-Runtime

People
Owner: Nobody in particular
Requestors: RADEK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 5.71000
Fixed in: 5.71001



Subject: $c->visit does not pass @args to chained actions correctly
/some/action is chained to /some/foo, and /some/foo has CaptureArgs(1). These two do not pass the args to /some/foo: $c->visit( '/some/action', [ 1..3 ] ); $c->visit( $c->controller('Some')->action_for('foo'), [ 1..3 ] ); This will not call Some::foo() at all: $c->visit( qw/ Some foo /, [ 1..3 ] ); Patch for the test suite attached; causes failures of test 54 in t/live_component_controller_action_go and 54, 56, 60 in t/live_component_controller_action_visit.
Subject: catalyst-visit-tests.patch
diff -ur Catalyst-Runtime-5.71000/t/lib/TestApp/Controller/Action/Chained.pm Catalyst-Runtime-5.71000.x/t/lib/TestApp/Controller/Action/Chained.pm --- Catalyst-Runtime-5.71000/t/lib/TestApp/Controller/Action/Chained.pm 2008-09-09 01:24:34.000000000 +0200 +++ Catalyst-Runtime-5.71000.x/t/lib/TestApp/Controller/Action/Chained.pm 2009-03-01 20:28:30.451472683 +0100 @@ -15,7 +15,11 @@ # # 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 -ur Catalyst-Runtime-5.71000/t/lib/TestApp/Controller/Action/Visit.pm Catalyst-Runtime-5.71000.x/t/lib/TestApp/Controller/Action/Visit.pm --- Catalyst-Runtime-5.71000/t/lib/TestApp/Controller/Action/Visit.pm 2009-01-11 23:16:26.000000000 +0100 +++ Catalyst-Runtime-5.71000.x/t/lib/TestApp/Controller/Action/Visit.pm 2009-03-01 20:11:05.678026236 +0100 @@ -62,7 +62,9 @@ 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 { diff -ur Catalyst-Runtime-5.71000/t/live_component_controller_action_visit.t Catalyst-Runtime-5.71000.x/t/live_component_controller_action_visit.t --- Catalyst-Runtime-5.71000/t/live_component_controller_action_visit.t 2009-01-12 16:42:03.000000000 +0100 +++ Catalyst-Runtime-5.71000.x/t/live_component_controller_action_visit.t 2009-03-01 20:12:37.708595341 +0100 @@ -10,7 +10,7 @@ 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 @@ 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" ); + } } }
Patch for 5.8000_06.
diff -ur Catalyst-Runtime-5.8000_06/t/aggregate/live_component_controller_action_visit.t Catalyst-Runtime-5.8000_06.x/t/aggregate/live_component_controller_action_visit.t --- Catalyst-Runtime-5.8000_06/t/aggregate/live_component_controller_action_visit.t 2008-10-14 22:33:13.000000000 +0200 +++ Catalyst-Runtime-5.8000_06.x/t/aggregate/live_component_controller_action_visit.t 2009-03-01 21:20:48.370932069 +0100 @@ -10,7 +10,7 @@ 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 @@ 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 -ur Catalyst-Runtime-5.8000_06/t/lib/TestApp/Controller/Action/Chained.pm Catalyst-Runtime-5.8000_06.x/t/lib/TestApp/Controller/Action/Chained.pm --- Catalyst-Runtime-5.8000_06/t/lib/TestApp/Controller/Action/Chained.pm 2008-11-14 17:16:07.000000000 +0100 +++ Catalyst-Runtime-5.8000_06.x/t/lib/TestApp/Controller/Action/Chained.pm 2009-03-01 21:20:12.260935759 +0100 @@ -15,7 +15,11 @@ # # 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 -ur Catalyst-Runtime-5.8000_06/t/lib/TestApp/Controller/Action/Visit.pm Catalyst-Runtime-5.8000_06.x/t/lib/TestApp/Controller/Action/Visit.pm --- Catalyst-Runtime-5.8000_06/t/lib/TestApp/Controller/Action/Visit.pm 2008-10-14 22:33:12.000000000 +0200 +++ Catalyst-Runtime-5.8000_06.x/t/lib/TestApp/Controller/Action/Visit.pm 2009-03-01 21:20:12.260935759 +0100 @@ -62,7 +62,9 @@ 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 {