diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 07a5b66f4..68f7afeec 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -220,12 +220,11 @@ property inheritUrlFromParent => ( uiLevel => 9, fieldType => 'yesNo', default => 0, + trigger => \&_set_inheritUrlFromParent, ); -around inheritUrlFromParent => sub { - my $orig = shift; - my $self = shift; - $self->$orig(@_); - if (@_ > 0 && $_[0]) { +sub _set_inheritUrlFromParent { + my ($self, $new, $old) = @_; + if ($new && ($new != $old)) { $self->url($self->url); } }; @@ -686,9 +685,8 @@ sub fixUrl { # if we're inheriting the URL from our parent, set that appropriately my @parts = split(m{/}, $url); # don't do anything unless we need to - if($url ne $self->getParent->get('url') . '/' . $parts[-1]) { - $url = $self->getParent->get('url') . '/' . $parts[-1]; - } + my $inheritUrl = $self->getParent->get('url') . '/' . $parts[-1]; + $url = $inheritUrl if $url ne $inheritUrl; } $url = $self->session->url->urlize($url); diff --git a/t/Asset/Asset.t b/t/Asset/Asset.t index 3abca8d1a..0e57898e2 100644 --- a/t/Asset/Asset.t +++ b/t/Asset/Asset.t @@ -499,15 +499,17 @@ is($rootAsset->get('isExportable'), 1, 'isExportable exists, defaults to 1'); # getSeparator # ################################################################ -is($rootAsset->getSeparator, '~~~PBasset000000000000001~~~', 'getSeparator, known assetId'); -is($rootAsset->getSeparator('!'), '!!!PBasset000000000000001!!!', 'getSeparator, given pad character'); -isnt($rootAsset->getSeparator, $mediaFolder->getSeparator, 'getSeparator: unique string'); +note "getSeparator"; +is($rootAsset->getSeparator, '~~~PBasset000000000000001~~~', '... known assetId'); +is($rootAsset->getSeparator('!'), '!!!PBasset000000000000001!!!', '... given pad character'); +isnt($rootAsset->getSeparator, $mediaFolder->getSeparator, '... unique string'); ################################################################ # # get # ################################################################ +note "get"; my $assetProps = $rootAsset->get(); my $funkyTitle = q{Miss Annie's Whoopie Emporium and Sasparilla Shop}; $assetProps->{title} = $funkyTitle; @@ -555,6 +557,7 @@ $product3->purge; # inheritUrlFromParent # ################################################################ +note "inheritUrlFromParent"; my $versionTag4 = WebGUI::VersionTag->getWorking($session); WebGUI::Test->tagsToRollback($versionTag4); @@ -581,6 +584,7 @@ $properties2 = { my $iufpAsset2 = $iufpAsset->addChild($properties2, $properties2->{id}); $iufpAsset2->update( { inheritUrlFromParent => 1 } ); +is $iufpAsset2->inheritUrlFromParent, 1, 'inheritUrlFromParent set'; $iufpAsset2->commit; is($iufpAsset2->get('url'), 'inheriturlfromparent01/inheriturlfromparent02', 'inheritUrlFromParent works');