X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcatalyst-action-rest.t;h=96452e91d79c34bbba688527f92b1eaec27da802;hb=3d1e10e70eb17bd02ed4c3ba440fce3a94696833;hp=535ac4ea83bdcc8776a701269fff4b0f9ce87b0f;hpb=501578043bb885a3383d99b818ff2faeb7a334d5;p=catagits%2FCatalyst-Action-REST.git diff --git a/t/catalyst-action-rest.t b/t/catalyst-action-rest.t index 535ac4e..96452e9 100644 --- a/t/catalyst-action-rest.t +++ b/t/catalyst-action-rest.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 18; +use Test::More; use FindBin; use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" ); @@ -33,14 +33,40 @@ foreach my $method (qw(GET DELETE POST PUT OPTIONS)) { ); } +my $head_res = request( $t->head(url => '/test') ); +ok($head_res->is_success, 'HEAD request succeeded') + or diag($head_res->code); +ok(!$head_res->content, 'HEAD request had proper response'); + +$head_res = request( $t->head(url => '/actions/yet_other_test') ); +ok($head_res->code == 405, 'HEAD request succeeded') + or diag($head_res->code); + my $fail_res = request( $t->delete( url => '/notreally' ) ); is( $fail_res->code, 405, "Request to bad method gets 405 Not Implemented" ); -is( $fail_res->header('allow'), "GET", "405 allow header properly set." ); +is( $fail_res->header('allow'), "GET, HEAD", "405 allow header properly set." ); my $options_res = request( $t->options( url => '/notreally' ) ); is( $options_res->code, 200, "OPTIONS request handler succeeded" ); is( $options_res->header('allow'), - "GET", "OPTIONS request allow header properly set." ); + "GET, HEAD", "OPTIONS request allow header properly set." ); + +my $opts_res = request( $t->options( url => '/rest/opts' ) ); +is( $opts_res->code, 200, "OPTIONS request handler succeeded" ); +is( $opts_res->header('allow'), + "GET, HEAD", "OPTIONS request allow header properly set." ); +is($opts_res->content, q{}, 'should have no body'); + +$opts_res = request( + $t->options( + url => '/rest/opts', + headers => { Accept => 'application/json' }, + ) +); +is( $opts_res->code, 200, "OPTIONS request handler succeeded" ); +is( $opts_res->header('allow'), + "GET, HEAD", "OPTIONS request allow header properly set." ); +is($opts_res->content, q{}, 'should have no body'); my $modified_res = request( $t->get( url => '/not_modified' ) ); is( $modified_res->code, 304, "Not Modified request handler succeeded" ); @@ -54,3 +80,5 @@ is( ); 1; + +done_testing;