Fix warnings, we may not always be dumping a object
Tomas Doran [Sat, 6 Jun 2009 12:20:37 +0000 (12:20 +0000)]
t/lib/TestApp/View/Dump.pm

index c4c29db..a59e417 100644 (file)
@@ -43,13 +43,17 @@ sub process {
         $c->res->headers->content_type('text/plain');
         $c->res->output($output);
 
-        # Repair context
-        $reference->{_context} = $context;
-        weaken( $reference->{_context} );
-
-        # Repair body
-        delete $reference->{__body_type};
-        $reference->{_body} = $body;
+        if ($context) {
+            # Repair context
+            $reference->{_context} = $context;
+            weaken( $reference->{_context} );
+        }
+
+        if ($body) {
+            # Repair body
+            delete $reference->{__body_type};
+            $reference->{_body} = $body;
+        }
 
         return 1;
     }