Added new API method commitAsUser allowing developers to commit version tags as other users

This commit is contained in:
khenn 2010-06-03 21:44:29 -05:00
parent 5a904a85db
commit 053292a75b
3 changed files with 84 additions and 2 deletions

View file

@ -14,7 +14,7 @@ use lib "$FindBin::Bin/lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::VersionTag;
use Test::More tests => 81; # increment this value for each test you create
use Test::More tests => 85; # increment this value for each test you create
my $session = WebGUI::Test->session;
@ -184,8 +184,31 @@ is($tag3->getRevisionCount, 5, 'original tag still with five revisions');
$tag4->clearWorking;
$tag3->rollback;
$tag4->rollback;
($asset1, $asset2, $asset3, $tag3, $tag4) = ();
#Test commitAsUser
my $tag5 = WebGUI::VersionTag->create($session, {});
$tag5->setWorking;
my $asset5 = WebGUI::Asset->getRoot($session)->addChild({ className => 'WebGUI::Asset::Snippet' });
is($tag5->get("createdBy"),1,'tag created by visitor');
$tag5->commitAsUser(3);
$tag5 = WebGUI::VersionTag->new($session, $tag5->getId); #Get the tag again - properties have changed
is($tag5->get("committedBy"),3,'tag committed by admin');
$tag5->clearWorking;
$tag5->rollback;
#Test commitAsUser with options
my $tag6 = WebGUI::VersionTag->create($session, {});
$tag6->setWorking;
my $asset6 = WebGUI::Asset->getRoot($session)->addChild({ className => 'WebGUI::Asset::Snippet' });
$tag6->commitAsUser(3, { commitNow => "yes" });
$tag6 = WebGUI::VersionTag->new($session, $tag6->getId); #Get the tag again - properties have changed
is($tag6->get("committedBy"),3,'tag committed by admin again');
$asset6 = WebGUI::Asset->newByDynamicClass($session,$asset6->getId); #Get the asset again - properties have changed
is($asset6->get("status"),"approved","asset status approved");
$tag6->clearWorking;
$tag6->rollback;
($asset1, $asset2, $asset3, $asset5, $asset6, $tag3, $tag4, $tag5, $tag6) = ();
#additional tests for versionTagMode
#