"Fossies" - the Fresh Open Source Software Archive 
Member "RT-Extension-Assets-1.05/xt/roles.t" (15 Oct 2014, 907 Bytes) of package /linux/misc/RT-Extension-Assets-1.05.tar.gz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 use strict;
2 use warnings;
3
4 use lib 'xt/lib';
5 use RT::Extension::Assets::Test tests => undef;
6
7 my $catalog = create_catalog( Name => "A catalog" );
8 my $asset = create_asset( Name => "Test asset", Catalog => $catalog->id );
9 ok $asset && $asset->id, "Created asset";
10
11 for my $object ($asset, $catalog, RT->System) {
12 for my $role (RT::Asset->Roles) {
13 my $group = $object->RoleGroup($role);
14 ok $group->id, "Loaded role group $role for " . ref($object);
15
16 my $principal = $group->PrincipalObj;
17 ok $principal && $principal->id, "Found PrincipalObj for role group"
18 or next;
19
20 if ($object->DOES("RT::Record::Role::Rights")) {
21 my ($ok, $msg) = $principal->GrantRight(
22 Object => $object,
23 Right => "ShowAsset",
24 );
25 ok $ok, "Granted right" or diag "Error: $msg";
26 }
27 }
28 }
29
30 done_testing;