Fix inheritUrlFromParent, using trigger instead of around.
This commit is contained in:
parent
6573884db6
commit
5c3a3d440b
2 changed files with 13 additions and 11 deletions
|
|
@ -220,12 +220,11 @@ property inheritUrlFromParent => (
|
||||||
uiLevel => 9,
|
uiLevel => 9,
|
||||||
fieldType => 'yesNo',
|
fieldType => 'yesNo',
|
||||||
default => 0,
|
default => 0,
|
||||||
|
trigger => \&_set_inheritUrlFromParent,
|
||||||
);
|
);
|
||||||
around inheritUrlFromParent => sub {
|
sub _set_inheritUrlFromParent {
|
||||||
my $orig = shift;
|
my ($self, $new, $old) = @_;
|
||||||
my $self = shift;
|
if ($new && ($new != $old)) {
|
||||||
$self->$orig(@_);
|
|
||||||
if (@_ > 0 && $_[0]) {
|
|
||||||
$self->url($self->url);
|
$self->url($self->url);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -686,9 +685,8 @@ sub fixUrl {
|
||||||
# if we're inheriting the URL from our parent, set that appropriately
|
# if we're inheriting the URL from our parent, set that appropriately
|
||||||
my @parts = split(m{/}, $url);
|
my @parts = split(m{/}, $url);
|
||||||
# don't do anything unless we need to
|
# don't do anything unless we need to
|
||||||
if($url ne $self->getParent->get('url') . '/' . $parts[-1]) {
|
my $inheritUrl = $self->getParent->get('url') . '/' . $parts[-1];
|
||||||
$url = $self->getParent->get('url') . '/' . $parts[-1];
|
$url = $inheritUrl if $url ne $inheritUrl;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$url = $self->session->url->urlize($url);
|
$url = $self->session->url->urlize($url);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -499,15 +499,17 @@ is($rootAsset->get('isExportable'), 1, 'isExportable exists, defaults to 1');
|
||||||
# getSeparator
|
# getSeparator
|
||||||
#
|
#
|
||||||
################################################################
|
################################################################
|
||||||
is($rootAsset->getSeparator, '~~~PBasset000000000000001~~~', 'getSeparator, known assetId');
|
note "getSeparator";
|
||||||
is($rootAsset->getSeparator('!'), '!!!PBasset000000000000001!!!', 'getSeparator, given pad character');
|
is($rootAsset->getSeparator, '~~~PBasset000000000000001~~~', '... known assetId');
|
||||||
isnt($rootAsset->getSeparator, $mediaFolder->getSeparator, 'getSeparator: unique string');
|
is($rootAsset->getSeparator('!'), '!!!PBasset000000000000001!!!', '... given pad character');
|
||||||
|
isnt($rootAsset->getSeparator, $mediaFolder->getSeparator, '... unique string');
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
#
|
#
|
||||||
# get
|
# get
|
||||||
#
|
#
|
||||||
################################################################
|
################################################################
|
||||||
|
note "get";
|
||||||
my $assetProps = $rootAsset->get();
|
my $assetProps = $rootAsset->get();
|
||||||
my $funkyTitle = q{Miss Annie's Whoopie Emporium and Sasparilla Shop};
|
my $funkyTitle = q{Miss Annie's Whoopie Emporium and Sasparilla Shop};
|
||||||
$assetProps->{title} = $funkyTitle;
|
$assetProps->{title} = $funkyTitle;
|
||||||
|
|
@ -555,6 +557,7 @@ $product3->purge;
|
||||||
# inheritUrlFromParent
|
# inheritUrlFromParent
|
||||||
#
|
#
|
||||||
################################################################
|
################################################################
|
||||||
|
note "inheritUrlFromParent";
|
||||||
|
|
||||||
my $versionTag4 = WebGUI::VersionTag->getWorking($session);
|
my $versionTag4 = WebGUI::VersionTag->getWorking($session);
|
||||||
WebGUI::Test->tagsToRollback($versionTag4);
|
WebGUI::Test->tagsToRollback($versionTag4);
|
||||||
|
|
@ -581,6 +584,7 @@ $properties2 = {
|
||||||
|
|
||||||
my $iufpAsset2 = $iufpAsset->addChild($properties2, $properties2->{id});
|
my $iufpAsset2 = $iufpAsset->addChild($properties2, $properties2->{id});
|
||||||
$iufpAsset2->update( { inheritUrlFromParent => 1 } );
|
$iufpAsset2->update( { inheritUrlFromParent => 1 } );
|
||||||
|
is $iufpAsset2->inheritUrlFromParent, 1, 'inheritUrlFromParent set';
|
||||||
$iufpAsset2->commit;
|
$iufpAsset2->commit;
|
||||||
is($iufpAsset2->get('url'), 'inheriturlfromparent01/inheriturlfromparent02', 'inheritUrlFromParent works');
|
is($iufpAsset2->get('url'), 'inheriturlfromparent01/inheriturlfromparent02', 'inheritUrlFromParent works');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue