# This file documents the revision history for Perl extension Catalyst.
+ - Throw an exception rather than loading an app if an action
+ tries to chain to itself (t0m)
+ - Tests for this
- Added Catalyst::Test::ctx_request to be able to inspect
the context object after a request is made (Jos Boumans)
- debug() POD rewrite (jhannah)
"Multiple Chained attributes not supported registering ${action}"
);
}
+ my $chained_to = $chained_attr[0];
- my $children = ($self->_children_of->{ $chained_attr[0] } ||= {});
+ Catalyst::Exception->throw(
+ "Actions cannot chain to themselves registering /${action}"
+ ) if ($chained_to eq '/' . $action);
+
+ my $children = ($self->_children_of->{ $chained_to } ||= {});
my @path_part = @{ $action->attributes->{PathPart} || [] };
use Catalyst::Test 'TestApp';
-eval q{
+eval q{
package TestApp::Controller::Action::Chained;
sub should_fail : Chained('/') Chained('foo') Args(0) {}
};
ok(!$@);
-eval { TestApp->setup_actions; };
+eval { TestApp->setup_actions; };
ok($@, 'Multiple chained attributes make action setup fail');
-eval q{
+eval q{
package TestApp::Controller::Action::Chained;
no warnings 'redefine';
sub should_fail {}
--- /dev/null
+#!perl
+
+use strict;
+use warnings;
+use lib 't/lib';
+
+use Test::More tests => 6;
+
+use Catalyst::Test 'TestApp';
+
+eval q{
+ package TestApp::Controller::Action::Chained;
+ sub should_fail : Chained('should_fail') Args(0) {}
+};
+ok(!$@);
+
+eval { TestApp->setup_actions; };
+like($@, qr|Actions cannot chain to themselves registering /action/chained/should_fail|,
+ 'Local self referencing attributes makes action setup fail');
+
+eval q{
+ package TestApp::Controller::Action::Chained;
+ no warnings 'redefine';
+ sub should_fail {}
+ use warnings 'redefine';
+ sub should_also_fail : Chained('/action/chained/should_also_fail') Args(0) {}
+};
+ok(!$@);
+
+eval { TestApp->setup_actions };
+like($@, qr|Actions cannot chain to themselves registering /action/chained/should_also_fail|,
+ 'Full path self referencing attributes makes action setup fail');
+
+eval q{
+ package TestApp::Controller::Action::Chained;
+ no warnings 'redefine';
+ sub should_also_fail {}
+};
+ok(!$@);
+
+eval { TestApp->setup_actions };
+ok(!$@, 'And ok again') or warn $@;
+
$c->forward('TestApp::View::Dump::Request');
}
-sub chain_to_self : Chained('chain_to_self') PathPart('') CaptureArgs(1) { }
-
-sub chain_recurse_endoint : Chained('chain_to_self') Args(0) { }
-
1;
+++ /dev/null
-#!perl
-
-use strict;
-use warnings;
-
-use FindBin;
-use lib "$FindBin::Bin/lib";
-
-use Test::More tests => 3;
-
-
-use TestApp;
-
-my $dispatch_type = TestApp->dispatcher->dispatch_type('Chained');
-isa_ok($dispatch_type, "Catalyst::DispatchType::Chained", "got dispatch type");
-
-# This test was failing due to recursion/OOM. set up an alarm so things dont
-# runaway
-local $SIG{ALRM} = sub {
- ok(0, "Chained->list didn't loop");
- die "alarm expired - test probably looping";
-};
-alarm 10;
-
-$dispatch_type->list("TestApp");
-ok(1, "Chained->list didn't loop");