tests for dispatching to actions
[catagits/Catalyst-Action-REST.git] / t / lib / Test / Catalyst / Action / REST / Controller / Actions.pm
diff --git a/t/lib/Test/Catalyst/Action/REST/Controller/Actions.pm b/t/lib/Test/Catalyst/Action/REST/Controller/Actions.pm
new file mode 100644 (file)
index 0000000..f1b6f23
--- /dev/null
@@ -0,0 +1,95 @@
+package Test::Catalyst::Action::REST::Controller::Actions;
+use strict;
+use warnings;
+
+use base qw/Catalyst::Controller::REST/;
+
+__PACKAGE__->config( namespace => 'actions' );
+
+sub begin {}  # Don't need serialization..
+
+sub test : Local : ActionClass('REST') {
+    my ( $self, $c ) = @_;
+    $c->stash->{'entity'} = 'something';
+}
+
+sub test_GET :ActionClass('+Test::Action::Class') {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} .= " GET";
+    $c->forward('ok');
+}
+
+sub test_POST :ActionClass('+Test::Action::Class') {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} .= " POST";
+    $c->forward('ok');
+}
+
+sub test_PUT :ActionClass('+Test::Action::Class') {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} .= " PUT";
+    $c->forward('ok');
+}
+
+sub test_DELETE :ActionClass('+Test::Action::Class') {
+    my ( $self, $c ) = @_;
+    $c->stash->{'entity'} .= " DELETE";
+    $c->forward('ok');
+}
+
+sub test_OPTIONS :ActionClass('+Test::Action::Class') {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} .= " OPTIONS";
+    $c->forward('ok');
+}
+
+sub notreally : Local : ActionClass('REST') {
+}
+
+sub notreally_GET :ActionClass('+Test::Action::Class') {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} = "notreally GET";
+    $c->forward('ok');
+}
+
+sub not_implemented : Local : ActionClass('REST') {
+}
+
+sub not_implemented_GET :ActionClass('+Test::Action::Class') {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} = "not_implemented GET";
+    $c->forward('ok');
+}
+
+sub not_implemented_not_implemented :ActionClass('+Test::Action::Class') {
+    my ( $self, $c ) = @_;
+
+    $c->stash->{'entity'} = "Not Implemented Handler";
+    $c->forward('ok');
+}
+
+sub not_modified : Local : ActionClass('REST') { }
+
+sub not_modified_GET {
+    my ( $self, $c ) = @_;
+    $c->res->status(304);
+    return 1;
+}
+
+sub ok : Private {
+    my ( $self, $c ) = @_;
+
+    $c->res->content_type('text/plain');
+    $c->res->body( $c->stash->{'entity'} );
+}
+
+sub end : Private {} # Don't need serialization..
+
+1;
+