Rearrange form fields in default edit story template.

Change photo JSON blob to be an array ref, not a hash ref.
Code for saving new photo data.
This commit is contained in:
Colin Kuskie 2009-03-20 21:42:47 +00:00
parent 420a70531b
commit 3d5f5b04c1
4 changed files with 46 additions and 18 deletions

View file

@ -81,7 +81,7 @@ $story = $archive->addChild({
isa_ok($story, 'WebGUI::Asset::Story', 'Created a Story asset');
is($story->get('storageId'), '', 'by default, there is no storageId');
is($story->get('photo'), '{}', 'by default, photos is an empty JSON hash');
is($story->get('photo'), '[]', 'by default, photos is an empty JSON array');
is($story->get('isHidden'), 1, 'by default, stories are hidden');
$story->update({isHidden => 0});
is($story->get('isHidden'), 1, 'stories cannot be set to not be hidden');
@ -111,36 +111,36 @@ is($story->getArchive->getId, $archive->getId, 'getArchive gets the parent archi
my $photoData = $story->getPhotoData();
cmp_deeply(
$photoData, {},
'getPhotoData: returns an empty hash with no JSON data'
$photoData, [],
'getPhotoData: returns an empty array ref with no JSON data'
);
$story->setPhotoData({
filename1 => {
$story->setPhotoData([
{
byLine => 'Andrew Dufresne',
caption => 'Shawshank Prison',
},
});
]);
is($story->get('photo'), q|{"filename1":{"caption":"Shawshank Prison","byLine":"Andrew Dufresne"}}|, 'setPhotoData: set JSON in the photo property');
is($story->get('photo'), q|[{"caption":"Shawshank Prison","byLine":"Andrew Dufresne"}]|, 'setPhotoData: set JSON in the photo property');
$photoData = $story->getPhotoData();
$photoData->{filename1}->{caption}="My cell";
$photoData->[0]->{caption}="My cell";
cmp_deeply(
$story->getPhotoData,
{
filename1 => {
[
{
byLine => 'Andrew Dufresne',
caption => 'Shawshank Prison',
},
},
],
'getPhotoData does not return an unsafe reference'
);
$story->setPhotoData();
cmp_deeply(
$story->getPhotoData, {},
$story->getPhotoData, [],
'setPhotoData: wipes the stored data if nothing is passed'
);