diff options
author | ivan <ivan> | 2011-02-17 00:25:23 +0000 |
---|---|---|
committer | ivan <ivan> | 2011-02-17 00:25:23 +0000 |
commit | fc6209f398899f0211cfcedeb81a3cd65e04a941 (patch) | |
tree | bc1dc8876218529948413d85c17cd67508bdd38d /rt/t/api/cf_rights.t | |
parent | e70abd21bab68b23488f7ef1ee2e693a3b365691 (diff) |
import rt 3.8.9
Diffstat (limited to 'rt/t/api/cf_rights.t')
-rw-r--r-- | rt/t/api/cf_rights.t | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/rt/t/api/cf_rights.t b/rt/t/api/cf_rights.t new file mode 100644 index 000000000..f55214a66 --- /dev/null +++ b/rt/t/api/cf_rights.t @@ -0,0 +1,51 @@ +#!/usr/bin/perl +use warnings; +use strict; + +use RT; +use RT::Test tests => 12; + +my $q = RT::Queue->new($RT::SystemUser); +my ($id,$msg) =$q->Create(Name => "CF-Rights-".$$); +ok($id,$msg); + +my $cf = RT::CustomField->new($RT::SystemUser); +($id,$msg) = $cf->Create(Name => 'CF-'.$$, Type => 'Select', MaxValues => '1', Queue => $q->id); +ok($id,$msg); + + +($id,$msg) =$cf->AddValue(Name => 'First'); +ok($id,$msg); + +my $u = RT::User->new($RT::SystemUser); +($id,$msg) = $u->Create( Name => 'User1', Privileged => 1 ); +ok ($id,$msg); + +($id,$msg) = $u->PrincipalObj->GrantRight( Object => $cf, Right => 'SeeCustomField' ); +ok ($id,$msg); + +my $ucf = RT::CustomField->new($u); +($id,$msg) = $ucf->Load( $cf->Id ); +ok ($id,$msg); + +my $cfv = $ucf->Values->First; + +($id,$msg) = $cfv->SetName( 'First1' ); +ok (!$id,$msg); + +($id,$msg) = $u->PrincipalObj->GrantRight( Object => $cf, Right => 'AdminCustomFieldValues' ); +ok ($id,$msg); + +($id,$msg) = $cfv->SetName( 'First2' ); +ok ($id,$msg); + +($id,$msg) = $u->PrincipalObj->RevokeRight( Object => $cf, Right => 'AdminCustomFieldValues' ); +ok ($id,$msg); + +($id,$msg) = $u->PrincipalObj->GrantRight( Object => $cf, Right => 'AdminCustomField' ); +ok ($id,$msg); + +($id,$msg) = $cfv->SetName( 'First3' ); +ok ($id,$msg); + +1; |