handle the case when the JSON hash contains only the unique identifier

This commit is contained in:
Colin Kuskie 2008-05-16 05:40:20 +00:00
parent 06a38c61c3
commit 04412f96c4
2 changed files with 18 additions and 5 deletions

View file

@ -681,14 +681,16 @@ the criteria mentioned above.
sub setCollateral {
my $self = shift;
my $tableName = shift;
my $keyName = shift;
my $keyValue = shift;
my $keyName = shift;
my $keyValue = shift;
my $properties = shift;
##Note, since this returns a reference, it is actually updating
##the object cache directly.
my $table = $self->getAllCollateral($tableName);
if ($keyValue eq 'new' || $keyValue eq '') {
$properties->{$keyName} = $self->session->id->generate;
if (! exists $properties->{$keyName}) {
$properties->{$keyName} = $self->session->id->generate;
}
push @{ $table }, $properties;
$self->setAllCollateral($tableName);
return $properties->{$keyName};
@ -1140,7 +1142,7 @@ sub www_moveAccessoryDown {
sub www_moveAccessoryUp {
my $self = shift;
return $self->session->privilege->insufficient() unless ($self->canEdit);
$self->moveCollateralUp('accessoryJSON', $self->session->form->process('aid'));
$self->moveCollateralUp('accessoryJSON', 'accessoryAssetId', $self->session->form->process('aid'));
return '';
}

View file

@ -35,7 +35,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 26; # Increment this number for each test you create
plan tests => 27; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
@ -251,6 +251,17 @@ cmp_deeply(
$product2->purge;
my $product3 = $root->addChild({
className => "WebGUI::Asset::Sku::Product",
title => "Bible",
});
my $requestedVid = $session->id->generate();
my $bareVid = $product3->setCollateral('variantsJSON', 'bareVid', 'new', { bareVid => $requestedVid });
is($bareVid, $requestedVid, 'For single column collateral JSON, requested id = assigned id');
$product3->purge;
#----------------------------------------------------------------------------
# Cleanup
END {