Add a test to make sure that a die in a Controller's end sub is propogated as a 500...
Dave Rolsky [Tue, 3 May 2011 16:28:42 +0000 (11:28 -0500)]
t/aggregate/live_component_controller_action_die_in_end.t [new file with mode: 0644]
t/lib/TestApp/Controller/Action/DieInEnd.pm [new file with mode: 0644]

diff --git a/t/aggregate/live_component_controller_action_die_in_end.t b/t/aggregate/live_component_controller_action_die_in_end.t
new file mode 100644 (file)
index 0000000..b43aafe
--- /dev/null
@@ -0,0 +1,29 @@
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+our $iters;
+
+BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
+
+use Test::More tests => 2*$iters;
+use Catalyst::Test 'TestApp';
+
+if ( $ENV{CAT_BENCHMARK} ) {
+    require Benchmark;
+    Benchmark::timethis( $iters, \&run_tests );
+}
+else {
+    for ( 1 .. $iters ) {
+        run_tests();
+    }
+}
+
+sub run_tests {
+    ok( my $response = request('http://localhost/action/die_in_end'), 'Request' );
+    ok( !$response->is_success, 'generates a 500 error' );
+}
diff --git a/t/lib/TestApp/Controller/Action/DieInEnd.pm b/t/lib/TestApp/Controller/Action/DieInEnd.pm
new file mode 100644 (file)
index 0000000..61f4b2c
--- /dev/null
@@ -0,0 +1,16 @@
+package TestApp::Controller::Action::DieInEnd;
+
+use strict;
+use base 'TestApp::Controller::Action';
+
+sub end : Private {
+    my ( $self, $c ) = @_;
+    die "I'm ending with death";
+}
+
+sub default : Private {
+    my ( $self, $c ) = @_;
+    $c->forward('TestApp::View::Dump::Request');
+}
+
+1;