X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcatalyst-action-rest.t;h=535ac4ea83bdcc8776a701269fff4b0f9ce87b0f;hb=f04ed654a172628f642bdefe8483c1e6becf9ad1;hp=8534732ff37b4b8faa6b411cbec65093b75a41f5;hpb=6646fdc27add35e5421e516b1fcd98560bef0b96;p=catagits%2FCatalyst-Action-REST.git diff --git a/t/catalyst-action-rest.t b/t/catalyst-action-rest.t index 8534732..535ac4e 100644 --- a/t/catalyst-action-rest.t +++ b/t/catalyst-action-rest.t @@ -1,100 +1,7 @@ -package Test::Catalyst::Action::REST; - -use FindBin; - -use lib ("$FindBin::Bin/../lib"); - use strict; use warnings; - -use Catalyst::Runtime '5.70'; - -use Catalyst; - -__PACKAGE__->config( name => 'Test::Catalyst::Action::REST' ); -__PACKAGE__->setup; - -sub test : Local : ActionClass('REST') { - my ( $self, $c ) = @_; - $c->stash->{'entity'} = 'something'; -} - -sub test_GET : Local : ActionClass('REST') { - my ( $self, $c ) = @_; - - $c->stash->{'entity'} .= " GET"; - $c->forward('ok'); -} - -sub test_POST : Local : ActionClass('REST') { - my ( $self, $c ) = @_; - - $c->stash->{'entity'} .= " POST"; - $c->forward('ok'); -} - -sub test_PUT : Local : ActionClass('REST') { - my ( $self, $c ) = @_; - - $c->stash->{'entity'} .= " PUT"; - $c->forward('ok'); -} - -sub test_DELETE : Local : ActionClass('REST') { - my ( $self, $c ) = @_; - - $c->stash->{'entity'} .= " DELETE"; - $c->forward('ok'); -} - -sub test_OPTIONS : Local : ActionClass('REST') { - my ( $self, $c ) = @_; - - $c->stash->{'entity'} .= " OPTIONS"; - $c->forward('ok'); -} - -sub notreally : Local : ActionClass('REST') { -} - -sub notreally_GET { - my ( $self, $c ) = @_; - - $c->stash->{'entity'} = "notreally GET"; - $c->forward('ok'); -} - -sub not_implemented : Local : ActionClass('REST') { -} - -sub not_implemented_GET { - my ( $self, $c ) = @_; - - $c->stash->{'entity'} = "not_implemented GET"; - $c->forward('ok'); -} - -sub not_implemented_not_implemented { - my ( $self, $c ) = @_; - - $c->stash->{'entity'} = "Not Implemented Handler"; - $c->forward('ok'); -} - -sub ok : Private { - my ( $self, $c ) = @_; - - $c->res->content_type('text/plain'); - $c->res->body( $c->stash->{'entity'} ); -} - -package main; - -use strict; -use warnings; -use Test::More tests => 17; +use Test::More tests => 18; use FindBin; -use Data::Dump qw(dump); use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" ); use Test::Rest; @@ -114,7 +21,7 @@ foreach my $method (qw(GET DELETE POST PUT OPTIONS)) { $res = request( $t->$run_method( url => '/test', - data => { foo => 'bar' } + data => '', ) ); } @@ -135,6 +42,9 @@ is( $options_res->code, 200, "OPTIONS request handler succeeded" ); is( $options_res->header('allow'), "GET", "OPTIONS request allow header properly set." ); +my $modified_res = request( $t->get( url => '/not_modified' ) ); +is( $modified_res->code, 304, "Not Modified request handler succeeded" ); + my $ni_res = request( $t->delete( url => '/not_implemented' ) ); is( $ni_res->code, 200, "Custom not_implemented handler succeeded" ); is(