fixed bug where shortcuts weren't purged along with assets when both were in the trash
This commit is contained in:
parent
4583ce14fb
commit
4d22e7bcd6
3 changed files with 42 additions and 24 deletions
|
|
@ -1288,6 +1288,8 @@ sub getShortcutsForAssetId {
|
|||
|
||||
$properties->{ joinClass } = 'WebGUI::Asset::Shortcut';
|
||||
$properties->{ whereClause } = 'Shortcut.shortcutToAssetId = ' . $db->quote($assetId);
|
||||
$properties->{ statesToInclude } = ['published', 'trash', 'clipboard', 'clipboard-limbo', 'trash-limbo'];
|
||||
$properties->{ statusToInclude } = ['approved', 'pending', 'archived'];
|
||||
|
||||
return WebGUI::Asset->getRoot($session)->getLineage(['descendants'], $properties);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ sub purge {
|
|||
}
|
||||
|
||||
# Delete shortcuts to this asset
|
||||
# Also publish any shortcuts to this asset that are in the trash
|
||||
# Also purge any shortcuts to this asset that are in the trash
|
||||
$outputSub->($i18n->get('Purging shortcuts'));
|
||||
my $shortcuts
|
||||
= WebGUI::Asset::Shortcut->getShortcutsForAssetId($self->session, $self->getId, {
|
||||
|
|
|
|||
|
|
@ -29,17 +29,9 @@ my $node = WebGUI::Asset->getImportNode($session);
|
|||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Shortcut Test"});
|
||||
|
||||
# Make a snippet to shortcut
|
||||
my $snippet
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Snippet",
|
||||
});
|
||||
|
||||
my $shortcut
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Shortcut",
|
||||
shortcutToAssetId => $snippet->getId,
|
||||
});
|
||||
my $snippet;
|
||||
my $shortcut;
|
||||
init();
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
|
|
@ -50,7 +42,7 @@ END {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 10;
|
||||
plan tests => 11;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test shortcut's link to original asset
|
||||
|
|
@ -126,21 +118,28 @@ eval {
|
|||
|
||||
is(
|
||||
$contentLastModified, 0,
|
||||
"Purged Linked Asset: getContentLastModified returns 0",
|
||||
"Purged Linked Asset: getContentLastModified returns 0 when linked asset missing",
|
||||
);
|
||||
|
||||
# re-init so further tests will work
|
||||
$snippet
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Snippet",
|
||||
});
|
||||
init();
|
||||
|
||||
$shortcut
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Shortcut",
|
||||
shortcutToAssetId => $snippet->getId,
|
||||
});
|
||||
#----------------------------------------------------------------------------
|
||||
# Test purging snippet purges shortcut also, even when they're both in the trash
|
||||
|
||||
# This will trash both the snippet and the shortcut (or else an earlier test failed)
|
||||
$snippet->trash();
|
||||
|
||||
$snippet->purge();
|
||||
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
||||
|
||||
ok(
|
||||
!defined $shortcut,
|
||||
"Purge Linked Asset: Shortcut is purged even though it's in the trash"
|
||||
);
|
||||
|
||||
# re-init so further tests will work
|
||||
init();
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test purging snippet purges shortcut also
|
||||
|
|
@ -150,4 +149,21 @@ $shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
|||
ok(
|
||||
!defined $shortcut,
|
||||
"Purge Linked Asset: Shortcut is not defined",
|
||||
);
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# init a new snippet and shortcut; handy to have in a sub because we destroy
|
||||
# them in some tests and need to reset them for the next round
|
||||
sub init {
|
||||
# Make a snippet to shortcut
|
||||
$snippet
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Snippet",
|
||||
});
|
||||
|
||||
$shortcut
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Shortcut",
|
||||
shortcutToAssetId => $snippet->getId,
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue