Add a workflow activity that reverifies that all subscribers to a CS can still view the CS, otherwise, remove them. Hook up the workflow to the update method in Collaboriation.pm and create an instance for it if the groupIdView changes. Add tests for the activity. Add a new workflow. Update the default WebGUI.conf.
This commit is contained in:
parent
e2115411b5
commit
dd7e6016dc
9 changed files with 253 additions and 2 deletions
|
|
@ -48,7 +48,7 @@ is_deeply($wf->getCrons, [], 'workflow has no crons');
|
|||
isa_ok(WebGUI::Workflow->getList($session), 'HASH', 'getList returns a hashref');
|
||||
|
||||
ok(!isIn($wfId, keys %{WebGUI::Workflow->getList($session)}), 'workflow not in enabled list');
|
||||
is(scalar keys %{WebGUI::Workflow->getList($session)}, 12, 'There are twelve enabled, default workflows, of all types, shipped with WebGUI');
|
||||
is(scalar keys %{WebGUI::Workflow->getList($session)}, 13, 'There are twelve enabled, default workflows, of all types, shipped with WebGUI');
|
||||
|
||||
$wf->set({enabled => 1});
|
||||
ok($wf->get('enabled'), 'workflow is enabled');
|
||||
|
|
|
|||
86
t/Workflow/Activity/UpdateAssetSubscribers.t
Normal file
86
t/Workflow/Activity/UpdateAssetSubscribers.t
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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::UpdateAssetSubscribers;
|
||||
use WebGUI::Asset;
|
||||
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
|
||||
plan tests => 4; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
$session->user({userId => 3});
|
||||
|
||||
my $subscriberGroup = WebGUI::Group->new($session, "new"); ##Group to hold subscribers
|
||||
my $oldGroup = WebGUI::Group->new($session, "new"); ##Pretend group, old groupIdView
|
||||
my $betterGroup = WebGUI::Group->new($session, "new"); ##New group for groupIdView
|
||||
my $oldUser = WebGUI::User->create($session); ##User who should be unsubscribed
|
||||
my $betterUser = WebGUI::User->create($session); ##User who should remain subscribed
|
||||
my $otherUser = WebGUI::User->create($session); ##Just a user, we should never see him
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
my $cs = $root->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Collaboration',
|
||||
title => 'Test Calendar',
|
||||
subscriptionGroupId => $subscriberGroup->getId,
|
||||
groupIdView => $betterGroup->getId,
|
||||
});
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
$tag->commit;
|
||||
WebGUI::Test->addToCleanup($tag, $subscriberGroup, $betterGroup, $oldUser, $betterUser, $otherUser);
|
||||
|
||||
$subscriberGroup->addUsers([$oldUser->getId, $betterUser->getId, ]);
|
||||
$betterGroup->addUsers([$betterUser->getId, ]);
|
||||
|
||||
##Plan, since spectre isn't running, we manually simulate an update event and run the
|
||||
##workflow activity by hand.
|
||||
|
||||
cmp_bag(
|
||||
$subscriberGroup->getUsers,
|
||||
[$oldUser->getId, $betterUser->getId],
|
||||
'Initial subscribers are correct'
|
||||
);
|
||||
|
||||
##This workflowId needs to exist, since it's hardcoded in the CS asset
|
||||
my $workflow = WebGUI::Workflow->new($session, 'xR-_GRRbjBojgLsFx3dEMA');
|
||||
|
||||
my $instance1 = WebGUI::Workflow::Instance->create($session,
|
||||
{
|
||||
workflowId => $workflow->getId,
|
||||
skipSpectreNotification => 1,
|
||||
className => 'WebGUI::Asset',
|
||||
methodName => 'newByDynamicClass',
|
||||
parameters => $cs->getId,
|
||||
}
|
||||
);
|
||||
WebGUI::Test->addToCleanup($instance1);
|
||||
|
||||
my $retVal;
|
||||
|
||||
$retVal = $instance1->run();
|
||||
is($retVal, 'complete', 'cleanup: activity complete');
|
||||
$retVal = $instance1->run();
|
||||
is($retVal, 'done', 'cleanup: activity is done');
|
||||
$instance1->delete('skipNotify');
|
||||
|
||||
$subscriberGroup->clearCaches;
|
||||
|
||||
cmp_bag(
|
||||
$subscriberGroup->getUsers,
|
||||
[$betterUser->getId],
|
||||
'Corrent user removed'
|
||||
);
|
||||
|
|
@ -835,6 +835,7 @@ Example call:
|
|||
pbworkflow000000000006
|
||||
pbworkflow000000000007
|
||||
send_webgui_statistics
|
||||
xR-_GRRbjBojgLsFx3dEMA
|
||||
};
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue