X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Ft%2Fapi%2Fsystem.t;h=f3d9226cf18be0bc5dca8b616bf0631337e59ea4;hb=1c538bfabc2cd31f27067505f0c3d1a46cba6ef0;hp=f1100d33220e19ece7545f339e0b141d29c584a7;hpb=a6fe07e49e3fc12169e801b1ed6874c3a5bd8500;p=freeside.git 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'); + +}