Merge commit '17ce3572bf' into WebGUI8. All tests passing.
This commit is contained in:
commit
5e502fee53
117 changed files with 2012 additions and 1027 deletions
|
|
@ -74,6 +74,7 @@ my $workflow = WebGUI::Workflow->create($session,
|
|||
mode => 'realtime',
|
||||
},
|
||||
);
|
||||
WebGUI::Test->addToCleanup($workflow);
|
||||
my $icalFetch = $workflow->addActivity('WebGUI::Workflow::Activity::CalendarUpdateFeeds');
|
||||
|
||||
my $instance1 = WebGUI::Workflow::Instance->create($session,
|
||||
|
|
@ -127,8 +128,4 @@ is(scalar @{ $newEvents }, 1, 'reimport does not create new children');
|
|||
$anniversary = pop @{ $newEvents };
|
||||
is($anniversary->get('description'), $party->get('description'), '... description, checks for line unwrapping');
|
||||
|
||||
END {
|
||||
$instance1 && $instance1->delete('skipNotify');
|
||||
$instance2 && $instance2->delete('skipNotify');
|
||||
$workflow && $workflow->delete;
|
||||
}
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ my $workflow = WebGUI::Workflow->create($session,
|
|||
mode => 'realtime',
|
||||
},
|
||||
);
|
||||
WebGUI::Test->addToCleanup($workflow);
|
||||
my $activity = $workflow->addActivity('WebGUI::Workflow::Activity::DeleteExpiredSessions');
|
||||
|
||||
my $instance1 = WebGUI::Workflow::Instance->create($session,
|
||||
|
|
@ -52,9 +53,6 @@ my $origSessionTimeout = $session->setting->get('sessionTimeout');
|
|||
my $sessionCount = $session->db->quickScalar('select count(*) from userSession');
|
||||
my $scratchCount = $session->db->quickScalar('select count(*) from userSessionScratch');
|
||||
|
||||
note $sessionCount;
|
||||
note $scratchCount;
|
||||
|
||||
my @sessions;
|
||||
|
||||
foreach (1..2) {
|
||||
|
|
@ -113,6 +111,4 @@ foreach my $testSession (@sessions) {
|
|||
## Make sure that one scratch session was deleted and the other kept.
|
||||
## Close and end all four sessions
|
||||
|
||||
END {
|
||||
$workflow->delete;
|
||||
}
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -158,7 +158,4 @@ is($session->db->quickScalar('select count(*) from Survey_response where Survey_
|
|||
# Afterwards, back to no incomplete responses
|
||||
is( scalar $session->db->buildArray($SQL), 0, 'Afterwards, back to no incomplete responses');
|
||||
|
||||
END {
|
||||
$session->db->write('delete from Survey_response where userId = ?', [$user->userId]) if $user;
|
||||
$survey->purge if $survey;
|
||||
}
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -23,11 +23,13 @@ use Test::More;
|
|||
use Test::Exception;
|
||||
use URI;
|
||||
|
||||
plan tests => 20; # increment this value for each test you create
|
||||
plan tests => 19; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
$session->user({userId => 3});
|
||||
my $admin = $session->user;
|
||||
WebGUI::Test->addToCleanup(sub { WebGUI::Test->cleanupAdminInbox; });
|
||||
WebGUI::Test->addToCleanup(SQL => "delete from mailQueue where message like '%Threshold=15%'");
|
||||
my $inbox = WebGUI::Inbox->new($session);
|
||||
|
||||
my $import = WebGUI::Asset->getImportNode($session);
|
||||
|
|
@ -122,7 +124,7 @@ my $uri = URI->new($url);
|
|||
is($uri->path, $posters->getUrl, 'Link in message has correct URL path');
|
||||
is($uri->query, 'func=editVariant;vid='.$marilynVarId, 'Link in message has function and variant id');
|
||||
|
||||
wipeMessages($inbox, $admin);
|
||||
WebGUI::Test->cleanupAdminInbox;
|
||||
is(scalar @{$inbox->getMessagesForUser($admin)}, 0, 'All messages deleted');
|
||||
$instance1->delete;
|
||||
|
||||
|
|
@ -148,6 +150,13 @@ $message = $inbox->getMessagesForUser($admin)->[0];
|
|||
note "Test that the workflow does not die when encountering bad assets";
|
||||
|
||||
my $otherPosters = $posters->duplicate;
|
||||
WebGUI::Test->addToCleanup(sub {
|
||||
$session->db->write("delete from asset where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from assetData where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from sku where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from Product where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from assetIndex where assetId=?",[$otherPosters->getId]);
|
||||
});
|
||||
my $movie_posters = $import->addChild({
|
||||
className => 'WebGUI::Asset::Sku::Product',
|
||||
url => 'movie_posters',
|
||||
|
|
@ -181,7 +190,7 @@ is($retVal, 'done', 'Workflow is done');
|
|||
|
||||
$messages = $inbox->getMessagesForUser($admin);
|
||||
is(scalar @{$messages}, 1, 'Received one message');
|
||||
wipeMessages($inbox, $admin);
|
||||
WebGUI::Test->cleanupAdminInbox;
|
||||
|
||||
my $instance4 = WebGUI::Workflow::Instance->create($session,
|
||||
{
|
||||
|
|
@ -200,24 +209,5 @@ is($retVal, 'done', 'Workflow is done');
|
|||
|
||||
$messages = $inbox->getMessagesForUser($admin);
|
||||
is(scalar @{$messages}, 1, 'Still received one message');
|
||||
wipeMessages($inbox, $admin);
|
||||
|
||||
END {
|
||||
wipeMessages($inbox, $admin);
|
||||
$messages = $inbox->getMessagesForUser($admin);
|
||||
is(scalar @{$messages}, 0, 'Inbox cleaned up');
|
||||
$session->db->write("delete from mailQueue where message like '%Threshold=15%'");
|
||||
$session->db->write("delete from asset where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from assetData where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from sku where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from Product where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from assetIndex where assetId=?",[$otherPosters->getId]);
|
||||
}
|
||||
|
||||
sub wipeMessages {
|
||||
my ($inbox, $user) = @_;
|
||||
foreach my $message (@{ $inbox->getMessagesForUser($user) }) {
|
||||
$message->delete;
|
||||
}
|
||||
|
||||
}
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
103
t/Workflow/Activity/TrashExpiredEvents.t
Normal file
103
t/Workflow/Activity/TrashExpiredEvents.t
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Workflow::Activity::TrashExpiredEvents;
|
||||
use WebGUI::Asset;
|
||||
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
|
||||
plan tests => 5; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
$session->user({userId => 3});
|
||||
|
||||
my $bday = WebGUI::DateTime->new($session, WebGUI::Test->webguiBirthday)->cloneToUserTimeZone;
|
||||
my $now = WebGUI::DateTime->new($session, time())->cloneToUserTimeZone;
|
||||
my $tz = $session->datetime->getTimeZone();
|
||||
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
my $calendar = $root->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Calendar',
|
||||
title => 'Test Calendar',
|
||||
});
|
||||
my $wgBday = $calendar->addChild({
|
||||
className => 'WebGUI::Asset::Event',
|
||||
title => 'WebGUI Birthday',
|
||||
startDate => $bday->toDatabaseDate,
|
||||
endDate => $bday->toDatabaseDate,
|
||||
timeZone => $tz,
|
||||
}, undef, undef, {skipAutoCommitWorkflows => 1});
|
||||
|
||||
my $wrongBday = $calendar->addChild({
|
||||
className => 'WebGUI::Asset::Event',
|
||||
title => 'Wrong Birthday',
|
||||
startDate => $bday->toDatabaseDate,
|
||||
endDate => $bday->toDatabaseDate,
|
||||
timeZone => $tz,
|
||||
}, undef, time()-5, {skipAutoCommitWorkflows => 1});
|
||||
|
||||
$wrongBday->addRevision({
|
||||
startDate => $now->toDatabaseDate,
|
||||
endDate => $now->toDatabaseDate,
|
||||
}, undef, undef, {skipAutoCommitWorkflows => 1});
|
||||
|
||||
my $nowEvent = $calendar->addChild({
|
||||
className => 'WebGUI::Asset::Event',
|
||||
title => 'WebGUI Birthday',
|
||||
startDate => $now->toDatabaseDate,
|
||||
endDate => $now->toDatabaseDate,
|
||||
timeZone => $tz,
|
||||
}, undef, undef, {skipAutoCommitWorkflows => 1});
|
||||
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
$tag->commit;
|
||||
WebGUI::Test->addToCleanup($tag);
|
||||
|
||||
my $workflow = WebGUI::Workflow->create($session,
|
||||
{
|
||||
enabled => 1,
|
||||
objectType => 'None',
|
||||
mode => 'realtime',
|
||||
},
|
||||
);
|
||||
WebGUI::Test->addToCleanup($workflow);
|
||||
my $eventNuker = $workflow->addActivity('WebGUI::Workflow::Activity::TrashExpiredEvents');
|
||||
$eventNuker->set('trashAfter', 3600);
|
||||
|
||||
my $instance1 = WebGUI::Workflow::Instance->create($session,
|
||||
{
|
||||
workflowId => $workflow->getId,
|
||||
skipSpectreNotification => 1,
|
||||
}
|
||||
);
|
||||
|
||||
my $retVal;
|
||||
|
||||
$retVal = $instance1->run();
|
||||
is($retVal, 'complete', 'cleanup: activity complete');
|
||||
$retVal = $instance1->run();
|
||||
is($retVal, 'done', 'cleanup: activity is done');
|
||||
$instance1->delete('skipNotify');
|
||||
|
||||
my $wgBdayCopy = $wgBday->cloneFromDb;
|
||||
my $nowEventCopy = $nowEvent->cloneFromDb;
|
||||
my $wrongBdayCopy = $wrongBday->cloneFromDb;
|
||||
|
||||
is $wgBdayCopy->get('state'), 'trash', 'old event was trashed';
|
||||
is $nowEventCopy->get('state'), 'published', 'recent event was left alone';
|
||||
is $wrongBdayCopy->get('state'), 'published', 'revisioned event was left alone';
|
||||
Loading…
Add table
Add a link
Reference in a new issue