summaryrefslogtreecommitdiff
path: root/rt/t/api/system.t
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-07-10 18:15:08 -0700
committerMark Wells <mark@freeside.biz>2015-07-10 18:15:08 -0700
commit88bf5db0cca989c51237c661a13078eef08b3674 (patch)
tree0a84e1b5e7fd239f57fab678bf40c5311b0064a0 /rt/t/api/system.t
parent9c15ffe3a5ee987e30e10c6a0ad1b5bf0b2a12e3 (diff)
parente7eb845db1afab1cbdbc34ff9c387c5ac554659e (diff)
Merge branch 'FREESIDE_4_BRANCH' of git.freeside.biz:/home/git/freeside into 4.x
Diffstat (limited to 'rt/t/api/system.t')
-rw-r--r--rt/t/api/system.t54
1 files changed, 48 insertions, 6 deletions
diff --git a/rt/t/api/system.t b/rt/t/api/system.t
index f1100d332..f3d9226cf 100644
--- a/rt/t/api/system.t
+++ b/rt/t/api/system.t
@@ -2,8 +2,18 @@
use strict;
use warnings;
use RT;
-use RT::Test nodata => 1, tests => 7;
+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 ));
{
@@ -15,18 +25,50 @@ 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');
}
{
-use RT::System;
-my $sys = RT::System->new();
-is( $sys->Id, 1);
-is ($sys->id, 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');
+
+}