File: abort-chain-2.t

package info (click to toggle)
libcatalyst-perl 5.90128-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,988 kB
  • sloc: perl: 10,908; makefile: 7
file content (49 lines) | stat: -rw-r--r-- 1,238 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use strict;
use warnings;
use Test::More tests => 1;
use HTTP::Request::Common;

BEGIN {
    package TestApp::Controller::Root;
    $INC{'TestApp/Controller/Root.pm'} = __FILE__;
    use Moose;
    use MooseX::MethodAttributes;
    extends 'Catalyst::Controller';

    has counter => (is => 'rw', isa => 'Int', default => sub { 0 });
    sub increment {
        my $self = shift;
        $self->counter($self->counter + 1);
    }
    sub root :Chained('/') :PathPart('') :CaptureArgs(0) {
        my ($self, $c, $arg) = @_;
        die "Died in root";
    }
    sub main :Chained('root') :PathPart('') :Args(0) {
        my ($self, $c, $arg) = @_;
        $self->increment;
        die "Died in main";
    }
    sub hits :Path('hits') :Args(0) {
        my ($self, $c, $arg) = @_;
        $c->response->body($self->counter);
    }
    __PACKAGE__->config(namespace => '');
}
{
    package TestApp;
    $INC{'TestApp.pm'} = __FILE__;
    use Catalyst;
    __PACKAGE__->config(abort_chain_on_error_fix => 1);
    __PACKAGE__->setup('-Log=fatal');
}

use Catalyst::Test 'TestApp';

{
    my $res = request('/');
}
{
    my $res = request('/hits');
    is $res->content, 0, "main action not touched on crash with explicit setting to true";
}