979249c9f440366cede4686c3e3cf404d7d4b498
[catagits/Catalyst-Runtime.git] / t / abort-chain-3.t
1 use strict;
2 use warnings;
3 use Test::More tests => 1;
4 use HTTP::Request::Common;
5
6 BEGIN {
7     package TestApp::Controller::Root;
8     $INC{'TestApp/Controller/Root.pm'} = __FILE__;
9     use Moose;
10     use MooseX::MethodAttributes;
11     extends 'Catalyst::Controller';
12
13     has counter => (is => 'rw', isa => 'Int', default => sub { 0 });
14     sub increment {
15         my $self = shift;
16         $self->counter($self->counter + 1);
17     }
18     sub root :Chained('/') :PathPart('') :CaptureArgs(0) {
19         my ($self, $c, $arg) = @_;
20         die "Died in root";
21     }
22     sub main :Chained('root') :PathPart('') :Args(0) {
23         my ($self, $c, $arg) = @_;
24         $self->increment;
25         die "Died in main";
26     }
27     sub hits :Path('hits') :Args(0) {
28         my ($self, $c, $arg) = @_;
29         $c->response->body($self->counter);
30     }
31     __PACKAGE__->config(namespace => '');
32 }
33 {
34     package TestApp;
35     $INC{'TestApp.pm'} = __FILE__;
36     use Catalyst;
37     __PACKAGE__->config(abort_chain_on_error_fix => 0);
38     __PACKAGE__->setup;
39 }
40
41 use Catalyst::Test 'TestApp';
42
43 {
44     my $res = request('/');
45 }
46 {
47     my $res = request('/hits');
48     is $res->content, 1, "main action performed on crash with explicit setting to false";
49 }