don't mess with the class attribute
[catagits/Catalyst-Runtime.git] / t / forward_instances.t
1 use warnings;
2 use strict;
3 use Test::More;
4
5 # Test case for reported issue when an action consumes JSON but a
6 # POST sends nothing we get a hard error
7
8 {
9   package MyApp::Controller::Root;
10   $INC{'MyApp/Controller/Root.pm'} = __FILE__;
11
12   use base 'Catalyst::Controller';
13
14   sub test_forward :Local Args(0) {
15     my( $self, $c ) = @_;
16     my $view = $c->view('Test');
17     $c->forward($view);
18
19     Test::More::is("$view", "@{[ $c->res->body]}");
20   }
21
22   package MyApp::View::Test;
23   $INC{'MyApp/View/Test.pm'} = __FILE__;
24
25   use base 'Catalyst::View';
26
27   sub ACCEPT_CONTEXT {
28     my ($self, $c, @args) = @_;
29     return ref($self)->new;
30   }
31
32   sub process {
33     my ($self, $c, @args) = @_;
34     $c->res->body("$self");
35   }
36
37   package MyApp;
38   use Catalyst;
39   MyApp->setup;
40 }
41
42 use HTTP::Request::Common;
43 use Catalyst::Test 'MyApp';
44
45 {
46   ok my $res = request GET 'root/test_forward';
47 }
48
49 done_testing(2);