[Rt-commit] rt branch, 4.2/upgrade-history, updated. rt-4.0.5-296-g05eb368
Jim Brandt
jbrandt at bestpractical.com
Mon Mar 26 13:07:05 EDT 2012
The branch, 4.2/upgrade-history has been updated
via 05eb3685f42ef9b5935816d70c0984cc32df6984 (commit)
via b176a0d04caa70fe286e7c23dd7146723d216ff1 (commit)
from d27cf3bc8739d8faa5c89ef03d0deabc799b0857 (commit)
Summary of changes:
sbin/rt-setup-database.in | 14 +++++++++++
t/api/system.t | 54 ++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 62 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit b176a0d04caa70fe286e7c23dd7146723d216ff1
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Fri Mar 23 11:17:48 2012 -0400
Adding tests for new upgrade history methods.
diff --git a/t/api/system.t b/t/api/system.t
index f1100d3..c1df2c6 100644
--- a/t/api/system.t
+++ b/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 AddRights AddRightCategories
+ 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');
+
+}
commit 05eb3685f42ef9b5935816d70c0984cc32df6984
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Mon Mar 26 12:22:00 2012 -0400
Added ConnectToDatabase calls so the new history entries can be added to the DB. Noted where these might be removed if InsertData can stop disconnecting safely.
diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index bb4e6b4..e137aee 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -297,6 +297,12 @@ sub action_insert {
$content = <$handle>;
}
+ # XXX Reconnecting to insert the history entry
+ # until we can sort out removing
+ # the disconnect at the end of InsertData.
+
+ RT->ConnectToDatabase();
+
RT->System->AddUpgradeHistory(RT => {
action => 'insert',
filename => $file,
@@ -304,6 +310,9 @@ sub action_insert {
stage => 'after',
});
+ my $db_type = RT->Config->Get('DatabaseType');
+ $RT::Handle->Disconnect() unless $db_type eq 'SQLite';
+
return @ret;
}
@@ -431,6 +440,11 @@ sub action_upgrade {
return ( $ret, $msg ) unless $ret;
}
+ # XXX: Another connect since the insert called
+ # previous to this step will disconnect.
+
+ RT->ConnectToDatabase();
+
RT->System->AddUpgradeHistory(RT => {
action => 'upgrade',
type => 'individual upgrade',
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list