Provide a way for Template to import old packages that have headBlock properties, with tests.
This commit is contained in:
parent
bb5ced3e0d
commit
09f7caab40
3 changed files with 42 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
7.6.7
|
7.6.7
|
||||||
- fixed #9263: Thingy possibleValues processing, and List type autodetection.
|
- fixed #9263: Thingy possibleValues processing, and List type autodetection.
|
||||||
|
- fixed: Alter WebGUI::Asset::Template's update method so that it can import packages that use the old, deprecated headBlock property. The update method change is deprecatd.
|
||||||
|
|
||||||
7.6.6
|
7.6.6
|
||||||
- fixed #8792: Image Preview gives ERROR in Collateral Manager
|
- fixed #8792: Image Preview gives ERROR in Collateral Manager
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ use base 'WebGUI::Asset';
|
||||||
use WebGUI::International;
|
use WebGUI::International;
|
||||||
use WebGUI::Asset::Template::HTMLTemplate;
|
use WebGUI::Asset::Template::HTMLTemplate;
|
||||||
use WebGUI::Utility;
|
use WebGUI::Utility;
|
||||||
|
use Clone qw/clone/;
|
||||||
|
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
@ -401,6 +402,30 @@ sub processRaw {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 update
|
||||||
|
|
||||||
|
Override update from Asset.pm to handle backwards compatibility with the old
|
||||||
|
packages that contain headBlocks.
|
||||||
|
|
||||||
|
This method is deprecated and will be removed in the future. Don't plan
|
||||||
|
on this being here.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub update {
|
||||||
|
my $self = shift;
|
||||||
|
my $requestedProperties = shift;
|
||||||
|
my $properties = clone($requestedProperties);
|
||||||
|
if (exists $properties->{headBlock}) {
|
||||||
|
$properties->{extraHeadTags} .= $properties->{headBlock};
|
||||||
|
delete $properties->{headBlock};
|
||||||
|
}
|
||||||
|
$self->SUPER::update($properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub www_edit {
|
sub www_edit {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use lib "$FindBin::Bin/../lib";
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::Asset::Template;
|
use WebGUI::Asset::Template;
|
||||||
use Test::More tests => 13; # increment this value for each test you create
|
use Test::More tests => 15; # increment this value for each test you create
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
@ -23,19 +23,19 @@ my $session = WebGUI::Test->session;
|
||||||
my $list = WebGUI::Asset::Template->getList($session);
|
my $list = WebGUI::Asset::Template->getList($session);
|
||||||
cmp_deeply($list, {}, 'getList with no classname returns an empty hashref');
|
cmp_deeply($list, {}, 'getList with no classname returns an empty hashref');
|
||||||
|
|
||||||
my $template = " <tmpl_var variable> <tmpl_if conditional>true</tmpl_if> <tmpl_loop loop>XY</tmpl_loop> ";
|
my $tmplText = " <tmpl_var variable> <tmpl_if conditional>true</tmpl_if> <tmpl_loop loop>XY</tmpl_loop> ";
|
||||||
my %var = (
|
my %var = (
|
||||||
variable=>"AAAAA",
|
variable=>"AAAAA",
|
||||||
conditional=>1,
|
conditional=>1,
|
||||||
loop=>[{},{},{},{},{}]
|
loop=>[{},{},{},{},{}]
|
||||||
);
|
);
|
||||||
my $output = WebGUI::Asset::Template->processRaw($session,$template,\%var);
|
my $output = WebGUI::Asset::Template->processRaw($session,$tmplText,\%var);
|
||||||
ok($output =~ m/\bAAAAA\b/, "processRaw() - variables");
|
ok($output =~ m/\bAAAAA\b/, "processRaw() - variables");
|
||||||
ok($output =~ m/true/, "processRaw() - conditionals");
|
ok($output =~ m/true/, "processRaw() - conditionals");
|
||||||
ok($output =~ m/\s(?:XY){5}\s/, "processRaw() - loops");
|
ok($output =~ m/\s(?:XY){5}\s/, "processRaw() - loops");
|
||||||
|
|
||||||
my $importNode = WebGUI::Asset::Template->getImportNode($session);
|
my $importNode = WebGUI::Asset::Template->getImportNode($session);
|
||||||
my $template = $importNode->addChild({className=>"WebGUI::Asset::Template", title=>"test", url=>"testingtemplates", template=>$template, namespace=>'WebGUI Test Template'});
|
my $template = $importNode->addChild({className=>"WebGUI::Asset::Template", title=>"test", url=>"testingtemplates", template=>$tmplText, namespace=>'WebGUI Test Template'});
|
||||||
isa_ok($template, 'WebGUI::Asset::Template', "creating a template");
|
isa_ok($template, 'WebGUI::Asset::Template', "creating a template");
|
||||||
|
|
||||||
is($template->get('parser'), 'WebGUI::Asset::Template::HTMLTemplate', 'default parser is HTMLTemplate');
|
is($template->get('parser'), 'WebGUI::Asset::Template::HTMLTemplate', 'default parser is HTMLTemplate');
|
||||||
|
|
@ -57,6 +57,18 @@ is($template->get('isDefault'), 1, 'isDefault set to 1');
|
||||||
my $templateCopy = $template->duplicate();
|
my $templateCopy = $template->duplicate();
|
||||||
is($templateCopy->get('isDefault'), 0, 'isDefault set to 0 on copy');
|
is($templateCopy->get('isDefault'), 0, 'isDefault set to 0 on copy');
|
||||||
|
|
||||||
|
my $template3 = $importNode->addChild({
|
||||||
|
className => "WebGUI::Asset::Template",
|
||||||
|
title => 'headBlock test',
|
||||||
|
headBlock => "tag1 tag2 tag3",
|
||||||
|
template => "this is a template",
|
||||||
|
});
|
||||||
|
|
||||||
|
ok(!$template3->get('headBlock'), 'headBlock is empty');
|
||||||
|
is($template3->get('extraHeadTags'), 'tag1 tag2 tag3', 'extraHeadTags contains headBlock info');
|
||||||
|
|
||||||
$template->purge;
|
$template->purge;
|
||||||
$templateCopy->purge;
|
$templateCopy->purge;
|
||||||
|
$template3->purge;
|
||||||
|
WebGUI::VersionTag->getWorking($session)->rollback;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue