add test for encoding in $c->res->body after a ->write
Gerda Shank [Thu, 28 May 2015 17:24:12 +0000 (13:24 -0400)]
t/utf_incoming.t

index 6342025..6c0205d 100644 (file)
@@ -111,6 +111,14 @@ use Scalar::Util ();
     $c->response->body($contents);
   }
 
+  sub write_then_body :Local {
+    my ($self, $c) = @_;
+    $c->clear_encoding;
+    $c->res->content_type('text/plain');
+    $c->res->write("<p>This is early_write action ♥</p>");
+    $c->res->body("<p>This is body_write action ♥</p>");
+  }
+
   sub file_upload :POST  Consumes(Multipart) Local {
     my ($self, $c) = @_;
     Test::More::is $c->req->body_parameters->{'♥'}, '♥♥';
@@ -365,6 +373,14 @@ use Catalyst::Test 'MyApp';
 }
 
 {
+  my $res = request "/root/write_then_body";
+
+  is $res->code, 200, 'OK';
+  is decode_utf8($res->content), "<p>This is early_write action ♥</p><p>This is body_write action ♥</p>";
+  is $res->content_charset, 'UTF-8';
+}
+
+{
   ok my $path = File::Spec->catfile('t', 'utf8.txt');
   ok my $req = POST '/root/file_upload',
     Content_Type => 'form-data',