remove duplicate code in addUsers, add more tests to Group.t to cover
This commit is contained in:
parent
b24bd78e8d
commit
ec3eebda9b
2 changed files with 16 additions and 2 deletions
|
|
@ -163,7 +163,6 @@ sub addUsers {
|
|||
$self->clearCaches();
|
||||
my $expireOffset = shift || $self->get("expireOffset");
|
||||
foreach my $uid (@{$users}) {
|
||||
next if ($uid eq '1' and !isIn($self->getId, 1, 7));
|
||||
my ($isIn) = $self->session->db->quickArray("select count(*) from groupings where groupId=? and userId=?", [$self->getId, $uid]);
|
||||
unless ($isIn) {
|
||||
$self->session->db->write("insert into groupings (groupId,userId,expireDate) values (?,?,?)", [$self->getId, $uid, ($self->session->datetime->time()+$expireOffset)]);
|
||||
|
|
|
|||
17
t/Group.t
17
t/Group.t
|
|
@ -75,7 +75,7 @@ my @ipTests = (
|
|||
);
|
||||
|
||||
|
||||
plan tests => (137 + scalar(@scratchTests) + scalar(@ipTests)); # increment this value for each test you create
|
||||
plan tests => (138 + scalar(@scratchTests) + scalar(@ipTests)); # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
my $testCache = WebGUI::Cache->new($session, 'myTestKey');
|
||||
|
|
@ -321,6 +321,12 @@ $user->delete;
|
|||
|
||||
##Build a group of users and add them to various groups to test fetching users
|
||||
|
||||
################################################################
|
||||
#
|
||||
# addUser
|
||||
#
|
||||
################################################################
|
||||
|
||||
my @crowd = map { WebGUI::User->new($session, "new") } 0..7;
|
||||
my @mob;
|
||||
foreach my $idx (0..2) {
|
||||
|
|
@ -348,6 +354,15 @@ cmp_bag($gA->getAllUsers(), [@aUsers, @zUsers, 3], 'users in group A, recursivel
|
|||
cmp_bag($gC->getAllUsers(), [@cUsers, 3], 'users in group C, recursively');
|
||||
cmp_bag($gZ->getAllUsers(), [@zUsers, 3], 'users in group Z, recursively');
|
||||
|
||||
##User and Group specific addUser tests
|
||||
|
||||
my $visitorUser = WebGUI::User->new($session, 1);
|
||||
|
||||
my $everyoneGroup = WebGUI::Group->new($session, 7);
|
||||
my $everyUsers = $everyoneGroup->getUsers();
|
||||
$everyoneGroup->addUsers([$visitorUser->userId]);
|
||||
cmp_bag($everyUsers, $everyoneGroup->getUsers(), 'addUsers will not add a user to a group they already belong to');
|
||||
|
||||
##Database based user membership in groups
|
||||
|
||||
$session->db->dbh->do('DROP TABLE IF EXISTS myUserTable');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue