From 8b975cc8108b4c7638aad7abdd82e8d8d1cc81ed Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Thu, 22 Oct 2009 09:32:12 -0500 Subject: [PATCH] don't set tableName on property elements if it is already specified --- lib/WebGUI/Definition/Asset.pm | 2 +- t/Definition/Asset.t | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/WebGUI/Definition/Asset.pm b/lib/WebGUI/Definition/Asset.pm index ab6619330..1f532aec1 100644 --- a/lib/WebGUI/Definition/Asset.pm +++ b/lib/WebGUI/Definition/Asset.pm @@ -31,7 +31,7 @@ sub import { if ( my $properties = $definition->{properties} ) { my $table = $definition->{tableName}; for ( my $i = 1; $i < @{ $properties }; $i += 2) { - $properties->[$i]{tableName} = $table; + $properties->[$i]{tableName} ||= $table; } } diff --git a/t/Definition/Asset.t b/t/Definition/Asset.t index df160927f..c61dcf528 100644 --- a/t/Definition/Asset.t +++ b/t/Definition/Asset.t @@ -22,12 +22,14 @@ use WebGUI::Test; package WGT::Class; use WebGUI::Definition::Asset ( attribute1 => 'attribute 1 value', + tableName => 'mytable', properties => [ showInForms => { label => ['show in forms'], }, confirmChange => { label => ['confirm change', 'Asset'], + tableName => 'othertable', }, noTrans => { label => 'this label will not be translated', @@ -42,10 +44,15 @@ use WebGUI::Test; 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'; -is_deeply $object->getProperty('confirmChange')->{label}, 'Are you sure?', +is $object->getProperty('confirmChange')->{label}, 'Are you sure?', '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};