With debug enabled in C::P::Static::Simple v0.27, the following error occurs:
Caught exception in engine "Attribute (_static_debug_message) does not pass the type constraint because: Validation failed for 'Str' failed with value ARRAY(0x62c5c90) at
../support/lib/perl5/Catalyst/Plugin/Static/Simple.pm line 245
I think it's because the _static_debug_message attribute is defined as a Str, not an ArrayRef[Str]. I've attached a patch, with a test that now passes.
Caught exception in engine "Attribute (_static_debug_message) does not pass the type constraint because: Validation failed for 'Str' failed with value ARRAY(0x62c5c90) at
../support/lib/perl5/Catalyst/Plugin/Static/Simple.pm line 245
I think it's because the _static_debug_message attribute is defined as a Str, not an ArrayRef[Str]. I've attached a patch, with a test that now passes.
Subject: | debug-handling.patch |
Index: t/20debug.t
===================================================================
--- t/20debug.t (revision 0)
+++ t/20debug.t (revision 0)
@@ -0,0 +1,38 @@
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More tests => 5;
+use Catalyst::Test 'TestApp';
+
+# test defined static dirs
+TestApp->config->{static}->{dirs} = [
+ 'always-static',
+];
+
+TestApp->config->{static}->{debug} = 1;
+
+use Catalyst::Log;
+
+local *Catalyst::Log::_send_to_log;
+local our @MESSAGES;
+{
+ no warnings 'redefine';
+ *Catalyst::Log::_send_to_log = sub {
+ my $self = shift;
+ push @MESSAGES, @_;
+ };
+}
+
+
+# a missing file in a defined static dir will return 404 and text/html
+ok( my $res = request('http://localhost/always-static/404.txt'), 'request ok' );
+is( $res->code, 404, '404 ok' );
+is( $res->content_type, 'text/html', '404 is text/html' );
+ok(defined $MESSAGES[0], 'debug message set');
+like( $MESSAGES[0], qr/404/, 'debug message contains 404');
+
Index: lib/Catalyst/Plugin/Static/Simple.pm
===================================================================
--- lib/Catalyst/Plugin/Static/Simple.pm (revision 12517)
+++ lib/Catalyst/Plugin/Static/Simple.pm (working copy)
@@ -10,7 +10,7 @@
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;