From c86ee126510cfc1065d43d17c7dd79d073a940bd Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 7 Oct 2010 16:14:48 -0700 Subject: [PATCH] Fixing some failing tests --- lib/WebGUI/Asset.pm | 7 +++---- lib/WebGUI/AssetTrash.pm | 11 ++++++++++- sbin/testEnvironment.pl | 2 +- t/Asset/AssetClipboard.t | 15 ++++++++++++--- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 20651535d..f5fe175f9 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -2627,15 +2627,14 @@ sub setState { stateChanged = ? WHERE assetId = ? }; + my @props = ($state, $self->session->user->userId, time); $self->session->db->write( $sql, [ - $state, - $self->session->user->userId, - time, + @props, $self->getId, ] ); - $self->{_properties}->{state} = $state; + @{$self->{_properties}}{qw(state stateChangedBy stateChanged)} = @props; $self->purgeCache; } diff --git a/lib/WebGUI/AssetTrash.pm b/lib/WebGUI/AssetTrash.pm index 10e22da53..26e74f8a5 100644 --- a/lib/WebGUI/AssetTrash.pm +++ b/lib/WebGUI/AssetTrash.pm @@ -328,7 +328,16 @@ sub trash { $outputSub->($i18n->get('Clearing cache')); $asset->purgeCache; $asset->updateHistory("trashed"); - $asset->setState($asset->getId eq $rootId ? 'trash' : 'trash-limbo'); + if ($asset->getId eq $rootId) { + $asset->setState('trash'); + # setState will take care of _properties in $asset, but not in + # $self (whooops!), so we need to manually update. + my @keys = qw(state stateChangedBy stateChanged); + @{$self->{_properties}}{@keys} = @{$asset->{_properties}}{@keys}; + } + else { + $asset->setState('trash-limbo'); + } } $db->commit; diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index f550d4da8..5ef2fac92 100755 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -145,7 +145,7 @@ checkModule("CHI", "0.34" ); checkModule('IO::Socket::SSL', ); checkModule('Net::Twitter', "3.13006" ); checkModule('PerlIO::eol', "0.14" ); -checkModule('Monkey::Patch', '0.3' ); +checkModule('Monkey::Patch', '0.03' ); failAndExit("Required modules are missing, running no more checks.") if $missingModule; diff --git a/t/Asset/AssetClipboard.t b/t/Asset/AssetClipboard.t index 8eb2bbb1c..526425e50 100644 --- a/t/Asset/AssetClipboard.t +++ b/t/Asset/AssetClipboard.t @@ -20,6 +20,7 @@ use WebGUI::Session; use WebGUI::Utility; use WebGUI::Asset; use WebGUI::VersionTag; +use Test::MockObject; use Test::More; # increment this value for each test you create plan tests => 29; @@ -148,12 +149,20 @@ sub copied { return undef; } -my @methods = qw(Single Children Descendants); +my $process = Test::MockObject->new->mock(update => sub {}); +my @methods = ( + # single duplicate doesn't fork, so we can just test the www method to + # make sure it gets it right + sub { shift->www_copy }, + sub { shift->duplicateBranch(1, 'clipboard') }, + sub { shift->duplicateBranch(0, 'clipboard') }, +); +my @prefixes = qw(single children descendants); for my $i (0..2) { - my $meth = "_wwwCopy$methods[$i]"; + my $meth = $methods[$i]; $root->$meth(); my $clip = copied(); - is_tree_of_folders($clip, $i+1, $meth); + is_tree_of_folders($clip, $i+1, @prefixes[$i]); $clip->purge; }