include test for failure mode
[catagits/Catalyst-Runtime.git] / t / unit_dispatcher_requestargs_restore.t
CommitLineData
12f0342e 1# Insane test case for the behavior needed by Plugin::Auhorization::ACL
2
3# We have to localise $c->request->{arguments} in
4# Catalyst::Dispatcher::_do_forward, rather than using save and restore,
5# as otherwise, the calling $c->detach on an action which says
6# die $Catalyst:DETACH causes the request arguments to not get restored,
7# and therefore sub gorch gets the wrong string $frozjob parameter.
8
9# Please feel free to break this behavior once a sane hook for safely
10# executing another action from the dispatcher (i.e. wrapping actions)
11# is present, so that the Authorization::ACL plugin can be re-written
12# to not be full of such crazy shit.
13{
14 package ACLTestApp;
15 use Test::More;
16
17 use strict;
18 use warnings;
19 use MRO::Compat;
20 use Scalar::Util ();
21
22 use base qw/Catalyst Catalyst::Controller/;
23 use Catalyst qw//;
24
25 sub execute {
26 my $c = shift;
27 my ( $class, $action ) = @_;
28
29 if ( Scalar::Util::blessed($action)
30 and $action->name ne "foobar" ) {
31 eval { $c->detach( 'foobar', [$action, 'foo'] ) };
32 }
33
34 $c->next::method( @_ );
35 }
36
37 sub foobar : Private {
38 die $Catalyst::DETACH;
39 }
40
41 sub gorch : Local {
42 my ( $self, $c, $frozjob ) = @_;
43 is $frozjob, 'wozzle';
44 $c->res->body("gorch");
45 }
46
47 __PACKAGE__->setup;
48}
49
50use strict;
51use warnings;
52use FindBin qw/$Bin/;
53use lib "$Bin/lib";
54use Catalyst::Test 'ACLTestApp';
55use Test::More tests => 1;
56
57request('http://localhost/gorch/wozzle');