From a3e08c3b8e3be88fcde2112ebc6ac7bfd5c891a6 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Tue, 24 Aug 2010 16:15:14 -0500 Subject: [PATCH] regression tests for asset 304 response --- t/Content/Asset.t | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/t/Content/Asset.t b/t/Content/Asset.t index c746df170..8031afe96 100644 --- a/t/Content/Asset.t +++ b/t/Content/Asset.t @@ -82,7 +82,7 @@ WebGUI::Test->addToCleanup( WebGUI::VersionTag->getWorking( $session ) ); #---------------------------------------------------------------------------- # Tests -plan tests => 17; # Increment this number for each test you create +plan tests => 22; # Increment this number for each test you create #---------------------------------------------------------------------------- # test getUrlPermutation( url ) method @@ -184,4 +184,32 @@ $output = WebGUI::Content::Asset::dispatch( $session ); is $output, 'www_view one', 'an empty URL returns the default asset'; $session->setting->set('defaultPage', $originalDefaultPage); +#---------------------------------------------------------------------------- +# 304 Content Not Modified response + +my $newAsset = WebGUI::Asset->getImportNode( $session )->addChild( { + className => 'WebGUI::Asset::Wobject::Article', +} ); + +my $tag = WebGUI::VersionTag->getWorking( $session ); +$tag->commit; +WebGUI::Test->addToCleanup( $tag ); + +my $http_request = HTTP::Request::Common::GET('http://'.$session->config->get('sitename')->[0]); +$http_request->header('If-Modified-Since' => $session->datetime->epochToHttp(time + 20)); # 20 seconds into the future! +my $notModifiedSession = WebGUI::Test->newSession( undef, $http_request); +WebGUI::Test->addToCleanup( $notModifiedSession ); + +my $output = WebGUI::Content::Asset::handler( $notModifiedSession ); +is( $output, "chunked", "304 returns chunked" ); +is( $notModifiedSession->http->getStatus, "304", "http status code set" ); +ok( !$notModifiedSession->closed, "session is not closed" ); + +$notModifiedSession = WebGUI::Test->newSession( undef, $http_request); +WebGUI::Test->addToCleanup( $notModifiedSession ); +$notModifiedSession->user({ userId => 3}); +my $output = WebGUI::Content::Asset::handler( $notModifiedSession ); +isnt( $notModifiedSession->http->getStatus, "304", "logged in user doesn't get 304" ); +ok( !$notModifiedSession->closed, "session is not closed" ); + #vim:ft=perl