From ac6116b7a087e7946cc066bbf0cc130836a2e09f Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 2 Mar 2007 16:51:49 +0000 Subject: [PATCH] Added a dbSlave test to Session.t. It's kind of a hack as it sets up a slave reference back to the original db from the config. Bug fixes for the TrashClipboard workflow activity. The dates were off, since the interval returns an epoch, and the call to Asset->new didn't have the session. --- docs/changelog/7.x.x.txt | 1 + .../Workflow/Activity/TrashClipboard.pm | 4 +-- t/Session.t | 32 ++++++++++++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 4c860926f..9bafbd249 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -7,6 +7,7 @@ - fix: Database Connetion for ODBC fails for lengthy strings (thanks to Isaac Finegan, Core Mobility) - fix: the fileImport script did not resize vertical images. (Martin Kamerbeek / Oqapi) + - fix: TrashClipboard.pm (thanks to Erik Svanberg for the patch) 7.3.11 - Added an option for enabling coverage tests to testCodebase.pl. diff --git a/lib/WebGUI/Workflow/Activity/TrashClipboard.pm b/lib/WebGUI/Workflow/Activity/TrashClipboard.pm index 7fd6685a1..7016de213 100644 --- a/lib/WebGUI/Workflow/Activity/TrashClipboard.pm +++ b/lib/WebGUI/Workflow/Activity/TrashClipboard.pm @@ -75,10 +75,10 @@ See WebGUI::Workflow::Activity::execute() for details. sub execute { my $self = shift; - my $expireDate = (time()-(86400*$self->get("trashAfter"))); + my $expireDate = (time()-$self->get("trashAfter")); my $sth = $self->session->db->read("select assetId,className from asset where state='clipboard' and stateChanged < ?", [$expireDate]); while (my ($id, $class) = $sth->array) { - my $asset = WebGUI::Asset->new($id,$class); + my $asset = WebGUI::Asset->new($self->session,$id,$class); $asset->trash; } return $self->COMPLETE; diff --git a/t/Session.t b/t/Session.t index a0404dfa0..b391bcf0b 100644 --- a/t/Session.t +++ b/t/Session.t @@ -19,7 +19,7 @@ use WebGUI::User; use Test::More; -plan tests => 1; # increment this value for each test you create +plan tests => 2; # increment this value for each test you create my $session = WebGUI::Test->session; @@ -31,8 +31,38 @@ my ($userId) = $session->db->quickArray("select userId from userSession where se is($userId, $user->userId, 'changing session user changes sessionId inside userSession table'); +################################################################ +# +# dbSlave +# +################################################################ + +##Manually build one dbSlave in the config file to use + +my $slaveHash2 = { + dsn => $session->config->get('dsn'), + user => $session->config->get('dbuser'), + pass => $session->config->get('dbpass'), +}; + +my $slaveHash1 = { + dsn => $session->config->get('dsn').';host=192.168.104.202', + user => $session->config->get('dbuser'), + pass => $session->config->get('dbpass'), +}; + +diag $slaveHash1->{dsn}; + +$session->config->set('dbslave2', $slaveHash2); +$session->config->set('dbslave1', $slaveHash1); + +my $slave2 = $session->dbSlave; +isa_ok($slave2, 'WebGUI::SQL'); + END { foreach my $dude ($user) { $dude->delete if (defined $dude and ref $dude eq 'WebGUI::User'); } + $session->config->delete('dbslave2'); + $session->config->delete('dbslave1'); }