Commit | Line | Data |
7656dd12 |
1 | use strict; |
2 | use warnings; |
5213846d |
3 | use Test::More 0.88; |
7656dd12 |
4 | use FindBin; |
5 | |
6 | use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" ); |
7 | use Test::Rest; |
8 | |
9 | # Should use the default serializer, YAML |
10 | my $t = Test::Rest->new( 'content_type' => 'text/plain' ); |
11 | |
12 | use_ok 'Catalyst::Test', 'Test::Catalyst::Action::REST'; |
13 | |
14 | foreach my $method (qw(GET DELETE POST PUT OPTIONS)) { |
15 | my $run_method = lc($method); |
7656dd12 |
16 | my $res; |
17 | if ( grep /$method/, qw(GET DELETE OPTIONS) ) { |
18 | $res = request( $t->$run_method( url => '/actions/test' ) ); |
19 | } else { |
20 | $res = request( |
21 | $t->$run_method( |
22 | url => '/actions/test', |
23 | data => '', |
24 | ) |
25 | ); |
26 | } |
27 | ok( $res->is_success, "$method request succeeded" ); |
28 | is( |
29 | $res->content, |
5f461845 |
30 | "$method", |
7656dd12 |
31 | "$method request had proper response" |
32 | ); |
33 | is( |
5f461845 |
34 | $res->header('X-Was-In-TopLevel'), |
35 | '1', |
36 | "went through top level action for dispatching to $method" |
37 | ); |
38 | is( |
7656dd12 |
39 | $res->header('Using-Action'), |
40 | 'STATION', |
41 | "went through action for dispatching to $method" |
42 | ); |
43 | } |
44 | |
5213846d |
45 | my $res = request( |
46 | $t->put( |
47 | url => '/actions/test', |
48 | data => '', |
49 | ) |
50 | ); |
51 | is( |
52 | $res->header('Using-Action'), |
53 | 'STATION', |
54 | "went through action for dispatching to PUT" |
55 | ); |
56 | is( |
57 | $res->header('Using-Sub-Action'), |
58 | 'MOO', |
59 | "went through sub action for dispatching to PUT" |
60 | ); |
61 | |
62 | done_testing; |