diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 95eeda6d4..154cb950b 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -10,9 +10,6 @@ - fix: Redirects get displayed inside page layouts as '0' - fix: Mysterious "0" Appearing When Admin Is Off - fix: Deletion of Products - - Fix Asset.pm so that if no className is passed primeval Assets are not - returned. - 7.0.4 - Added a forum.lastPost.user.hasRead variable to the Message Board template. diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 57e329f52..5fd0be7c8 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1361,7 +1361,7 @@ sub manageAssetsSearch { =head2 new ( session, assetId [, className, revisionDate ] ) -Constructor. This does not create an asset. Returns a new object if it can, otherwise returns undef. +Constructor. This does not create an asset. =head3 session @@ -1377,7 +1377,8 @@ By default we'll use whatever class it is called by like WebGUI::Asset::File->ne =head3 revisionDate -An epoch date that represents a specific version of an asset. By default the most recent version will be used. +An epoch date that represents a specific version of an asset. By default the most recent version will be used. If +no revision date is available it will return undef. =cut @@ -1406,7 +1407,6 @@ sub new { } $class = $className; } - return undef if $class eq 'WebGUI::Asset'; my $cache = WebGUI::Cache->new($session, ["asset",$assetId,$revisionDate]); my $properties = $cache->get; if (exists $properties->{assetId}) { diff --git a/t/Asset/Asset.t b/t/Asset/Asset.t index 4adb6ec6e..973f78bd7 100644 --- a/t/Asset/Asset.t +++ b/t/Asset/Asset.t @@ -17,7 +17,7 @@ use WebGUI::Session; use WebGUI::Asset; use WebGUI::Asset::Wobject::Navigation; -use Test::More tests => 11; # increment this value for each test you create +use Test::More tests => 13; # increment this value for each test you create my $session = WebGUI::Test->session; @@ -47,9 +47,8 @@ $deadAsset = WebGUI::Asset->new($session, '', 'WebGUI::Asset::Wobject::Navigatio is ($deadAsset, undef,'new constructor with no assetId returns undef'); # -- no class -$deadAsset = 1; -$deadAsset = WebGUI::Asset->new($session, $assetId); -is ($deadAsset, undef,'new constructor with no class returns undef'); +my $primevalAsset = WebGUI::Asset->new($session, $assetId); +isa_ok ($primevalAsset, 'WebGUI::Asset'); # Test the newByDynamicClass Constructor $asset = undef; @@ -70,6 +69,11 @@ $deadAsset = 1; $deadAsset = WebGUI::Asset->newByDynamicClass($session); is ($deadAsset, undef, 'newByDynamicClass constructor with no assetId returns undef'); +# Root Asset +my $rootAsset = WebGUI::Asset->getRoot($session); +isa_ok($rootAsset, 'WebGUI::Asset'); +is($rootAsset->getId, 'PBasset000000000000001', 'Root Asset ID check'); + # TODO # Test the newByPropertiesHashRef Constructor #