Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/lib/WebGUI/AssetVersioning.pm b/lib/WebGUI/AssetVersioning.pm
index 49dce78..074c9a9 100644
--- a/lib/WebGUI/AssetVersioning.pm
+++ b/lib/WebGUI/AssetVersioning.pm
@@ -92,7 +92,7 @@ sub addRevision {
my $autoCommitId = $self->getAutoCommitWorkflowId() unless ($options->{skipAutoCommitWorkflows});
- my $workingTag;
+ my ($workingTag, $oldWorking);
if ( $autoCommitId ) {
$workingTag
= WebGUI::VersionTag->create( $self->session, {
@@ -109,7 +109,9 @@ sub addRevision {
$workingTag = WebGUI::VersionTag->getWorking( $self->session );
}
else {
+ my $oldWorking = WebGUI::VersionTag->getWorking($self->session, 'noCreate');
$workingTag = WebGUI::VersionTag->new( $self->session, $parentAsset->get('tagId') );
+ $workingTag->setWorking();
}
}
@@ -163,6 +165,7 @@ sub addRevision {
$newVersion->setVersionLock;
$newVersion->update(\%mergedProperties);
$newVersion->setAutoCommitTag($workingTag) if (defined $autoCommitId);
+ $oldWorking->setWorking if $oldWorking;
return $newVersion;
}
diff --git a/t/Asset/AssetLineage.t b/t/Asset/AssetLineage.t
index f031922..07f2bb9 100644
--- a/t/Asset/AssetLineage.t
+++ b/t/Asset/AssetLineage.t
@@ -17,7 +17,7 @@ use WebGUI::Session;
use WebGUI::User;
use WebGUI::Asset;
-use Test::More tests => 92; # increment this value for each test you create
+use Test::More tests => 93; # increment this value for each test you create
use Test::Deep;
# Test the methods in WebGUI::AssetLineage
@@ -526,6 +526,26 @@ $vTag2->commit;
is($deepAsset[41]->getParent->getId, $deepAsset[40]->getId, 'addChild will not create an asset with a lineage deeper than 42 levels');
like($WebGUI::Test::logger_warns, qr/Adding it as a sibling instead/, 'addChild logged a warning about deep assets');
+{
+ my $tag = WebGUI::VersionTag->getWorking($session);
+ addToCleanup($tag);
+ my $uncommittedParent = $root->addChild({
+ className => "WebGUI::Asset::Wobject::Layout",
+ groupIdView => 7,
+ ownerUserId => 3,
+ title => "Uncommitted Parent",
+ });
+ $tag->leaveTag;
+ my $parent = WebGUI::Asset->newPending($session, $uncommittedParent->getId);
+ my $floater = $parent->addChild({
+ className => "WebGUI::Asset::Snippet",
+ groupIdView => 7,
+ ownerUserId => 3, #For coverage on addChild properties
+ title => "Child of uncommitted parent",
+ });
+ is $parent->get('tagId'), $floater->get('tagId'), 'addChild: with uncommitted parent, adds child and puts it into the same tag as the parent';
+}
+
TODO: {
local $TODO = "Tests to make later";
ok(0, 'addChild');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.