When purging an asset, clean up all version tags for this asset, which may
contain only this asset. Fixes #10872
This commit is contained in:
parent
2703deba2e
commit
d8ae7fc68e
3 changed files with 65 additions and 15 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
7.7.19
|
7.7.19
|
||||||
|
- fixed #10872: Purging an asset leaves old version tags
|
||||||
- fixed #10867: EMS: can't set Ticket time
|
- fixed #10867: EMS: can't set Ticket time
|
||||||
- fixed #10855: Bug in submitting data to ITransact
|
- fixed #10855: Bug in submitting data to ITransact
|
||||||
- fixed #10868: EMS Schedule screen won't display
|
- fixed #10868: EMS Schedule screen won't display
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,7 @@ sub purge {
|
||||||
}
|
}
|
||||||
|
|
||||||
# gonna need this at the end
|
# gonna need this at the end
|
||||||
|
my $tags = $session->db->buildArrayRef('select tagId from assetData where assetId=?',[$self->getId]);
|
||||||
my $tagId = $self->get("tagId");
|
my $tagId = $self->get("tagId");
|
||||||
|
|
||||||
# clean up keywords
|
# clean up keywords
|
||||||
|
|
@ -208,10 +209,13 @@ sub purge {
|
||||||
$self = undef;
|
$self = undef;
|
||||||
|
|
||||||
# clean up version tag if empty
|
# clean up version tag if empty
|
||||||
my $versionTag = WebGUI::VersionTag->new($session, $tagId);
|
foreach my $tagId (@{ $tags }) {
|
||||||
if ($versionTag && $versionTag->getAssetCount == 0) {
|
my $versionTag = WebGUI::VersionTag->new($session, $tagId);
|
||||||
$versionTag->rollback;
|
if ($versionTag && $versionTag->getAssetCount == 0) {
|
||||||
|
$versionTag->rollback;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,25 +20,35 @@ use WebGUI::Session;
|
||||||
use WebGUI::Utility;
|
use WebGUI::Utility;
|
||||||
use WebGUI::Asset::Template;
|
use WebGUI::Asset::Template;
|
||||||
use Test::More; # increment this value for each test you create
|
use Test::More; # increment this value for each test you create
|
||||||
plan tests => 17;
|
plan tests => 26;
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
my $propertyHash = {
|
my $propertyHash = {
|
||||||
template => q!Hi, I'm a template!,
|
template => "Hi, I'm a template",
|
||||||
url => '/template/versionTest',
|
url => '/template/versionTest',
|
||||||
title => 'Version Test Template',
|
title => 'Version Test Template',
|
||||||
menuTitle => 'Version Test Template',
|
menuTitle => 'Version Test Template',
|
||||||
namespace => 'Article',
|
namespace => 'Article',
|
||||||
className => 'WebGUI::Asset::Template',
|
className => 'WebGUI::Asset::Template',
|
||||||
};
|
};
|
||||||
|
|
||||||
my $root = WebGUI::Asset->getRoot($session);
|
my $root = WebGUI::Asset->getRoot($session);
|
||||||
|
|
||||||
|
my $originalVersionTags = $session->db->quickScalar(q{select count(*) from assetVersionTag});
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
#
|
||||||
|
# purgeRevision
|
||||||
|
#
|
||||||
|
################################################################
|
||||||
|
|
||||||
|
diag "purgeRevision tests";
|
||||||
my $template = $root->addChild($propertyHash);
|
my $template = $root->addChild($propertyHash);
|
||||||
$template->commit;
|
$template->commit;
|
||||||
|
|
||||||
is (ref $template, "WebGUI::Asset::Template", "Template Asset created");
|
is (ref $template, "WebGUI::Asset::Template", "Template Asset created");
|
||||||
checkTableEntries($template->getId, 1,1,1);
|
checkTableEntries($template->getId, 1,1,1,1);
|
||||||
|
|
||||||
sleep 1;
|
sleep 1;
|
||||||
|
|
||||||
|
|
@ -46,11 +56,11 @@ my $templatev2 = $template->addRevision({template => 'Hello, I am a template wit
|
||||||
$templatev2->commit;
|
$templatev2->commit;
|
||||||
|
|
||||||
is ($templatev2->getId, $template->getId, 'Both versions of the asset have the same assetId');
|
is ($templatev2->getId, $template->getId, 'Both versions of the asset have the same assetId');
|
||||||
checkTableEntries($templatev2->getId, 1,2,2);
|
checkTableEntries($templatev2->getId, 1,2,2,1);
|
||||||
|
|
||||||
$templatev2->purgeRevision;
|
$templatev2->purgeRevision;
|
||||||
|
|
||||||
checkTableEntries($templatev2->getId, 1,1,1);
|
checkTableEntries($templatev2->getId, 1,1,1,1);
|
||||||
|
|
||||||
undef $templatev2;
|
undef $templatev2;
|
||||||
|
|
||||||
|
|
@ -59,22 +69,57 @@ $templatev2a->commit;
|
||||||
|
|
||||||
$template->purgeRevision;
|
$template->purgeRevision;
|
||||||
|
|
||||||
checkTableEntries($template->getId, 1,1,1);
|
checkTableEntries($template->getId, 1,1,1,1);
|
||||||
|
|
||||||
$template->purgeRevision;
|
$template->purgeRevision;
|
||||||
checkTableEntries($template->getId, 0,0,0);
|
checkTableEntries($template->getId, 0,0,0,0);
|
||||||
|
|
||||||
|
my $versionTagCheck;
|
||||||
|
$versionTagCheck = $session->db->quickScalar(q{select count(*) from assetVersionTag});
|
||||||
|
is($versionTagCheck, $originalVersionTags, 'version tag cleaned up by deleting last version');
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
#
|
||||||
|
# purge
|
||||||
|
#
|
||||||
|
################################################################
|
||||||
|
|
||||||
|
$template = $root->addChild($propertyHash);
|
||||||
|
my $tag1 = WebGUI::VersionTag->getWorking($session);
|
||||||
|
$tag1->commit;
|
||||||
|
WebGUI::Test->tagsToRollback($tag1);
|
||||||
|
sleep 1;
|
||||||
|
$templatev2 = $template->addRevision({template => 'Vie gates. Ich bin ein templater.'});
|
||||||
|
my $tag2 = WebGUI::VersionTag->getWorking($session);
|
||||||
|
$tag2->commit;
|
||||||
|
WebGUI::Test->tagsToRollback($tag2);
|
||||||
|
diag "purge";
|
||||||
|
checkTableEntries($templatev2->getId, 1,2,2);
|
||||||
|
$versionTagCheck = $session->db->quickScalar(q{select count(*) from assetVersionTag});
|
||||||
|
is($versionTagCheck, $originalVersionTags+2, 'created two version tags');
|
||||||
|
|
||||||
|
$template->purge;
|
||||||
|
checkTableEntries($templatev2->getId, 0,0,0);
|
||||||
|
$versionTagCheck = $session->db->quickScalar(q{select count(*) from assetVersionTag});
|
||||||
|
is($versionTagCheck, $originalVersionTags, 'purge deleted both tags');
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
#
|
||||||
|
# Utility routines
|
||||||
|
#
|
||||||
|
################################################################
|
||||||
|
|
||||||
sub checkTableEntries {
|
sub checkTableEntries {
|
||||||
my ($assetId, $assetNum, $assetDataNum, $templateNum) = @_;
|
my ($assetId, $assetNum, $assetDataNum, $templateNum) = @_;
|
||||||
my ($count) = $session->db->quickArray('select COUNT(assetId) from asset where assetId=?', [$assetId]);
|
my ($count) = $session->db->quickArray('select COUNT(*) from asset where assetId=?', [$assetId]);
|
||||||
is ($count, $assetNum,
|
is ($count, $assetNum,
|
||||||
sprintf 'Expecting %d Assets with that id in asset', $assetNum);
|
sprintf 'Expecting %d Assets with that id in asset', $assetNum);
|
||||||
|
|
||||||
($count) = $session->db->quickArray('select COUNT(assetId) from assetData where assetId=?', [$assetId]);
|
($count) = $session->db->quickArray('select COUNT(*) from assetData where assetId=?', [$assetId]);
|
||||||
is ($count, $assetDataNum,
|
is ($count, $assetDataNum,
|
||||||
sprintf 'Expecting %d Assets with that id in assetData', $assetDataNum);
|
sprintf 'Expecting %d Assets with that id in assetData', $assetDataNum);
|
||||||
|
|
||||||
($count) = $session->db->quickArray('select COUNT(assetId) from template where assetId=?', [$assetId]);
|
($count) = $session->db->quickArray('select COUNT(*) from template where assetId=?', [$assetId]);
|
||||||
is ($count, $templateNum,
|
is ($count, $templateNum,
|
||||||
sprintf 'Expecting %d Assets with that id in template', $templateNum);
|
sprintf 'Expecting %d Assets with that id in template', $templateNum);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue