Added tests and removed message
[catagits/Catalyst-Action-REST.git] / t / lib / Test / Catalyst / Action / REST / Controller / REST.pm
CommitLineData
0ba73721 1package Test::Catalyst::Action::REST::Controller::REST;
2
930013e6 3use Moose;
4use namespace::autoclean;
0ba73721 5
930013e6 6BEGIN { extends 'Catalyst::Controller::REST' }
0ba73721 7
7cc6122a 8__PACKAGE__->config(
9 'map' => {
10 'text/html' => 'YAML::HTML',
11 'text/x-yaml' => 'YAML',
12});
13
0ba73721 14sub test : Local {
9fb09119 15 my ( $self, $c ) = @_;
16 $self->status_ok( $c,
17 entity => { test => 'worked', data => $c->req->data } );
18}
19
20sub test_status_created : Local {
21 my ( $self, $c ) = @_;
22 $self->status_created(
23 $c,
24 location => '/rest',
25 entity => { status => 'created' }
26 );
27}
28
bdff70a9 29sub test_status_multiple_choices : Local {
30 my ( $self, $c ) = @_;
31 $self->status_multiple_choices(
32 $c,
33 location => '/rest/choice1',
34 entity => { choices => [qw(/rest/choice1 /rest/choice2)] }
35 );
36}
37
e52456a4 38sub test_status_found : Local {
39 my ( $self, $c ) = @_;
40 $self->status_found(
41 $c,
42 location => '/rest',
43 entity => { status => 'found' },
44 );
45}
46
5832c2d0 47sub test_status_not_modified : Local {
48 my ( $self, $c ) = @_;
49 $self->status_not_modified(
50 $c,
51 message => "Not modified",
52 );
53}
54
9fb09119 55sub test_status_accepted : Local {
56 my ( $self, $c ) = @_;
259c53c7 57 $self->status_accepted(
58 $c,
59 location => '/rest',
60 entity => { status => "queued", }
61 );
9fb09119 62}
63
64sub test_status_no_content : Local {
65 my ( $self, $c ) = @_;
66 $self->status_no_content($c);
67}
68
69sub test_status_bad_request : Local {
70 my ( $self, $c ) = @_;
71 $self->status_bad_request( $c,
72 message => "Cannot do what you have asked!", );
73}
74
550807bc 75sub test_status_forbidden : Local {
76 my ( $self, $c ) = @_;
77 $self->status_forbidden ( $c,
78 message => "access denied", );
79}
80
9fb09119 81sub test_status_not_found : Local {
82 my ( $self, $c ) = @_;
83 $self->status_not_found( $c,
84 message => "Cannot find what you were looking for!", );
85}
86
87sub test_status_gone : Local {
88 my ( $self, $c ) = @_;
89 $self->status_gone( $c,
90 message => "Document have been deleted by foo", );
0ba73721 91}
92
80204218 93sub opts : Local ActionClass('REST') {}
94
95sub opts_GET {
96 my ( $self, $c ) = @_;
97 $self->status_ok( $c, entity => { opts => 'worked' } );
98}
99
258f6e7c 100sub opts_not_implemented {
101 my ( $self, $c ) = @_;
102 $c->res->status(405);
103 $c->res->header('Allow' => [qw(GET HEAD)]);
104 $c->res->body('Not implemented');
105}
106
0ba73721 1071;