[Rt-commit] rt branch, dashboard-acl-query, updated. rt-3.9.6-369-ge4aaf4a
Shawn Moore
sartak at bestpractical.com
Mon Dec 6 18:47:50 EST 2010
The branch, dashboard-acl-query has been updated
via e4aaf4a5fbd41ee38d1856552f40ecdcf0534ad0 (commit)
from e6d22ccc09613485b3057b224e10de3632b8e7f5 (commit)
Summary of changes:
t/api/groups.t | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 53 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit e4aaf4a5fbd41ee38d1856552f40ecdcf0534ad0
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Dec 6 18:47:37 2010 -0500
Tests for ForWhichCurrentUserHasRight
diff --git a/t/api/groups.t b/t/api/groups.t
index e4ed959..254ba1e 100644
--- a/t/api/groups.t
+++ b/t/api/groups.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use RT::Test nodata => 1, tests => 27;
+use RT::Test nodata => 1, tests => 42;
RT::Group->AddRights(
'RTxGroupRight' => 'Just a right for testing rights',
@@ -125,8 +125,58 @@ $groups = RT::Groups->new(RT->SystemUser);
$groups->WithRight(Right => 'RTxGroupRight', Object => $RTxObj2, EquivObjects => [ $RTxSysObj ]);
is($groups->Count, 1, "RTxGroupRight found for RTxObj2");
+}
-
-
+{
+ # this company is split into two halves, the hacks and the non-hacks
+ # herbert is a hacker but eric is not.
+ my $herbert = RT::User->new(RT->SystemUser);
+ my ($ok, $msg) = $herbert->Create(Name => 'herbert');
+ ok($ok, $msg);
+
+ my $eric = RT::User->new(RT->SystemUser);
+ ($ok, $msg) = $eric->Create(Name => 'eric');
+ ok($ok, $msg);
+
+ my $hacks = RT::Group->new(RT->SystemUser);
+ ($ok, $msg) = $hacks->CreateUserDefinedGroup(Name => 'Hackers');
+ ok($ok, $msg);
+
+ my $employees = RT::Group->new(RT->SystemUser);
+ ($ok, $msg) = $employees->CreateUserDefinedGroup(Name => 'Employees');
+ ok($ok, $msg);
+
+ ($ok, $msg) = $employees->AddMember($hacks->PrincipalId);
+ ok($ok, $msg);
+
+ ($ok, $msg) = $hacks->AddMember($herbert->PrincipalId);
+ ok($ok, $msg);
+
+ ($ok, $msg) = $employees->AddMember($eric->PrincipalId);
+ ok($ok, $msg);
+
+ ok($employees->HasMemberRecursively($hacks->PrincipalId), 'employees has member hacks');
+ ok($employees->HasMemberRecursively($herbert->PrincipalId), 'employees has member herbert');
+ ok($employees->HasMemberRecursively($eric->PrincipalId), 'employees has member eric');
+
+ ok($hacks->HasMemberRecursively($herbert->PrincipalId), 'hacks has member herbert');
+ ok(!$hacks->HasMemberRecursively($eric->PrincipalId), 'hacks does not have member eric');
+
+ ($ok, $msg) = $employees->PrincipalObj->GrantRight(Right => 'RTxGroupRight', Object => $employees);
+ ok($ok, $msg);
+
+ {
+ my $groups = RT::Groups->new(RT::CurrentUser->new($eric));
+ $groups->LimitToUserDefinedGroups;
+ $groups->ForWhichCurrentUserHasRight(Right => 'RTxGroupRight');
+ is_deeply([sort map { $_->Name } @{ $groups->ItemsArrayRef }], ['Employees']);
+ }
+
+ {
+ my $groups = RT::Groups->new(RT::CurrentUser->new($herbert));
+ $groups->LimitToUserDefinedGroups;
+ $groups->ForWhichCurrentUserHasRight(Right => 'RTxGroupRight');
+ is_deeply([sort map { $_->Name } @{ $groups->ItemsArrayRef }], ['Employees', 'Hackers']);
+ }
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list