From e5affbd0c2bc6f5d5c0b68f1dba9a8e07486e3a8 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 22 Jan 2010 11:42:05 -0800 Subject: [PATCH] Add tagId property, fix cloneFromDb. Fix several tests. --- lib/WebGUI/Asset.pm | 10 +++++++--- t/Asset/Asset.t | 36 ++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 68f7afeec..f7609b088 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -243,6 +243,11 @@ property assetSize => ( fieldType => 'integer', default => 0, ); +property tagId => ( + noFormPost => 1, + fieldType => 'guid', + default => 0, + ); has session => ( is => 'ro', required => 1, @@ -588,10 +593,9 @@ Returns the new Asset object. sub cloneFromDb { my $self = shift; - return WebGUI::Asset->new($self->session, + return WebGUI::Asset->newById($self->session, $self->getId, - $self->get('className'), - $self->get('revisionDate') + $self->revisionDate ); } diff --git a/t/Asset/Asset.t b/t/Asset/Asset.t index 0e57898e2..f85f155f1 100644 --- a/t/Asset/Asset.t +++ b/t/Asset/Asset.t @@ -35,7 +35,7 @@ my $session = WebGUI::Test->session; my @getTitleTests = getTitleTests($session); -plan tests => 114 +plan tests => 105 + 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle ; @@ -586,7 +586,7 @@ my $iufpAsset2 = $iufpAsset->addChild($properties2, $properties2->{id}); $iufpAsset2->update( { inheritUrlFromParent => 1 } ); is $iufpAsset2->inheritUrlFromParent, 1, 'inheritUrlFromParent set'; $iufpAsset2->commit; -is($iufpAsset2->get('url'), 'inheriturlfromparent01/inheriturlfromparent02', 'inheritUrlFromParent works'); +is($iufpAsset2->url, 'inheriturlfromparent01/inheriturlfromparent02', 'inheritUrlFromParent works'); my $properties2a = { # '1234567890123456789012' @@ -599,12 +599,12 @@ my $properties2a = { my $iufpAsset2a = $iufpAsset->addChild($properties2a, $properties2a->{id}); $iufpAsset2a->commit; -is($iufpAsset2a->get('url'), 'inheriturlfromparent01/inheriturlfromparent2a', '... works when created with the property'); +is($iufpAsset2a->url, 'inheriturlfromparent01/inheriturlfromparent2a', '... works when created with the property'); # works for setting, now try disabling. Should not change the URL. $iufpAsset2->update( { inheritUrlFromParent => 0 } ); $iufpAsset2->commit; -is($iufpAsset2->get('url'), 'inheriturlfromparent01/inheriturlfromparent02', '... setting inheritUrlFromParent to 0 works'); +is($iufpAsset2->url, 'inheriturlfromparent01/inheriturlfromparent02', '... setting inheritUrlFromParent to 0 works'); # also make sure that it is actually disabled is($iufpAsset2->get('inheritUrlFromParent'), 0, "... disabling inheritUrlFromParent actually works"); @@ -624,10 +624,10 @@ $iufpAsset2->update( { inheritUrlFromParent => 1 } ); $iufpAsset2->commit; $iufpAsset3->update( { inheritUrlFromParent => 1 } ); $iufpAsset3->commit; -is($iufpAsset3->get('url'), 'inheriturlfromparent01/inheriturlfromparent02/inheriturlfromparent03', '... recurses properly'); +is($iufpAsset3->url, 'inheriturlfromparent01/inheriturlfromparent02/inheriturlfromparent03', '... recurses properly'); $iufpAsset2->update({url => 'iufp2'}); -is($iufpAsset2->get('url'), 'inheriturlfromparent01/iufp2', '... update works propertly when iUFP is not passed'); +is($iufpAsset2->url, 'inheriturlfromparent01/iufp2', '... update works propertly when iUFP is not passed'); ################################################################ @@ -648,9 +648,9 @@ $properties = { url => 'moveVersionToParent_01', }; -my $parentAsset = $defaultAsset->addChild($properties, $properties->{id}); -my $parentVersionTag = WebGUI::VersionTag->new($session, $parentAsset->get('tagId')); -is($parentVersionTag->get('isCommitted'),0, 'built non-committed parent asset'); +my $parentAsset = $defaultAsset->addChild($properties, $properties->{id}); +my $parentVersionTag = WebGUI::VersionTag->new($session, $parentAsset->tagId); +is($parentVersionTag->get('isCommitted'), 0, 'built non-committed parent asset'); my $versionTag6 = WebGUI::VersionTag->create($session, {}); @@ -667,23 +667,23 @@ $properties2 = { }; my $childAsset = $parentAsset->addChild($properties, $properties2->{id}); -my $testAsset = WebGUI::Asset->newPending($session, $childAsset->get('parentId')); -my $testVersionTag = WebGUI::VersionTag->new($session, $testAsset->get('tagId')); +my $testAsset = WebGUI::Asset->newPending($session, $childAsset->parentId); +my $testVersionTag = WebGUI::VersionTag->new($session, $testAsset->tagId); my $childVersionTag; -$childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId')); -is($childVersionTag->get('isCommitted'),0, 'built non-committed child asset'); +$childVersionTag = WebGUI::VersionTag->new($session, $childAsset->tagId); +is($childVersionTag->get('isCommitted'), 0, 'built non-committed child asset'); -isnt($testAsset->get('tagId'),$childAsset->get('tagId'),'parent asset and child asset have different version tags'); -isnt($testVersionTag->getId,$childVersionTag->getId,'parent asset and child asset version tags unmatched'); +isnt($testAsset->tagId, $childAsset->tagId, 'parent asset and child asset have different version tags'); +isnt($testVersionTag->getId, $childVersionTag->getId, 'parent asset and child asset version tags unmatched'); eval { $childAsset->requestAutoCommit; - $childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId')); + $childVersionTag = WebGUI::VersionTag->new($session, $childAsset->tagId); }; -is($childVersionTag->get('isCommitted'),0, 'confirm non-committed child asset'); +is($childVersionTag->get('isCommitted'), 0, 'confirm non-committed child asset'); -is($testAsset->get('tagId'),$childAsset->get('tagId'),'parent asset and child asset have same version tags'); +is($testAsset->tagId, $childAsset->tagId, 'parent asset and child asset have same version tags'); eval { $testVersionTag->commit;