change forward/detach to work with instances
[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 :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
38   package MyApp;
39   use Catalyst;
40   MyApp->setup;
41 }
42
43 use HTTP::Request::Common;
44 use Catalyst::Test 'MyApp';
45
46 {
47   ok my $res = request GET 'root/test';
48 }
49
50 done_testing(2);