Set the session asset, added tests.

This commit is contained in:
Colin Kuskie 2010-08-05 10:58:21 -07:00
parent 3e60133e10
commit 98d3ecc16f
2 changed files with 6 additions and 1 deletions

View file

@ -81,6 +81,7 @@ sub dispatch {
my $fragment = $assetUrl; my $fragment = $assetUrl;
$fragment =~ s/$url//; $fragment =~ s/$url//;
$session->asset($asset);
my $output = eval { $asset->dispatch($fragment); }; my $output = eval { $asset->dispatch($fragment); };
return $output if defined $output; return $output if defined $output;
} }

View file

@ -79,7 +79,7 @@ WebGUI::Test->addToCleanup( WebGUI::VersionTag->getWorking( $session ) );
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Tests # Tests
plan tests => 12; # Increment this number for each test you create plan tests => 15; # Increment this number for each test you create
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# test getUrlPermutation( url ) method # test getUrlPermutation( url ) method
@ -118,12 +118,15 @@ cmp_deeply(
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# test dispatch( session, url ) method # test dispatch( session, url ) method
is ($session->asset, undef, 'session asset is not defined, yet');
is( is(
WebGUI::Content::Asset::dispatch( $session, "testdispatch" ), WebGUI::Content::Asset::dispatch( $session, "testdispatch" ),
"www_view one", "www_view one",
"Regular www_view", "Regular www_view",
); );
is ($session->asset->getId, $td->getId, 'dispatch set the session asset');
is( is(
WebGUI::Content::Asset::dispatch( $session, "testdispatch/foo" ), WebGUI::Content::Asset::dispatch( $session, "testdispatch/foo" ),
"bar", "bar",
@ -144,6 +147,7 @@ is(
"www_view two", "www_view two",
"dispatch to the asset with the longest URL", "dispatch to the asset with the longest URL",
); );
is ($session->asset->getId, $clobberingTime->getId, 'dispatch reset the session asset');
$clobberingTime->purge; $clobberingTime->purge;