Fix cleanup of Inbox messages for users. Provide a method for cleaning up Admin's messages.

This commit is contained in:
Colin Kuskie 2010-06-09 17:23:42 -07:00
parent 8edcab37a6
commit 53721581a1
3 changed files with 24 additions and 3 deletions

View file

@ -146,10 +146,11 @@ sub deleteMessagesForUser {
my $self = shift;
my $user = shift;
my $db = $self->session->db;
my $messages = $self->getMessagesForUser($user, 1e10);
my $userId = $user->userId;
$db->write("DELETE FROM inbox_messageState WHERE userId=?",[$userId]);
$db->write("DELETE FROM inbox WHERE userId=? AND (groupId IS NULL OR groupId='')",[$userId]);
foreach my $message (@{ $messages }) {
$message->delete($userId);
}
}
#-------------------------------------------------------------------

View file

@ -267,6 +267,7 @@ $templateMock->mock('process', sub { push @templateVars, clone $_[1]; } );
$session->setting->set('shopReceiptEmailTemplateId', $templateId);
{
WebGUI::Test->addToCleanup(sub { WebGUI::Test->cleanupAdminInbox(); });
WebGUI::Test->mockAssetId($templateId, $templateMock);
$trans->sendNotifications;
is(@templateVars, 2, '... called template->process twice');

View file

@ -697,6 +697,25 @@ sub assetsToPurge {
#----------------------------------------------------------------------------
=head2 cleanupAdminInbox ( )
Push a list of Asset objects onto the stack of assets to be automatically purged
at the end of the test. This will also clean-up all version tags associated
with the Asset.
This is a class method.
=cut
sub cleanupAdminInbox {
my $class = shift;
my $admin = WebGUI::User->new($class->session, '3');
my $inbox = WebGUI::Inbox->new($class->session);
$inbox->deleteMessagesForUser($admin);
}
#----------------------------------------------------------------------------
=head2 groupsToDelete ( $group, [$group ] )
Push a list of group objects onto the stack of groups to be automatically deleted