From 587ff397b5861302862ddc26598b251e20589aff Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 10 Sep 2010 11:14:03 -0700 Subject: [PATCH] More cleanup from dispatch. Do not set the session asset if the requested URL does not exist. In RssFeed, pass the fragment to the next method. Fixes bug #11854. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/AssetAspect/RssFeed.pm | 2 +- lib/WebGUI/Content/Asset.pm | 1 + lib/WebGUI/Session.pm | 13 +++++++++++++ t/Content/Asset.t | 15 ++++++++++++++- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 64f26cca0..12c72b300 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,5 +1,6 @@ 7.10.1 - fixed #11851: Story Topic: top story variables should be available all the time + - fixed #11854: CS doesn't return Not Found page 7.10.0 - fixed #11812: Checking www_ajaxSave's response in the cart js, urlencoding post parameters diff --git a/lib/WebGUI/AssetAspect/RssFeed.pm b/lib/WebGUI/AssetAspect/RssFeed.pm index fc758fc0a..1b39921a9 100644 --- a/lib/WebGUI/AssetAspect/RssFeed.pm +++ b/lib/WebGUI/AssetAspect/RssFeed.pm @@ -160,7 +160,7 @@ sub dispatch { elsif ($fragment eq '.rdf') { return $self->www_viewRdf; } - return $self->next::method(); + return $self->next::method($fragment); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Content/Asset.pm b/lib/WebGUI/Content/Asset.pm index 400682475..58598099e 100644 --- a/lib/WebGUI/Content/Asset.pm +++ b/lib/WebGUI/Content/Asset.pm @@ -84,6 +84,7 @@ sub dispatch { return $output if defined $output; } } + $session->clearAsset; if ($session->var->isAdminOn) { my $asset = WebGUI::Asset->newByUrl($session, $session->url->getRefererUrl) || WebGUI::Asset->getDefault($session); return $asset->addMissing($assetUrl); diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index b25f3d80c..7a4303a04 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -110,6 +110,19 @@ sub asset { #------------------------------------------------------------------- +=head2 clearAsset ( ) + +Clears out the session asset. + +=cut + +sub clearAsset { + my $self = shift; + $self->{_asset} = undef; +} + +#------------------------------------------------------------------- + =head2 close Cleans up a WebGUI session information from memory and disconnects from any resources opened by the session. diff --git a/t/Content/Asset.t b/t/Content/Asset.t index 7492ecb4e..4c291e51d 100644 --- a/t/Content/Asset.t +++ b/t/Content/Asset.t @@ -17,6 +17,7 @@ use FindBin; use strict; use lib "$FindBin::Bin/../lib"; use Test::More; +use Test::MockObject::Extends; use Test::Deep; use Data::Dumper; use WebGUI::Test; # Must use this before any other WebGUI modules @@ -92,7 +93,7 @@ WebGUI::Test->addToCleanup( WebGUI::VersionTag->getWorking( $session ) ); #---------------------------------------------------------------------------- # Tests -plan tests => 20; # Increment this number for each test you create +plan tests => 22; # Increment this number for each test you create #---------------------------------------------------------------------------- # test getUrlPermutation( url ) method @@ -204,4 +205,16 @@ $output = WebGUI::Content::Asset::dispatch( $session ); is $output, 'www_view one', 'an empty URL returns the default asset'; $session->setting->set('defaultPage', $originalDefaultPage); +# Test that requesting a URL that doesn't exist, but one of the permutations does exist, returns undef +#my $default = WebGUI::Asset->getDefault($session); +#my $mockDefault = Test::MockObject::Extends->new($default); +#$mockDefault->mock('addMissing', sub { return "add missing" }); + +$session->request->setup_body({ }); +my $nonexistant_url = WebGUI::Asset->getDefault($session)->get('url'); +$nonexistant_url = join '/', $nonexistant_url, 'nothing_here_to_see'; +$output = WebGUI::Content::Asset::dispatch( $session, $nonexistant_url ); +is $output, undef, 'getting a URL which does not exist returns undef'; +is $session->asset, undef, '... session asset is not set'; + #vim:ft=perl