Gallery resolutions are integers. Fixed sorting the resolutions, and fixed the tests to not use bad resolutions. Fixes bug #11787

This commit is contained in:
Colin Kuskie 2010-08-17 11:16:58 -07:00
parent 09ff64334e
commit eac7fe8a64
6 changed files with 15 additions and 14 deletions

View file

@ -4,6 +4,7 @@
- fixed #11780: fixFilenames regex needs an anchor in ZipArchive asset - fixed #11780: fixFilenames regex needs an anchor in ZipArchive asset
- fixed #11782: Attachments all showing duplicated first thumbnail - fixed #11782: Attachments all showing duplicated first thumbnail
- fixed #11777: Thingy search on yes no field fails - fixed #11777: Thingy search on yes no field fails
- fixed #11787: Gallery resolutions wrongly ordered
7.9.12 7.9.12
- webgui.org homepage gives 404 (#11778) - webgui.org homepage gives 404 (#11778)

View file

@ -306,7 +306,7 @@ sub getResolutions {
my $storage = $self->getStorageLocation; my $storage = $self->getStorageLocation;
# Return a list not including the web view image. # Return a list not including the web view image.
return [ sort { $a cmp $b } grep { $_ ne $self->get("filename") } @{ $storage->getFiles } ]; return [ sort { $a <=> $b } grep { $_ ne $self->get("filename") } @{ $storage->getFiles } ];
} }
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------

View file

@ -39,7 +39,7 @@ addToCleanup($versionTag);
my $gallery my $gallery
= $node->addChild({ = $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery", className => "WebGUI::Asset::Wobject::Gallery",
imageResolutions => "1024x768", imageResolutions => "1024",
}, },
undef, undef,
undef, undef,

View file

@ -35,7 +35,7 @@ my ($gallery, $album, $photo);
$gallery $gallery
= $node->addChild({ = $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery", className => "WebGUI::Asset::Wobject::Gallery",
imageResolutions => "1600x1200\n1024x768\n800x600\n640x480", imageResolutions => "1600\n1024\n800\n640",
}); });
$album $album
= $gallery->addChild({ = $gallery->addChild({
@ -75,7 +75,7 @@ diag( $@ )
cmp_deeply( cmp_deeply(
$photo->getStorageLocation->getFiles, $photo->getStorageLocation->getFiles,
bag( '1024x768.jpg', '1600x1200.jpg', '640x480.jpg', '800x600.jpg', 'page_title.jpg' ), bag( '1024.jpg', '1600.jpg', '640.jpg', '800.jpg', 'page_title.jpg' ),
"makeResolutions makes all the required resolutions with the appropriate names.", "makeResolutions makes all the required resolutions with the appropriate names.",
); );
@ -91,7 +91,7 @@ WebGUI::Test->addToCleanup($versionTags[-1]);
$gallery $gallery
= $node->addChild({ = $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery", className => "WebGUI::Asset::Wobject::Gallery",
imageResolutions => "1600x1200\n1024x768\n800x600\n640x480", imageResolutions => "1600\n1024\n800\n640",
}); });
$album $album
= $gallery->addChild({ = $gallery->addChild({
@ -116,12 +116,12 @@ $photo->getStorageLocation->addFileFromFilesystem( WebGUI::Test->getTestCollater
$photo->update({ filename => 'page_title.jpg' }); $photo->update({ filename => 'page_title.jpg' });
ok( ok(
!eval{ $photo->makeResolutions('100x100','200x200'); 1 }, !eval{ $photo->makeResolutions('100','200'); 1 },
"makeResolutions fails when first argument is not array reference", "makeResolutions fails when first argument is not array reference",
); );
ok( ok(
eval{ $photo->makeResolutions(['100x100','200x200']); 1 }, eval{ $photo->makeResolutions(['100','200']); 1 },
"makeResolutions succeeds when first argument is array reference of resolutions to make", "makeResolutions succeeds when first argument is array reference of resolutions to make",
); );
diag( $@ ) diag( $@ )
@ -129,7 +129,7 @@ diag( $@ )
is_deeply( is_deeply(
[ sort({ $a cmp $b} @{ $photo->getStorageLocation->getFiles }) ], [ sort({ $a cmp $b} @{ $photo->getStorageLocation->getFiles }) ],
['100x100.jpg', '200x200.jpg', 'page_title.jpg'], ['100.jpg', '200.jpg', 'page_title.jpg'],
"makeResolutions makes all the required resolutions with the appropriate names.", "makeResolutions makes all the required resolutions with the appropriate names.",
); );
@ -157,18 +157,18 @@ $photo->getStorageLocation->addFileFromFilesystem( WebGUI::Test->getTestCollater
$photo->update({ filename => 'page_title.jpg' }); $photo->update({ filename => 'page_title.jpg' });
ok( ok(
!eval{ $photo->makeResolutions('100x100','200x200'); 1 }, !eval{ $photo->makeResolutions('100','200'); 1 },
"makeResolutions fails when first argument is not array reference", "makeResolutions fails when first argument is not array reference",
); );
ok( ok(
eval{ $photo->makeResolutions(['100x100','200x200']); 1 }, eval{ $photo->makeResolutions(['100','200']); 1 },
"makeResolutions succeeds when first argument is array reference of resolutions to make", "makeResolutions succeeds when first argument is array reference of resolutions to make",
); );
is_deeply( is_deeply(
[ sort({ $a cmp $b} @{ $photo->getStorageLocation->getFiles }) ], [ sort({ $a cmp $b} @{ $photo->getStorageLocation->getFiles }) ],
['100x100.jpg', '200x200.jpg', 'page_title.jpg'], ['100.jpg', '200.jpg', 'page_title.jpg'],
"makeResolutions makes all the required resolutions with the appropriate names.", "makeResolutions makes all the required resolutions with the appropriate names.",
); );

View file

@ -37,7 +37,7 @@ addToCleanup($versionTag);
my $gallery my $gallery
= $node->addChild({ = $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery", className => "WebGUI::Asset::Wobject::Gallery",
imageResolutions => "1024x768", imageResolutions => "1024",
}, },
undef, undef,
undef, undef,

View file

@ -30,7 +30,7 @@ $versionTag->set({name=>"Photo Test"});
my $gallery my $gallery
= $node->addChild({ = $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery", className => "WebGUI::Asset::Wobject::Gallery",
imageResolutions => "1024x768", imageResolutions => "1024",
}); });
my $album my $album
= $gallery->addChild({ = $gallery->addChild({
@ -62,7 +62,7 @@ $photo->setFile( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
my $storage = $photo->getStorageLocation; my $storage = $photo->getStorageLocation;
cmp_deeply( cmp_deeply(
$storage->getFiles, bag('page_title.jpg','1024x768.jpg'), $storage->getFiles, bag('page_title.jpg','1024.jpg'),
"Storage location contains the resolution file", "Storage location contains the resolution file",
); );