Static::Simple 0.20, fixed static dirs regex and added content-type text/html to...
[catagits/Catalyst-Plugin-Static-Simple.git] / t / 05dirs.t
CommitLineData
e37ad815 1#!perl\r
2\r
3use strict;\r
4use warnings;\r
5\r
6use FindBin;\r
7use lib "$FindBin::Bin/lib";\r
8\r
0495a293 9use Test::More tests => 13;\r
e37ad815 10use Catalyst::Test 'TestApp';\r
11\r
12# test defined static dirs\r
13TestApp->config->{static}->{dirs} = [\r
14 'always-static',\r
15 qr/^images/,\r
16 'qr/^css/',\r
17];\r
18\r
19# a file with no extension will return text/plain\r
20ok( my $res = request('http://localhost/always-static/test'), 'request ok' );\r
21is( $res->content_type, 'text/plain', 'text/plain ok' );\r
22\r
c8ee8fd2 23# a file with an extension in ignore_extensions still gets served\r
24ok( $res = request('http://localhost/always-static/test.html'), 'request ok' );\r
25is( $res->code, 200, 'html file in dirs get served' );\r
26\r
0495a293 27# a missing file in a defined static dir will return 404 and text/html\r
e37ad815 28ok( $res = request('http://localhost/always-static/404.txt'), 'request ok' );\r
29is( $res->code, 404, '404 ok' );\r
0495a293 30is( $res->content_type, 'text/html', '404 is text/html' );\r
e37ad815 31\r
32# qr regex test\r
33ok( $res = request('http://localhost/images/catalyst.png'), 'request ok' );\r
34is( $res->content_type, 'image/png', 'qr regex path ok' );\r
35\r
36# eval regex test\r
37ok( $res = request('http://localhost/css/static.css'), 'request ok' );\r
38like( $res->content, qr/background/, 'eval regex path ok' );\r
0495a293 39\r
40# A static dir with no trailing slash is handled by Cat\r
41ok( $res = request('http://localhost/always-static'), 'request ok' );\r
42is( $res->content, 'default', 'content ok' );