Added an extra test that dies in the middle of a chain
Mark Ellis [Mon, 27 Jan 2014 21:41:20 +0000 (21:41 +0000)]
t/aggregate/live_component_controller_action_chained.t
t/lib/TestApp/Controller/Action/Chained.pm

index 99ea3c7..f0cbc6a 100644 (file)
@@ -776,6 +776,25 @@ sub run_tests {
     {
         my @expected = qw[
           TestApp::Controller::Action::Chained->begin
+          TestApp::Controller::Action::Chained->chain_error_a
+          TestApp::Controller::Action::Chained->end
+        ];
+
+        my $expected = join( ", ", @expected );
+
+        ok( my $response = request('http://localhost/chained/chain_error/1/end/2'),
+            "Break a chain in the middle" );
+        is( $response->header('X-Catalyst-Executed'),
+            $expected, 'Executed actions' );
+        is( $response->content, 'FATAL ERROR: break in the middle of a chain', 'Content OK' );
+    }
+
+    #
+    # Test dieing in the middle of a chain.
+    #
+    {
+        my @expected = qw[
+          TestApp::Controller::Action::Chained->begin
           TestApp::Controller::Action::Chained->chain_die_a
           TestApp::Controller::Action::Chained->end
         ];
@@ -786,7 +805,7 @@ sub run_tests {
             "Break a chain in the middle" );
         is( $response->header('X-Catalyst-Executed'),
             $expected, 'Executed actions' );
-        is( $response->content, 'FATAL ERROR: break in the middle of a chain', 'Content OK' );
+        is( $response->content, 'FATAL ERROR: Caught exception in TestApp::Controller::Action::Chained->chain_die_a "die in the middle of a chain"', 'Content OK' );
     }
 
     #
index 2af1ec6..4c02130 100644 (file)
@@ -143,10 +143,19 @@ sub chain_dt_a :Chained :PathPart('chained/chain_dt') :CaptureArgs(1) {
 sub chain_dt_b :Chained('chain_dt_a') :PathPart('end') :Args(1) { }
 
 #
+#   Error in the middle of a chain
+#
+sub chain_error_a :Chained :PathPart('chained/chain_error') :CaptureArgs(1) {
+    $_[1]->error( 'break in the middle of a chain' );
+}
+
+sub chain_error_b :Chained('chain_error_a') :PathPart('end') :Args(1) {}
+
+#
 #   Die in the middle of a chain
 #
 sub chain_die_a :Chained :PathPart('chained/chain_die') :CaptureArgs(1) {
-    $_[1]->error( 'break in the middle of a chain' );
+    die( "die in the middle of a chain\n" );
 }
 
 sub chain_die_b :Chained('chain_die_a') :PathPart('end') :Args(1) {}