X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Faggregate%2Flive_redirect_body.t;h=c7bb241dc50b21e583ad2e608a995713e08316a1;hb=9bdde4de9bedb3f4ebd9f90d2e79b27a00689038;hp=135cb85f11272d82a81aff5bca4ab7070755dba1;hpb=5dbac379d1a478321ca88d3c94c16d32224f8a60;p=catagits%2FCatalyst-Runtime.git diff --git a/t/aggregate/live_redirect_body.t b/t/aggregate/live_redirect_body.t index 135cb85..c7bb241 100644 --- a/t/aggregate/live_redirect_body.t +++ b/t/aggregate/live_redirect_body.t @@ -3,43 +3,46 @@ use lib "$FindBin::Bin/../lib"; use Catalyst::Test 'TestApp', {default_host => 'default.com'}; use Catalyst::Request; -use Test::More tests => 12; - - # test redirect - { - my $request = - HTTP::Request->new( GET => 'http://localhost:3000/test_redirect' ); - - ok( my $response = request($request), 'Request' ); - is( $response->code, 302, 'Response Code' ); - - # When no body and no content_type has been set, redirecting should set both. - is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); - like( $response->content, qr//, 'Content contains HTML body' ); - } - - # test redirect without a body and but with a content_type set explicitly by the developer - { - my $request = - HTTP::Request->new( GET => 'http://localhost:3000/test_redirect_with_contenttype' ); - - ok( my $response = request($request), 'Request' ); - is( $response->code, 302, 'Response Code' ); - - # When the developer has not set content body, we set it. The content type must always match the body, so it should be overwritten. - is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); - like( $response->content, qr//, 'Content contains HTML body' ); - } - - # test redirect without a body and but with a content_type set explicitly by the developer - { - my $request = - HTTP::Request->new( GET => 'http://localhost:3000/test_redirect_with_content' ); - - ok( my $response = request($request), 'Request' ); - is( $response->code, 302, 'Response Code' ); - - # When the developer sets both the content body and content type, the set content body and content_type should get through. - is( $response->header( 'Content-Type' ), 'text/plain', 'Content Type' ); - like( $response->content, qr/kind sir/, 'Content contains content set by the Controller' ); - } +use Test::More; + +# test redirect +{ + my $request = + HTTP::Request->new( GET => 'http://localhost:3000/test_redirect' ); + + ok( my $response = request($request), 'Request' ); + is( $response->code, 302, 'Response Code' ); + + # When no body and no content_type has been set, redirecting should set both. + is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); + like( $response->content, qr//, 'Content contains HTML body' ); +} + +# test redirect without a body and but with a content_type set explicitly by the developer +{ + my $request = + HTTP::Request->new( GET => 'http://localhost:3000/test_redirect_with_contenttype' ); + + ok( my $response = request($request), 'Request' ); + is( $response->code, 302, 'Response Code' ); + + # When the developer has not set content body, we set it. The content type must always match the body, so it should be overwritten. + is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); + like( $response->content, qr//, 'Content contains HTML body' ); +} + +# test redirect without a body and but with a content_type set explicitly by the developer +{ + my $request = + HTTP::Request->new( GET => 'http://localhost:3000/test_redirect_with_content' ); + + ok( my $response = request($request), 'Request' ); + is( $response->code, 302, 'Response Code' ); + + # When the developer sets both the content body and content type, the set content body and content_type should get through. + is( $response->header( 'Content-Type' ), 'text/plain', 'Content Type' ); + like( $response->content, qr/kind sir/, 'Content contains content set by the Controller' ); +} + +done_testing; +