Quote the id generated by the Image asset. Also, do not overwrite user uploaded parameters. Fixes bug #11246
This commit is contained in:
parent
03d9263079
commit
15ce7b56cc
3 changed files with 46 additions and 25 deletions
|
|
@ -13,6 +13,7 @@ use strict;
|
|||
use lib "$FindBin::Bin/../../lib";
|
||||
|
||||
use Test::MockObject;
|
||||
use Test::MockObject::Extends;
|
||||
my $mocker;
|
||||
BEGIN {
|
||||
$mocker = Test::MockObject->new();
|
||||
|
|
@ -20,7 +21,6 @@ BEGIN {
|
|||
$mocker->fake_new('WebGUI::Form::Image');
|
||||
}
|
||||
|
||||
use File::Copy;
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Image;
|
||||
|
|
@ -30,7 +30,8 @@ use WebGUI::Form::File;
|
|||
|
||||
use Test::More; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
plan tests => 11;
|
||||
use Data::Dumper;
|
||||
plan tests => 13;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -39,7 +40,7 @@ $rectangle->setBackgroundColor('#0000FF');
|
|||
|
||||
##Create a storage location
|
||||
my $storage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($storage);
|
||||
addToCleanup($storage);
|
||||
|
||||
##Save the image to the location
|
||||
$rectangle->saveToStorageLocation($storage, 'blue.png');
|
||||
|
|
@ -73,6 +74,9 @@ $asset->update({
|
|||
filename => 'blue.png',
|
||||
});
|
||||
|
||||
is($storage->getId, $asset->get('storageId'), 'Asset updated with correct new storageId');
|
||||
is($storage->getId, $asset->getStorageLocation->getId, 'Cached Asset storage location updated with correct new storageId');
|
||||
|
||||
my $filename = $asset->getStorageLocation->getPath . "/" . $asset->get("filename");
|
||||
|
||||
my @stat_before = stat($filename);
|
||||
|
|
@ -93,16 +97,32 @@ is(isnt_array(\@stat_before, \@stat_after), 1, 'Image is different after crop');
|
|||
my $sth = $session->db->read('describe ImageAsset annotations');
|
||||
isnt($sth->hashRef, undef, 'Annotations column is defined');
|
||||
|
||||
is($storage->getId, $asset->get('storageId'), 'Asset updated with correct new storageId');
|
||||
is($storage->getId, $asset->getStorageLocation->getId, 'Cached Asset storage location updated with correct new storageId');
|
||||
#------------------------------------------------------------------------------
|
||||
# Template variables
|
||||
my $templateId = 'FILE_IMAGE_TEMPLATE___';
|
||||
|
||||
my $templateMock = Test::MockObject->new({});
|
||||
$templateMock->set_isa('WebGUI::Asset::Template');
|
||||
$templateMock->set_always('getId', $templateId);
|
||||
my $templateVars;
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
|
||||
$asset->update({
|
||||
parameters => 'alt="alternate"',
|
||||
templateId => $templateId,
|
||||
});
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
$asset->prepareView();
|
||||
$asset->view();
|
||||
like($templateVars->{parameters}, qr{ id="[^"]{22}"}, 'id in parameters is quoted');
|
||||
like($templateVars->{parameters}, qr{alt="alternate"}, 'original parameters included');
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
}
|
||||
|
||||
$versionTag->commit;
|
||||
|
||||
END {
|
||||
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
|
||||
$versionTag->rollback;
|
||||
}
|
||||
}
|
||||
addToCleanup($versionTag);
|
||||
|
||||
sub isnt_array {
|
||||
my ($a, $b) = @_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue