X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F05dirs.t;h=f342556db79ca188f3613bce88ea51738ef2431b;hb=ff1c0d19a46cc42ec4a7b1d493cb58e0f39582e2;hp=fa5db8a7cd750f0c775fdfd21e8608ee6cb4a00e;hpb=e37ad815c40f3cbde50ad12cd6b3ac68f0dc7399;p=catagits%2FCatalyst-Plugin-Static-Simple.git diff --git a/t/05dirs.t b/t/05dirs.t index fa5db8a..f342556 100644 --- a/t/05dirs.t +++ b/t/05dirs.t @@ -1,33 +1,42 @@ -#!perl - -use strict; -use warnings; - -use FindBin; -use lib "$FindBin::Bin/lib"; - -use Test::More tests => 8; -use Catalyst::Test 'TestApp'; - -# test defined static dirs -TestApp->config->{static}->{dirs} = [ - 'always-static', - qr/^images/, - 'qr/^css/', -]; - -# a file with no extension will return text/plain -ok( my $res = request('http://localhost/always-static/test'), 'request ok' ); -is( $res->content_type, 'text/plain', 'text/plain ok' ); - -# a missing file in a defined static dir will return 404 -ok( $res = request('http://localhost/always-static/404.txt'), 'request ok' ); -is( $res->code, 404, '404 ok' ); - -# qr regex test -ok( $res = request('http://localhost/images/catalyst.png'), 'request ok' ); -is( $res->content_type, 'image/png', 'qr regex path ok' ); - -# eval regex test -ok( $res = request('http://localhost/css/static.css'), 'request ok' ); -like( $res->content, qr/background/, 'eval regex path ok' ); +#!perl + +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/lib"; + +use Test::More tests => 13; +use Catalyst::Test 'TestApp'; + +# test defined static dirs +TestApp->config->{'Plugin::Static::Simple'}->{dirs} = [ + 'always-static', + qr/^images/, + 'qr/^css/', +]; + +# a file with no extension will return text/plain +ok( my $res = request('http://localhost/always-static/test'), 'request ok' ); +is( $res->content_type, 'text/plain', 'text/plain ok' ); + +# a file with an extension in ignore_extensions still gets served +ok( $res = request('http://localhost/always-static/test.html'), 'request ok' ); +is( $res->code, 200, 'html file in dirs get served' ); + +# a missing file in a defined static dir will return 404 and text/html +ok( $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' ); + +# qr regex test +ok( $res = request('http://localhost/images/catalyst.png'), 'request ok' ); +is( $res->content_type, 'image/png', 'qr regex path ok' ); + +# eval regex test +ok( $res = request('http://localhost/css/static.css'), 'request ok' ); +like( $res->content, qr/background/, 'eval regex path ok' ); + +# A static dir with no trailing slash is handled by Cat +ok( $res = request('http://localhost/always-static'), 'request ok' ); +is( $res->content, 'default', 'content ok' );