summaryrefslogtreecommitdiff
path: root/rt/t/api/cf_rights.t
diff options
context:
space:
mode:
authorivan <ivan>2011-02-17 00:25:23 +0000
committerivan <ivan>2011-02-17 00:25:23 +0000
commit0fb307c305e4bc2c9c27dc25a3308beae3a4d33c (patch)
tree9d527e17db4b4d875f63f019dcd513762bb938a6 /rt/t/api/cf_rights.t
parent6a79fae0c14b6635c67b4f224ee4a14f263b37d0 (diff)
parentfc6209f398899f0211cfcedeb81a3cd65e04a941 (diff)
This commit was generated by cvs2svn to compensate for changes in r10640,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'rt/t/api/cf_rights.t')
-rw-r--r--rt/t/api/cf_rights.t51
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;