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