create status 302 "found"
[catagits/Catalyst-Action-Serialize-Data-Serializer.git] / t / lib / Test / Catalyst / Action / REST / Controller / REST.pm
1 package Test::Catalyst::Action::REST::Controller::REST;
2
3 use Moose;
4 use namespace::autoclean;
5
6 BEGIN { extends 'Catalyst::Controller::REST' }
7
8 sub test : Local {
9     my ( $self, $c ) = @_;
10     $self->status_ok( $c,
11         entity => { test => 'worked', data => $c->req->data } );
12 }
13
14 sub test_status_created : Local {
15     my ( $self, $c ) = @_;
16     $self->status_created(
17         $c,
18         location => '/rest',
19         entity   => { status => 'created' }
20     );
21 }
22
23 sub test_status_multiple_choices : Local {
24     my ( $self, $c ) = @_;
25     $self->status_multiple_choices(
26         $c,
27         location => '/rest/choice1',
28         entity   => { choices => [qw(/rest/choice1 /rest/choice2)] }
29     );
30 }
31
32 sub test_status_found : Local {
33     my ( $self, $c ) = @_;
34     $self->status_found(
35         $c,
36         location => '/rest',
37         entity   => { status => 'found' },
38     );
39 }
40
41 sub test_status_accepted : Local {
42     my ( $self, $c ) = @_;
43     $self->status_accepted( $c, entity => { status => "queued", } );
44 }
45
46 sub test_status_no_content : Local {
47     my ( $self, $c ) = @_;
48     $self->status_no_content($c);
49 }
50
51 sub test_status_bad_request : Local {
52     my ( $self, $c ) = @_;
53     $self->status_bad_request( $c,
54         message => "Cannot do what you have asked!", );
55 }
56
57 sub test_status_forbidden : Local {
58     my ( $self, $c ) = @_;
59     $self->status_forbidden ( $c,
60         message => "access denied", );
61 }
62
63 sub test_status_not_found : Local {
64     my ( $self, $c ) = @_;
65     $self->status_not_found( $c,
66         message => "Cannot find what you were looking for!", );
67 }
68
69 sub test_status_gone : Local {
70     my ( $self, $c ) = @_;
71     $self->status_gone( $c,
72         message => "Document have been deleted by foo", );
73 }
74
75 1;