don't set tableName on property elements if it is already specified

This commit is contained in:
Graham Knop 2009-10-22 09:32:12 -05:00
parent 0e94b4a783
commit 8b975cc810
2 changed files with 11 additions and 4 deletions

View file

@ -31,7 +31,7 @@ sub import {
if ( my $properties = $definition->{properties} ) { if ( my $properties = $definition->{properties} ) {
my $table = $definition->{tableName}; my $table = $definition->{tableName};
for ( my $i = 1; $i < @{ $properties }; $i += 2) { for ( my $i = 1; $i < @{ $properties }; $i += 2) {
$properties->[$i]{tableName} = $table; $properties->[$i]{tableName} ||= $table;
} }
} }

View file

@ -22,12 +22,14 @@ use WebGUI::Test;
package WGT::Class; package WGT::Class;
use WebGUI::Definition::Asset ( use WebGUI::Definition::Asset (
attribute1 => 'attribute 1 value', attribute1 => 'attribute 1 value',
tableName => 'mytable',
properties => [ properties => [
showInForms => { showInForms => {
label => ['show in forms'], label => ['show in forms'],
}, },
confirmChange => { confirmChange => {
label => ['confirm change', 'Asset'], label => ['confirm change', 'Asset'],
tableName => 'othertable',
}, },
noTrans => { noTrans => {
label => 'this label will not be translated', label => 'this label will not be translated',
@ -42,10 +44,15 @@ use WebGUI::Test;
my $object = WGT::Class->instantiate; my $object = WGT::Class->instantiate;
is_deeply $object->getProperty('showInForms')->{label}, 'Show In Forms?', is $object->getProperty('showInForms')->{tableName}, 'mytable',
'properties copy tableName attribute';
is $object->getProperty('confirmChange')->{tableName}, 'othertable',
'tableName property element not overwritten if manually specified';
is $object->getProperty('showInForms')->{label}, 'Show In Forms?',
'getProperty internationalizes label'; 'getProperty internationalizes label';
is_deeply $object->getProperty('confirmChange')->{label}, 'Are you sure?', is $object->getProperty('confirmChange')->{label}, 'Are you sure?',
'getProperty internationalizes label with namespace'; 'getProperty internationalizes label with namespace';
is_deeply $object->getProperty('noTrans')->{label}, 'this label will not be translated', is $object->getProperty('noTrans')->{label}, 'this label will not be translated',
q{getProperty doesn't internationalize plain scalars}; q{getProperty doesn't internationalize plain scalars};