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