update tests for newer catalyst where UTF8 is default
John Napiorkowski [Mon, 29 Dec 2014 17:57:58 +0000 (11:57 -0600)]
Changes
lib/Catalyst/View/TT.pm
t/14alt_content_type.t

diff --git a/Changes b/Changes
index 3fcb57c..e096a60 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension Catalyst::View::TT.
 
+0.42   2014-12-29
+        - Fixes to test cases to be compatible with Catalyst v5.90080
+
 0.41   2013-02-28
         - New local attribute to let you override the default content type when
           no content type has been set for the response.
index 3f54afd..39725f9 100644 (file)
@@ -10,7 +10,7 @@ use Template::Timer;
 use MRO::Compat;
 use Scalar::Util qw/blessed weaken/;
 
-our $VERSION = '0.41';
+our $VERSION = '0.42';
 $VERSION = eval $VERSION;
 
 __PACKAGE__->mk_accessors('template');
@@ -230,7 +230,7 @@ sub process {
     }
 
     unless ( $c->response->content_type ) {
-        my $default = $self->content_type || 'text/html; charset=utf-8';
+        my $default = $self->content_type || 'text/html; charset=UTF-8';
         $c->response->content_type($default);
     }
 
@@ -455,6 +455,10 @@ to search. See L<CAPTURING TEMPLATE OUTPUT> for an example showing this.
 
 =head2 Unicode
 
+B<NOTE> Starting with L<Catalyst> v5.90080 unicode and encoding has been
+baked into core, and the default encoding is UTF-8.  The following advice
+is for older versions of L<Catalyst>
+
 Be sure to set C<< ENCODING => 'utf-8' >> and use
 L<Catalyst::Plugin::Unicode::Encoding> if you want to use non-ascii
 characters (encoded as utf-8) in your templates.
index bed2f0f..01caea8 100644 (file)
@@ -6,6 +6,11 @@ use FindBin;
 use lib "$FindBin::Bin/lib";
 
 use_ok('Catalyst::Test', 'TestApp');
-is(request("/test_alt_content_type")->header('Content-Type'), 'text/plain');
 
+# Hack to support Catalyst v5.90080+ (JNAP)
+if(TestApp->can('encoding') and (my $enc = TestApp->encoding) and TestApp->can('clear_encoding')) {
+  is(request("/test_alt_content_type")->header('Content-Type'), "text/plain; charset=${\$enc->mime_name}", "Plain text with ${\$enc->mime_name}");
+} else {
+  is(request("/test_alt_content_type")->header('Content-Type'), 'text/plain', 'Plain Text');
+}
 done_testing;