Return "setDefault" when key is undefined (Closes: #903)

This commit is contained in:
Xavier Guimard 2016-01-19 21:22:05 +00:00
parent 6282810fcc
commit 4e0f37d071
3 changed files with 13 additions and 4 deletions

View File

@ -711,7 +711,8 @@ sub getKey {
# When "hash"
if ( $key =~ qr/^$simpleHashKeys$/o ) {
$value //= {};
return $self->sendError( $req, 'setDefault', 200 )
unless defined($value);
# If a hash key is asked return its value
if ($subkey) {
@ -736,6 +737,7 @@ sub getKey {
# When scalar
return $self->sendError( $req, "Key $key is not a hash", 400 )
if ($subkey);
return $self->sendError( $req, 'setDefault', 200 ) unless defined($value);
return $self->sendJSONresponse( $req, { value => $value } );
# TODO authParam key

View File

@ -615,7 +615,7 @@
}
var setHelp = function(scope) {
if (!showH) return;
if (!$scope.showH) return;
while (!scope.$modelValue.help && scope.$parentNodeScope) {
scope = scope.$parentNodeScope;
}

View File

@ -62,13 +62,20 @@ while (<F>) {
close F;
ok( $hstruct = from_json($hstruct), 'struct.json is JSON' );
ok( ref $hstruct eq 'ARRAY', 'struct.json is an array' );
ok( ref $hstruct eq 'ARRAY', 'struct.json is an array' )
or print STDERR "Expected: ARRAY, got: " . ( ref $hstruct ) . "\n";
count(2);
foreach my $query (@hkeys) {
my $href = &client->jsonResponse( "/confs/1/$query", '' );
ok( ref $href eq 'ARRAY', 'Response is an array' );
ok(
( ref $href eq 'ARRAY' )
or
( ( ref $href eq 'HASH' ) and ( $href->{error} =~ /setDefault$/ ) ),
'Response is an array'
);
count(1);
next if ( ( ref $href eq 'HASH' ) and ( $href->{error} =~ /setDefault$/ ) );
foreach my $k (@$href) {
ok( defined $k->{title}, 'Title defined' );
ok( defined $k->{id}, 'Id defined' );