Make revisedBy a property, so it gets written on ->update. Change addRev not to write to the db when it does not need to. Update tests to verify that addRev does the right thing for tagId and revisedBy.
This commit is contained in:
parent
9155f70555
commit
d66b3b891b
3 changed files with 11 additions and 13 deletions
|
|
@ -260,6 +260,11 @@ has assetId => (
|
|||
has revisionDate => (
|
||||
is => 'rw',
|
||||
);
|
||||
property revisedBy => (
|
||||
is => 'rw',
|
||||
noFormPost => 1,
|
||||
fieldType => 'guid',
|
||||
);
|
||||
has [qw/parentId lineage
|
||||
creationDate createdBy
|
||||
state stateChanged stateChangedBy
|
||||
|
|
@ -2313,7 +2318,7 @@ sub write {
|
|||
my @values = map { $self->$_ } @properties;
|
||||
my @columnNames = map { $db->quoteIdentifier($_).'=?' } @properties;
|
||||
push @values, $self->getId, $self->revisionDate;
|
||||
$db->write("update ".$table." set ".join(",",@columnNames)." where assetId=? and revisionDate=?",\@values);
|
||||
$db->write("update ".$table." set ".join(",",@columnNames)." where assetId=? and revisionDate=?",\@values);
|
||||
}
|
||||
|
||||
# update the asset's size, which also purges the cache.
|
||||
|
|
|
|||
|
|
@ -114,17 +114,8 @@ sub addRevision {
|
|||
}
|
||||
$session->db->commit;
|
||||
|
||||
my $sql = "update assetData set revisedBy=?, tagId=? where assetId=? and revisionDate=?";
|
||||
|
||||
$session->db->write($sql,[
|
||||
$session->user->userId,
|
||||
$workingTag->getId,
|
||||
$self->getId,
|
||||
$now,
|
||||
]);
|
||||
|
||||
# current values, and the user set properties
|
||||
my %mergedProperties = (%{$self->get}, %{$properties}, (status => 'pending'));
|
||||
my %mergedProperties = (%{$self->get}, %{$properties}, (status => 'pending', revisedBy => $session->user->userId, tagId => $workingTag->getId), );
|
||||
|
||||
#Instantiate new revision and fill with real data
|
||||
my $newVersion = WebGUI::Asset->newById($session, $self->getId, $now);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use Test::Deep;
|
|||
use Test::Exception;
|
||||
use WebGUI::Exception;
|
||||
|
||||
plan tests => 57;
|
||||
plan tests => 59;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -238,13 +238,15 @@ my $session = WebGUI::Test->session;
|
|||
my $testAsset = WebGUI::Asset->new($session, $testId2, $revisionDate);
|
||||
$testAsset->title('test title 43');
|
||||
$testAsset->write();
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
my $revAsset = $testAsset->addRevision({}, $now);
|
||||
isa_ok $revAsset, 'WebGUI::Asset';
|
||||
is $revAsset->revisionDate, $now, 'revisionDate set correctly on new revision';
|
||||
is $revAsset->title, 'test title 43', 'data fetch from database correct';
|
||||
is $revAsset->revisedBy, $session->user->userId, 'revisedBy is current session user';
|
||||
is $revAsset->tagId, $tag->getId, 'tagId is current working tagId';
|
||||
my $count = $session->db->quickScalar('SELECT COUNT(*) from assetData where assetId=?',[$testId2]);
|
||||
is $count, 2, 'two records in the database';
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
addToCleanup($tag);
|
||||
|
||||
$session->db->write("delete from asset where assetId like 'wg8TestAsset00000%'");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue