Bug fix for debug mode from RT#53338
Tomas Doran [Mon, 4 Jan 2010 13:13:18 +0000 (13:13 +0000)]
Changes
Makefile.PL
lib/Catalyst/Plugin/Static/Simple.pm
t/20debug.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index fb1a150..af1e471 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
 Revision history for Perl extension Catalyst::Plugin::Static::Simple
 
+        - Fix issues in debug mode. (RT#53338)
+
 0.27   2010-01-03 14:49:00
         - Switch to being a Moose role, removing dependencies on
           Class::Data::Inheritable and Class::Accessor (Andrey Kostenko in
index 5472fbb..57096f1 100644 (file)
@@ -11,6 +11,7 @@ requires 'Catalyst::Runtime' => '5.80008';
 requires 'MIME::Types' => '1.25';
 requires 'Test::More';
 requires 'Moose';
+requires 'MooseX::Types';
 requires 'namespace::autoclean';
 
 test_requires 'Test::More';
index c7708e6..90e9cc1 100644 (file)
@@ -5,12 +5,13 @@ use File::stat;
 use File::Spec ();
 use IO::File ();
 use MIME::Types ();
+use MooseX::Types::Moose qw/ArrayRef Str/;
 use namespace::autoclean;
 
 our $VERSION = '0.27';
 
 has _static_file => ( is => 'rw' );
-has _static_debug_message => ( is => 'rw', isa => 'Str' );
+has _static_debug_message => ( is => 'rw', isa => ArrayRef[Str] );
 
 before prepare_action => sub {
     my $c = shift;
diff --git a/t/20debug.t b/t/20debug.t
new file mode 100644 (file)
index 0000000..e934dee
--- /dev/null
@@ -0,0 +1,38 @@
+#!perl\r
+\r
+use strict;\r
+use warnings;\r
+\r
+use FindBin;\r
+use lib "$FindBin::Bin/lib";\r
+\r
+use Test::More tests => 5;\r
+use Catalyst::Test 'TestApp';\r
+\r
+# test defined static dirs\r
+TestApp->config->{static}->{dirs} = [\r
+    'always-static',\r
+];\r
+\r
+TestApp->config->{static}->{debug} = 1;\r
+\r
+use Catalyst::Log;\r
+\r
+local *Catalyst::Log::_send_to_log;\r
+local our @MESSAGES;\r
+{\r
+    no warnings 'redefine';\r
+    *Catalyst::Log::_send_to_log = sub {\r
+        my $self = shift;\r
+        push @MESSAGES, @_;\r
+    };\r
+}\r
+\r
+\r
+# a missing file in a defined static dir will return 404 and text/html\r
+ok( my $res = request('http://localhost/always-static/404.txt'), 'request ok' );\r
+is( $res->code, 404, '404 ok' );\r
+is( $res->content_type, 'text/html', '404 is text/html' );\r
+ok(defined $MESSAGES[0], 'debug message set');\r
+like( $MESSAGES[0], qr/404/, 'debug message contains 404'); \r
+\r