2 use lib "$FindBin::Bin/lib";
3 use Catalyst::Test 'TestApp', {default_host => 'default.com'};
11 HTTP::Request->new( GET => 'http://localhost:3000/test_redirect' );
13 ok( my $response = request($request), 'Request' );
14 is( $response->code, 302, 'Response Code' );
16 # When no body and no content_type has been set, redirecting should set both.
17 is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' );
18 like( $response->content, qr/<body>/, 'Content contains HTML body' );
21 # test redirect without a body and but with a content_type set explicitly by the developer
24 HTTP::Request->new( GET => 'http://localhost:3000/test_redirect_with_contenttype' );
26 ok( my $response = request($request), 'Request' );
27 is( $response->code, 302, 'Response Code' );
29 # When the developer has not set content body, we set it. The content type must always match the body, so it should be overwritten.
30 is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' );
31 like( $response->content, qr/<body>/, 'Content contains HTML body' );
34 # test redirect without a body and but with a content_type set explicitly by the developer
37 HTTP::Request->new( GET => 'http://localhost:3000/test_redirect_with_content' );
39 ok( my $response = request($request), 'Request' );
40 is( $response->code, 302, 'Response Code' );
42 # When the developer sets both the content body and content type, the set content body and content_type should get through.
43 is( $response->header( 'Content-Type' ), 'text/plain', 'Content Type' );
44 like( $response->content, qr/kind sir/, 'Content contains content set by the Controller' );