From 867095d8117eba16debe5917e0577f17e00f6f57 Mon Sep 17 00:00:00 2001 From: Scott Walters Date: Tue, 8 Jun 2010 13:49:02 -0400 Subject: [PATCH] A user removed from a group with deleteUsers() will still appear to be in that group according to Inbox.pm, User::getGroupIdsRecursive() and User::getGroups(). Groups.pm wasn't clearing the cache key "getGroupsForUser" in clearCaches(). Tests and fix. --- lib/WebGUI/Group.pm | 1 + t/Group.t | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/WebGUI/Group.pm b/lib/WebGUI/Group.pm index cc1e95b96..4e4b5548a 100644 --- a/lib/WebGUI/Group.pm +++ b/lib/WebGUI/Group.pm @@ -282,6 +282,7 @@ sub clearCaches { $session->stow->delete("groupObj"); $session->stow->delete("isInGroup"); $session->stow->delete("gotGroupsInGroup"); + $session->stow->delete("gotGroupsForUser"); } #------------------------------------------------------------------- diff --git a/t/Group.t b/t/Group.t index 3a7d8c026..f6f6f662d 100644 --- a/t/Group.t +++ b/t/Group.t @@ -93,7 +93,7 @@ my @ldapTests = ( ); -plan tests => (164 + (scalar(@scratchTests) * 2) + scalar(@ipTests)); # increment this value for each test you create +plan tests => (168 + (scalar(@scratchTests) * 2) + scalar(@ipTests)); # increment this value for each test you create my $session = WebGUI::Test->session; my $testCache = WebGUI::Cache->new($session, 'myTestKey'); @@ -778,11 +778,15 @@ $gY->addUsers([$cacheDude->userId]); ok( $cacheDude->isInGroup($gY->getId), "Cache dude added to group Y"); ok( $cacheDude->isInGroup($gZ->getId), "Cache dude is a member of group Z by group membership"); +ok((grep $_ eq $gY->getId, @{ $cacheDude->getGroupIdsRecursive } ), 'Cache dude in Y by getGroupIdsRecursive'); -$gY->deleteUsers([$cacheDude->userId]); +ok(eval { $gY->deleteUsers([$cacheDude->userId]); 1; }, "Y deleteUsers on Cache dude"); -ok( !$cacheDude->isInGroup($gY->getId), "Cache dude removed from group Y"); -ok( !$cacheDude->isInGroup($gZ->getId), "Cache dude removed from group Z too"); +ok((! grep $_ eq $gY->getId, @{ $cacheDude->getGroupIdsRecursive } ), 'Cache dude not in Y getGroupIdsRecursive'); +ok((! grep $_ eq $cacheDude->userId, @{ $gY->getAllUsers() } ), 'Cache dude not in Y getAllUsers'); + +ok( !$cacheDude->isInGroup($gY->getId), "Cache dude removed from group Y by isInGroup"); +ok( !$cacheDude->isInGroup($gZ->getId), "Cache dude removed from group Z too by isInGroup"); my $gCache = WebGUI::Group->new($session, "new"); WebGUI::Test->groupsToDelete($gCache);