Make Macro/Thumbnail.t more robust by not running downstream tests if
the file does not exist. Fixed a bug I created by changing the order of update and change comparison in Asset/File.pm. This caused Asset/File.t, Asset/File/Image.t and Macro/Thumbnail.t to fail.
This commit is contained in:
parent
a7dde82421
commit
37f6db428f
2 changed files with 18 additions and 12 deletions
|
|
@ -382,6 +382,7 @@ sub update {
|
|||
edit => $self->get("groupIdEdit"),
|
||||
storageId => $self->get('storageId'),
|
||||
);
|
||||
$self->SUPER::update(@_);
|
||||
##update may have entered a new storageId. Reset the cached one just in case.
|
||||
if ($self->get("storageId") ne $before{storageId}) {
|
||||
$self->setStorageLocation;
|
||||
|
|
@ -389,7 +390,6 @@ sub update {
|
|||
if ($self->get("ownerUserId") ne $before{owner} || $self->get("groupIdEdit") ne $before{edit} || $self->get("groupIdView") ne $before{view}) {
|
||||
$self->getStorageLocation->setPrivileges($self->get("ownerUserId"),$self->get("groupIdView"),$self->get("groupIdEdit"));
|
||||
}
|
||||
$self->SUPER::update(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -65,11 +65,12 @@ $asset->update({
|
|||
storageId => $storage->getId,
|
||||
filename => 'square.png',
|
||||
});
|
||||
$versionTag->commit;
|
||||
|
||||
|
||||
$asset->generateThumbnail();
|
||||
|
||||
$versionTag->commit;
|
||||
|
||||
|
||||
##Call the Thumbnail Macro with that Asset's URL and see if it returns
|
||||
##the correct URL.
|
||||
|
||||
|
|
@ -77,19 +78,24 @@ my $output = WebGUI::Macro::Thumbnail::process($session, $asset->getUrl());
|
|||
my $macroUrl = $storage->getPath('thumb-square.png');
|
||||
is($output, $asset->getThumbnailUrl, 'Macro returns correct filename');
|
||||
|
||||
my $thumbUrl = $asset->getThumbnailUrl;
|
||||
my $thumbUrl = $output;
|
||||
substr($thumbUrl, 0, length($session->config->get("uploadsURL"))) = '';
|
||||
my $thumbFile = $session->config->get('uploadsPath') . $thumbUrl;
|
||||
ok((-e $thumbFile), 'file actually exists');
|
||||
my $fileExists = ok((-e $thumbFile), "file actually exists $thumbFile");
|
||||
|
||||
##Load the image into some parser and check a few pixels to see if they're blue-ish.
|
||||
##->Get('pixel[x,y]') hopefully returns color in hex triplets
|
||||
my $thumbImg = Image::Magick->new();
|
||||
$thumbImg->Read(filename => $thumbFile);
|
||||
SKIP: {
|
||||
skip "File does not exist", 3 unless $fileExists;
|
||||
|
||||
cmp_bag([$thumbImg->GetPixels(width=>1, height=>1, x=>25, y=>25, map=>'RGB', normalize=>'true')], [0,0,1], 'blue pixel #1');
|
||||
cmp_bag([$thumbImg->GetPixels(width=>1, height=>1, x=>75, y=>75, map=>'RGB', normalize=>'true')], [0,0,1], 'blue pixel #2');
|
||||
cmp_bag([$thumbImg->GetPixels(width=>1, height=>1, x=>50, y=>50, map=>'RGB', normalize=>'true')], [0,0,1], 'blue pixel #3');
|
||||
##Load the image into some parser and check a few pixels to see if they're blue-ish.
|
||||
##->Get('pixel[x,y]') hopefully returns color in hex triplets
|
||||
my $thumbImg = Image::Magick->new();
|
||||
$thumbImg->Read(filename => $thumbFile);
|
||||
|
||||
cmp_bag([$thumbImg->GetPixels(width=>1, height=>1, x=>25, y=>25, map=>'RGB', normalize=>'true')], [0,0,1], 'blue pixel #1');
|
||||
cmp_bag([$thumbImg->GetPixels(width=>1, height=>1, x=>75, y=>75, map=>'RGB', normalize=>'true')], [0,0,1], 'blue pixel #2');
|
||||
cmp_bag([$thumbImg->GetPixels(width=>1, height=>1, x=>50, y=>50, map=>'RGB', normalize=>'true')], [0,0,1], 'blue pixel #3');
|
||||
|
||||
}
|
||||
|
||||
END {
|
||||
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue