fixed bug #11052; includes test
This commit is contained in:
parent
d088386e2c
commit
4583ce14fb
2 changed files with 46 additions and 5 deletions
|
|
@ -267,8 +267,14 @@ Return the largest of either the asset revision date, or the shortcut revision d
|
|||
sub getContentLastModified {
|
||||
my $self = shift;
|
||||
my $assetRev = $self->get('revisionDate');
|
||||
my $shortcuttedRev = $self->getShortcut->get('revisionDate');
|
||||
return $assetRev > $shortcuttedRev ? $assetRev : $shortcuttedRev;
|
||||
my $shortcut = $self->getShortcut;
|
||||
my $shortcuttedRev;
|
||||
if (defined $shortcut) {
|
||||
$shortcuttedRev = $shortcut->get('revisionDate');
|
||||
return $assetRev > $shortcuttedRev ? $assetRev : $shortcuttedRev;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ END {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 9;
|
||||
plan tests => 10;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test shortcut's link to original asset
|
||||
|
|
@ -106,6 +106,42 @@ ok(
|
|||
"Restore Linked Asset: Shortcut is not in trash",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test purging snippet but keeping shortcut doesn't cause
|
||||
# getContentLastModified to generate an error; makes sure that
|
||||
# http://www.webgui.org/use/bugs/tracker/11052 stays fixed.
|
||||
$session->db->beginTransaction();
|
||||
$session->db->write("delete from assetData where assetId = ?",
|
||||
[$snippet->getId]);
|
||||
$session->db->write("delete from asset where assetId = ?",
|
||||
[$snippet->getId]);
|
||||
$session->db->write("delete from snippet where assetId = ?",
|
||||
[$snippet->getId]);
|
||||
$session->db->commit();
|
||||
|
||||
my $contentLastModified;
|
||||
eval {
|
||||
$contentLastModified = $shortcut->getContentLastModified();
|
||||
};
|
||||
|
||||
is(
|
||||
$contentLastModified, 0,
|
||||
"Purged Linked Asset: getContentLastModified returns 0",
|
||||
);
|
||||
|
||||
# re-init so further tests will work
|
||||
$snippet
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Snippet",
|
||||
});
|
||||
|
||||
$shortcut
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Shortcut",
|
||||
shortcutToAssetId => $snippet->getId,
|
||||
});
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test purging snippet purges shortcut also
|
||||
$snippet->purge;
|
||||
|
|
@ -114,5 +150,4 @@ $shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
|||
ok(
|
||||
!defined $shortcut,
|
||||
"Purge Linked Asset: Shortcut is not defined",
|
||||
);
|
||||
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue