almost done fixing addRevision changes

This commit is contained in:
Doug Bell 2010-11-16 11:18:41 -06:00
parent 3ce9198220
commit 1866c593ea
25 changed files with 186 additions and 199 deletions

View file

@ -60,16 +60,18 @@ $session->config->addToHash('adminConsole', 'test2', {
} );
# Add some assets
my $tag = WebGUI::VersionTag->getWorking( $session );
my $snip = $import->addChild( {
className => 'WebGUI::Asset::Snippet',
title => 'test',
groupIdEdit => '3',
synopsis => "aReallyLongWordToGetIndexed",
keywords => "AKeywordToGetIndexed",
tagId => $tag->getId,
status => "pending",
} );
# Commit the tag
my $tag = WebGUI::VersionTag->getWorking( $session );
$tag->commit;
addToCleanup( $tag );

View file

@ -304,10 +304,6 @@ my $session = WebGUI::Test->session;
is $revAsset->revisionDate, $now, 'revisionDate set correctly on new revision';
is $revAsset->title, 'test title 43', 'data fetch from database correct';
is $revAsset->revisedBy, $session->user->userId, 'revisedBy is current session user';
is $revAsset->tagId, $tag->getId, 'tagId is current working tagId';
ok $revAsset->isLocked, 'new revision is locked';
is $revAsset->isLockedBy, '7', 'locked by userId 7';
is $revAssetDb->isLockedBy, '7', 'database jives with asset data';
my $count = $session->db->quickScalar('SELECT COUNT(*) from assetData where assetId=?',[$testId2]);
is $count, 2, 'two records in the database';
addToCleanup($tag);

View file

@ -98,12 +98,8 @@ $properties = {
groupIdView => 7,
};
my $versionTag2 = WebGUI::VersionTag->getWorking($session);
addToCleanup($versionTag2);
my $canEditAsset = $rootAsset->addChild($properties, $properties->{id});
$versionTag2->commit;
addToCleanup( $canEditAsset );
$properties = {}; ##Clear out the hash so that it doesn't leak later by accident.
my $canEditMaker = WebGUI::Test::Maker::Permission->new();
@ -114,8 +110,6 @@ $canEditMaker->prepare({
'fail' => [1, $testUsers{'regular user'}, ],
});
my $versionTag3 = WebGUI::VersionTag->getWorking($session);
addToCleanup($versionTag3);
$properties = {
# '1234567890123456789012'
id => 'canViewAsset0000000010',
@ -129,8 +123,7 @@ $properties = {
my $canViewAsset = $rootAsset->addChild($properties, $properties->{id});
$versionTag3->commit;
addToCleanup( $canViewAsset );
$properties = {}; ##Clear out the hash so that it doesn't leak later by accident.
my $canViewMaker = WebGUI::Test::Maker::Permission->new();
@ -148,7 +141,7 @@ $canViewMaker->prepare(
},
);
plan tests => 121
plan tests => 113
+ 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle
;
@ -345,10 +338,6 @@ is($importNode->addEditLabel, $i18n->get('add').' '.$importNode->getName, 'addEd
#
################################################################
my $versionTag = WebGUI::VersionTag->getWorking($session);
addToCleanup($versionTag);
$versionTag->set({name=>"Asset tests"});
my $properties = {
# '1234567890123456789012'
id => 'fixUrlAsset00000000012',
@ -358,18 +347,21 @@ my $properties = {
};
my $fixUrlAsset = $defaultAsset->addChild($properties, $properties->{id});
addToCleanup( $fixUrlAsset );
# '1234567890123456789012'
$properties->{id} = 'fixUrlAsset00000000013';
$properties->{url} = 'fixUrlFolderURL9';
my $fixUrlAsset2 = $defaultAsset->addChild($properties, $properties->{id});
addToCleanup( $fixUrlAsset2 );
# '1234567890123456789012'
$properties->{id} = 'fixUrlAsset00000000014';
$properties->{url} = 'fixUrlFolderURL00';
my $fixUrlAsset3 = $defaultAsset->addChild($properties, $properties->{id});
addToCleanup( $fixUrlAsset3 );
# '1234567890123456789012'
$properties->{id} = 'fixUrlAsset00000000015';
@ -377,6 +369,7 @@ $properties->{url} = 'fixUrlFolderURL100';
my $fixUrlAsset4 = $defaultAsset->addChild($properties, $properties->{id});
is($fixUrlAsset4->get('url'), 'fixurlfolderurl100', 'asset setup correctly for 100->101 test');
addToCleanup( $fixUrlAsset4 );
delete $properties->{url};
# '1234567890123456789012'
@ -384,6 +377,7 @@ $properties->{id} = 'fixUrlAsset00000000016';
$properties->{menuTitle} = 'fix url folder url autogenerated';
my $fixUrlAsset5 = $defaultAsset->addChild($properties, $properties->{id});
addToCleanup( $fixUrlAsset5 );
my $properties2 = {
# '1234567890123456789012'
@ -394,8 +388,7 @@ my $properties2 = {
};
my $fixTitleAsset = $defaultAsset->addChild($properties2, $properties2->{id});
##Commit this asset right away
$fixTitleAsset->commit;
addToCleanup( $fixTitleAsset );
$properties2 = {
# '1234567890123456789012'
@ -406,9 +399,7 @@ $properties2 = {
};
my $getTitleAsset = $defaultAsset->addChild($properties2, $properties2->{id});
$getTitleAsset->commit;
$versionTag->commit;
addToCleanup( $getTitleAsset );
$session->setting->set('urlExtension', undef);
@ -623,10 +614,8 @@ my $node = WebGUI::Asset->getRoot($session);
my $product1 = $node->addChild({ className => 'WebGUI::Asset::Sku::Product'}, undef, undef, { skipAutoCommitWorkflows => 1});
my $product2 = $node->addChild({ className => 'WebGUI::Asset::Sku::Product'}, undef, undef, { skipAutoCommitWorkflows => 1});
my $product3 = $node->addChild({ className => 'WebGUI::Asset::Sku::Product'}, undef, undef, { skipAutoCommitWorkflows => 1});
my $pTag = WebGUI::VersionTag->getWorking($session);
$pTag->commit;
addToCleanup($pTag);
my $product4 = $node->addChild({ className => 'WebGUI::Asset::Sku::Product'}, undef, undef, { skipAutoCommitWorkflows => 1});
addToCleanup($product1, $product2, $product3);
my $product4 = $node->addChild({ className => 'WebGUI::Asset::Sku::Product', status => "pending"}, undef, undef, { skipAutoCommitWorkflows => 1});
addToCleanup($product4);
my $getAProduct = WebGUI::Asset::Sku::Product->getIsa($session);
@ -669,10 +658,6 @@ $product4->purge;
################################################################
note "inheritUrlFromParent";
my $versionTag4 = WebGUI::VersionTag->getWorking($session);
addToCleanup($versionTag4);
$versionTag4->set( { name => 'inheritUrlFromParent tests' } );
$properties = {
# '1234567890123456789012'
id => 'inheritUrlFromParent01',
@ -682,6 +667,7 @@ $properties = {
};
my $iufpAsset = $defaultAsset->addChild($properties, $properties->{id});
addToCleanup( $iufpAsset );
$iufpAsset->commit;
$properties2 = {
@ -693,6 +679,7 @@ $properties2 = {
};
my $iufpAsset2 = $iufpAsset->addChild($properties2, $properties2->{id});
addToCleanup( $iufpAsset2 );
$iufpAsset2->update( { inheritUrlFromParent => 1 } );
is $iufpAsset2->inheritUrlFromParent, 1, 'inheritUrlFromParent set';
$iufpAsset2->commit;
@ -708,6 +695,7 @@ my $properties2a = {
};
my $iufpAsset2a = $iufpAsset->addChild($properties2a, $properties2a->{id});
addToCleanup( $iufpAsset2a );
$iufpAsset2a->commit;
is($iufpAsset2a->url, 'inheriturlfromparent01/inheriturlfromparent2a', '... works when created with the property');
@ -729,6 +717,7 @@ my $properties3 = {
url => 'inheriturlfromparent03',
};
my $iufpAsset3 = $iufpAsset2->addChild($properties3, $properties3->{id});
addToCleanup( $iufpAsset3 );
$iufpAsset3->commit;
$iufpAsset2->update( { inheritUrlFromParent => 1 } );
$iufpAsset2->commit;
@ -740,94 +729,19 @@ $iufpAsset2->update({url => 'iufp2'});
is($iufpAsset2->url, 'inheriturlfromparent01/iufp2', '... update works propertly when iUFP is not passed');
################################################################
#
# addRevision to uncommitted child of uncommitted parent
#
################################################################
my $versionTag5 = WebGUI::VersionTag->getWorking($session);
$versionTag5->set( { name => 'move revision of uncommitted child to uncommitted parent tests vt1' } );
$properties = {
# '1234567890123456789012'
id => 'moveVersionToParent_01',
title => 'moveVersionToParent_01',
className => 'WebGUI::Asset::Wobject::Layout',
url => 'moveVersionToParent_01',
};
my $parentAsset = $defaultAsset->addChild( $properties, $properties->{id}, undef, { skipAutoCommitWorkflows => 1 } );
my $parentVersionTag = WebGUI::VersionTag->new($session, $parentAsset->tagId);
is( $parentVersionTag->get('isCommitted'), 0, 'built non-committed parent asset' );
my $versionTag6 = WebGUI::VersionTag->create( $session, {} );
$versionTag6->set( { name => 'move revision of uncommitted child to uncommitted parent tests vt2' } );
$versionTag6->setWorking;
$properties2 = {
# '1234567890123456789012'
id => 'moveVersionToParent_03',
title => 'moveVersionToParent_03',
className => 'WebGUI::Asset::Wobject::Layout',
url => 'moveVersionToParent_03',
};
my $childAsset = $parentAsset->addChild(
$properties2, $properties2->{id},
time(),
{ skipAutoCommitWorkflows => 1 }
);
my $testAsset = WebGUI::Asset->newPending( $session, $childAsset->parentId );
my $testVersionTag = WebGUI::VersionTag->new( $session, $testAsset->tagId );
my $childVersionTag;
$childVersionTag = WebGUI::VersionTag->new( $session, $childAsset->tagId );
is( $childVersionTag->get('isCommitted'), 0, 'built non-committed child asset' );
is( $testAsset->tagId,
$childAsset->tagId,
'uncommitted parent asset and uncommitted child asset have same version tag at addChild'
);
$properties2 = {
# '1234567890123456789012'
id => 'moveVersionToParent_03',
title => 'moveVersionToParent_03a',
className => 'WebGUI::Asset::Wobject::Layout',
url => 'moveVersionToParent_03a',
};
sleep 2;
$childAsset->addRevision( $properties2, time(), { skipAutoCommitWorkflows => 1 } );
is( $parentVersionTag->get('isCommitted'), 0, 'confimr non-committed parent asset after revision' );
is( $childVersionTag->get('isCommitted'), 0, 'confirm non-committed child asset after revision' );
is( $testAsset->get('tagId'),
$childAsset->get('tagId'),
'uncommitted parent asset and uncommitted child asset have same version tag after addRevision'
);
eval { $testVersionTag->commit; };
$session->log->warn('parent asset is now committed');
is( $testVersionTag->get('isCommitted'), 1, 'parent asset is now committed' );
$childVersionTag = WebGUI::VersionTag->new( $session, $childAsset->get('tagId') );
is( $childVersionTag->get('isCommitted'), 1, 'child asset is now committed' );
################################################################
#
# cloneFromDb
#
################################################################
my $assetToCommit = $defaultAsset->addChild({ className => 'WebGUI::Asset::Snippet', title => 'Snippet to commit and clone from db', });
my $cloneTag = WebGUI::VersionTag->getWorking($session);
my $assetToCommit = $defaultAsset->addChild({
className => 'WebGUI::Asset::Snippet',
title => 'Snippet to commit and clone from db',
status => "pending",
tagId => $cloneTag->getId,
});
addToCleanup($cloneTag);
$cloneTag->commit;
is($assetToCommit->get('status'), 'pending', 'cloneFromDb: local asset is still pending');
@ -847,10 +761,7 @@ my $trashedAsset = $defaultAsset->addChild({
my $clippedAsset = $defaultAsset->addChild({
className => 'WebGUI::Asset::Snippet', title => 'Clippy',
});
my $checkTag = WebGUI::VersionTag->getWorking($session);
$checkTag->commit;
addToCleanup($checkTag);
addToCleanup( $trashedAsset, $clippedAsset );
$trashedAsset = $trashedAsset->cloneFromDb;
$clippedAsset = $clippedAsset->cloneFromDb;
$trashedAsset->trash;

View file

@ -134,7 +134,11 @@ $tag->setWorking;
WebGUI::Test->addToCleanup($tag);
my $tempspace = WebGUI::Asset->getTempspace($session);
my $folder = {className => 'WebGUI::Asset::Wobject::Folder'};
my $folder = {
className => 'WebGUI::Asset::Wobject::Folder',
tagId => $tag->getId,
status => "pending",
};
my $root = $tempspace->addChild($folder);
my $child = $root->addChild($folder);
my $grandchild = $child->addChild($folder);
@ -175,13 +179,17 @@ my $versionTag2 = WebGUI::VersionTag->getWorking($session);
WebGUI::Test->addToCleanup($versionTag2);
my $page = $tempspace->addChild({
className => 'WebGUI::Asset::Wobject::Layout',
title => 'Parent asset',
className => 'WebGUI::Asset::Wobject::Layout',
title => 'Parent asset',
tagId => $versionTag2->getId,
status => "pending",
});
my $shortcut = $tempspace->addChild({
className => 'WebGUI::Asset::Shortcut',
shortcutToAssetId => $page->getId,
className => 'WebGUI::Asset::Shortcut',
shortcutToAssetId => $page->getId,
tagId => $versionTag2->getId,
status => "pending",
});
$versionTag2->commit;

View file

@ -170,16 +170,22 @@ my $parent = $importNode->addChild({
className => 'WebGUI::Asset::Wobject::Layout',
styleTemplateId => 'PBtmpl0000000000000132',
url => 'parent',
tagId => $versionTag->getId,
status => "pending",
});
my $firstChild = $parent->addChild({
className => 'WebGUI::Asset::Wobject::Layout',
styleTemplateId => 'PBtmpl0000000000000132',
url => 'first_child',
tagId => $versionTag->getId,
status => "pending",
});
my $grandChild = $firstChild->addChild({
className => 'WebGUI::Asset::Wobject::Article',
styleTemplateId => 'PBtmpl0000000000000132',
url => 'first_child/grand_child',
tagId => $versionTag->getId,
status => "pending",
});
$versionTag->commit;
@ -310,6 +316,8 @@ my $asset = $importNode->addChild($properties, $properties->{id});
$asset->update({
storageId => $storage->getId,
filename => $filename,
tagId => $versionTag->getId,
status => "pending",
});
my $fileAsPath = $asset->exportGetUrlAsPath('index.html');
@ -329,6 +337,8 @@ $properties = {
title => 'Export Test',
className => 'WebGUI::Asset::File',
url => 'export-test.foobar',
tagId => $versionTag->getId,
status => "pending",
};
$asset = $importNode->addChild($properties, $properties->{id});
$asset->update({

View file

@ -15,7 +15,7 @@ use WebGUI::Session;
use WebGUI::User;
use WebGUI::Asset;
use Test::More tests => 109; # increment this value for each test you create
use Test::More tests => 108; # increment this value for each test you create
use Test::Deep;
use Test::Exception;
use Data::Dumper;
@ -40,6 +40,8 @@ my $topFolder = $root->addChild({
menuTitle => 'topFolderMenuTitle',
groupIdEdit => 3,
className => 'WebGUI::Asset::Wobject::Folder',
tagId => $versionTag->getId,
status => "pending",
});
my $folder = $topFolder->addChild({
@ -48,6 +50,8 @@ my $folder = $topFolder->addChild({
menuTitle => 'folderMenuTitle',
groupIdEdit => 3,
className => 'WebGUI::Asset::Wobject::Folder',
tagId => $versionTag->getId,
status => "pending",
});
my $folder2 = $topFolder->addChild({
@ -55,6 +59,8 @@ my $folder2 = $topFolder->addChild({
title => 'folder2',
menuTitle => 'folder2MenuTitle',
className => 'WebGUI::Asset::Wobject::Folder',
tagId => $versionTag->getId,
status => "pending",
});
my $editor = WebGUI::User->new($session, 'new');
@ -71,6 +77,8 @@ foreach my $snipNum (0..6) {
title => "Snippet $snipNum",
menuTitle => $snipNum,
url => 'snippet'.$snipNum,
tagId => $versionTag->getId,
status => "pending",
});
}
@ -80,6 +88,8 @@ my $snippet2 = $folder2->addChild( {
ownerUserId => $editor->userId, #For coverage on addChild properties
title => "Snippet2 0",
menuTitle => 0,
tagId => $versionTag->getId,
status => "pending",
});
$versionTag->commit;
@ -665,6 +675,8 @@ WebGUI::Test->interceptLogging( sub {
ownerUserId => 3, #For coverage on addChild properties
title => "Deep Snippet $_",
menuTitle => "Deep Snip $_",
tagId => $vTag2->getId,
status => "pending",
});
}
@ -674,26 +686,6 @@ WebGUI::Test->interceptLogging( sub {
like($log_data->{warn}, qr/Adding it as a sibling instead/, 'addChild logged a warning about deep assets');
});
{
my $tag = WebGUI::VersionTag->getWorking($session);
addToCleanup($tag);
my $uncommittedParent = $root->addChild({
className => "WebGUI::Asset::Wobject::Layout",
groupIdView => 7,
ownerUserId => 3,
title => "Uncommitted Parent",
});
$tag->leaveTag;
my $parent = WebGUI::Asset->newPending($session, $uncommittedParent->getId);
my $floater = $parent->addChild({
className => "WebGUI::Asset::Snippet",
groupIdView => 7,
ownerUserId => 3, #For coverage on addChild properties
title => "Child of uncommitted parent",
});
is $parent->get('tagId'), $floater->get('tagId'), 'addChild: with uncommitted parent, adds child and puts it into the same tag as the parent';
}
TODO: {
local $TODO = "Tests to make later";
ok(0, 'addChild');

View file

@ -40,6 +40,8 @@ my $folder = $root->addChild({
menuTitle => 'folderMenuTitle',
className => 'WebGUI::Asset::Wobject::Folder',
isPackage => 1,
tagId => $versionTag->getId,
status => "pending",
}, undef, $time);
my $targetFolder = $root->addChild({
@ -47,6 +49,8 @@ my $targetFolder = $root->addChild({
title => 'Target Folder',
menuTitle => 'Target folderMenuTitle',
className => 'WebGUI::Asset::Wobject::Folder',
tagId => $versionTag->getId,
status => "pending",
});
my $subSnippet = $folder->addChild({
@ -55,6 +59,8 @@ my $subSnippet = $folder->addChild({
menuTitle => 'snippetMenuTitle',
className => 'WebGUI::Asset::Snippet',
snippet => 'A snippet of text',
tagId => $versionTag->getId,
status => "pending",
}, undef, $time);
my $snippet = $root->addChild({
@ -63,6 +69,8 @@ my $snippet = $root->addChild({
className => 'WebGUI::Asset::Snippet',
snippet => 'Always upgrade to the latest version',
isPackage => 1,
tagId => $versionTag->getId,
status => "pending",
}, undef, $time);
my $packageAssetId = $folder->getId;
@ -79,11 +87,15 @@ $versionTag->commit;
my $storage = $snippet->exportPackage();
isa_ok($storage, 'WebGUI::Storage', 'exportPackage returns a WebGUI::Storage object');
my $snippetRev = $snippet->addRevision({ snippet => 'Only upgrade existing data if revisionDate is newer' });
my $vt2 = WebGUI::VersionTag->getWorking($session);
my $snippetRev = $snippet->addRevision({
snippet => 'Only upgrade existing data if revisionDate is newer',
tagId => $vt2->getId,
status => "pending",
});
is($snippetRev->get('snippet'), 'Only upgrade existing data if revisionDate is newer', 'importPackage, overwriteLatest: precondition check, content');
cmp_ok( $snippetRev->get('revisionDate'), '>', $snippet->get('revisionDate'), '... precondition check, revisionDate');
my $vt2 = WebGUI::VersionTag->getWorking($session);
$vt2->commit;
WebGUI::Test->addToCleanup($vt2);
@ -103,10 +115,9 @@ is(scalar @{ $deployedFolderChildren }, 1, 'deployed package folder still has 1
isa_ok($deployedFolderChildren->[0] , 'WebGUI::Asset::Snippet', 'deployed child is a Snippet');
##Unset isPackage in this versionTag for the next tests
$folder->addRevision({isPackage => 0});
my $newVersionTag = WebGUI::VersionTag->getWorking($session);
WebGUI::Test->addToCleanup($newVersionTag);
$folder->addRevision({isPackage => 0, tagId => $newVersionTag->getId, status => "pending", });
$newVersionTag->commit;
my $newFolder = WebGUI::Asset->newById($session, $folder->getId);
@ -137,6 +148,8 @@ WebGUI::Test->addToCleanup($lastTag);
className => 'WebGUI::Asset::Snippet',
snippet => 'This is a test asset',
isPackage => 1,
tagId => $flagTag->getId,
status => "pending",
}
);
my $storage = $snippet->exportPackage;

View file

@ -24,9 +24,16 @@ my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Adding Calendar for Event Asset Test"});
WebGUI::Test->addToCleanup($versionTag);
my $defaultAsset = WebGUI::Asset->getDefault($session);
my $cal = $defaultAsset->addChild({className=>'WebGUI::Asset::Wobject::Calendar'});
my $cal = $defaultAsset->addChild({
className=>'WebGUI::Asset::Wobject::Calendar',
tagId => $versionTag->getId,
status => "pending",
});
$versionTag->commit;
my $versionTag2 = WebGUI::VersionTag->getWorking($session);
WebGUI::Test->addToCleanup($versionTag2);
my $properties = {
# '1234567890123456789012'
id => 'EventAssetTest00000001',
@ -39,6 +46,8 @@ my $properties = {
endTime => '03:00:00',
timeZone => 'America/Chicago',
location => 'Madison, Wisconsin',
tagId => $versionTag->getId,
status => "pending",
};
my $event = $cal->addChild($properties, $properties->{id});
@ -125,9 +134,6 @@ my $event6a = $event6->addRevision({ title => 'Event with storage', }, undef, {
ok($session->id->valid($event6a->get('storageId')), 'addRevision gives the new revision a valid storageId');
isnt($event6a->get('storageId'), $event6->get('storageId'), '... and it is different from the previous revision');
my $versionTag2 = WebGUI::VersionTag->getWorking($session);
WebGUI::Test->addToCleanup($versionTag2);
my $event7 = $cal->addChild({
className => 'WebGUI::Asset::Event',
startDate => '2000-08-31',

View file

@ -79,9 +79,11 @@ my $instance = WebGUI::Workflow::Instance->create(
);
my $count = 0;
while (my $status = $instance->run ne 'complete') {
note $status;
$instance->run;
last if $count++ > 30;
}
my $sql = q{