1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
use strict;
use warnings;
use RT;
use RT::Test nodata => 1, tests => 16;
BEGIN{
use_ok('RT::System');
}
# Skipping most of the methods added just to make RT::System
# look like RT::Record.
can_ok('RT::System', qw( AvailableRights RightCategories AddRight
id Id SubjectTag Name QueueCacheNeedsUpdate AddUpgradeHistory
UpgradeHistory ));
{
my $s = RT::System->new(RT->SystemUser);
my $rights = $s->AvailableRights;
ok ($rights, "Rights defined");
ok ($rights->{'AdminUsers'},"AdminUsers right found");
ok ($rights->{'CreateTicket'},"CreateTicket right found");
ok ($rights->{'AdminGroupMembership'},"ModifyGroupMembers right found");
ok (!$rights->{'CasdasdsreateTicket'},"bogus right not found");
}
{
my $sys = RT::System->new();
is( $sys->Id, 1, 'Id is 1');
is ($sys->id, 1, 'id is 1');
}
{
# Test upgrade history methods.
my $sys = RT::System->new(RT->SystemUser);
isa_ok($sys, 'RT::System');
my $file = 'test_file.txt';
my $content = 'Some file contents.';
my $upgrade_history = RT->System->UpgradeHistory();
is( keys %$upgrade_history, 0, 'No history in test DB');
RT->System->AddUpgradeHistory(RT =>{
action => 'insert',
filename => $file,
content => $content,
stage => 'before',
});
$upgrade_history = RT->System->UpgradeHistory();
ok( exists($upgrade_history->{'RT'}), 'History has an RT key.');
is( @{$upgrade_history->{'RT'}}, 1, '1 item in history array');
is($upgrade_history->{RT}[0]{stage}, 'before', 'stage is before for item 1');
RT->System->AddUpgradeHistory(RT =>{
action => 'insert',
filename => $file,
content => $content,
stage => 'after',
});
$upgrade_history = RT->System->UpgradeHistory();
is( @{$upgrade_history->{'RT'}}, 2, '2 item in history array');
is($upgrade_history->{RT}[1]{stage}, 'after', 'stage is after for item 2');
}
|