Add a test for evaluating templates and macros in the right order
in the Snippet. Fix a bug with that.
This commit is contained in:
parent
1af2704e0c
commit
e3c77d4e80
3 changed files with 28 additions and 8 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
7.6.9
|
7.6.9
|
||||||
- marked sbin scripts as executable
|
- marked sbin scripts as executable
|
||||||
|
- Problem #9492: in passing form variables to Macro SQL inside a snippet
|
||||||
|
|
||||||
7.6.8
|
7.6.8
|
||||||
- added #!/usr/bin/env perl to all utility scripts
|
- added #!/usr/bin/env perl to all utility scripts
|
||||||
|
|
|
||||||
|
|
@ -194,23 +194,24 @@ sub purgeCache {
|
||||||
sub view {
|
sub view {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $calledAsWebMethod = shift;
|
my $calledAsWebMethod = shift;
|
||||||
my $versionTag = WebGUI::VersionTag->getWorking($self->session, 1);
|
my $session = $self->session;
|
||||||
|
my $versionTag = WebGUI::VersionTag->getWorking($session, 1);
|
||||||
my $noCache =
|
my $noCache =
|
||||||
$self->session->var->isAdminOn
|
$session->var->isAdminOn
|
||||||
|| $self->get("cacheTimeout") <= 10
|
|| $self->get("cacheTimeout") <= 10
|
||||||
|| ($versionTag && $versionTag->getId eq $self->get("tagId"));
|
|| ($versionTag && $versionTag->getId eq $self->get("tagId"));
|
||||||
unless ($noCache) {
|
unless ($noCache) {
|
||||||
my $out = WebGUI::Cache->new($self->session,"view_".$calledAsWebMethod."_".$self->getId)->get;
|
my $out = WebGUI::Cache->new($session,"view_".$calledAsWebMethod."_".$self->getId)->get;
|
||||||
return $out if $out;
|
return $out if $out;
|
||||||
}
|
}
|
||||||
my $output = $self->get("snippet");
|
my $output = $self->get("snippet");
|
||||||
WebGUI::Macro::process($self->session,\$output);
|
$output = $self->getToolbar.$output if ($session->var->isAdminOn && !$calledAsWebMethod);
|
||||||
$output = $self->getToolbar.$output if ($self->session->var->isAdminOn && !$calledAsWebMethod);
|
|
||||||
if ($self->getValue("processAsTemplate")) {
|
if ($self->getValue("processAsTemplate")) {
|
||||||
$output = WebGUI::Asset::Template->processRaw($self->session, $output, $self->get);
|
$output = WebGUI::Asset::Template->processRaw($session, $output, $self->get);
|
||||||
}
|
}
|
||||||
|
WebGUI::Macro::process($session,\$output);
|
||||||
unless ($noCache) {
|
unless ($noCache) {
|
||||||
WebGUI::Cache->new($self->session,"view_".$calledAsWebMethod."_".$self->getId)->set($output,$self->get("cacheTimeout"));
|
WebGUI::Cache->new($session,"view_".$calledAsWebMethod."_".$self->getId)->set($output,$self->get("cacheTimeout"));
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use lib "$FindBin::Bin/../lib";
|
||||||
|
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use Test::More tests => 14; # increment this value for each test you create
|
use Test::More tests => 15; # increment this value for each test you create
|
||||||
use WebGUI::Asset::Snippet;
|
use WebGUI::Asset::Snippet;
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
@ -70,6 +70,24 @@ isnt ($wwwViewOutput, undef, 'www_view returns something');
|
||||||
my $editOutput = $snippet->www_edit;
|
my $editOutput = $snippet->www_edit;
|
||||||
isnt ($editOutput, undef, 'www_edit returns something');
|
isnt ($editOutput, undef, 'www_edit returns something');
|
||||||
|
|
||||||
|
$snippet->update({
|
||||||
|
title => "authMethod",
|
||||||
|
processAsTemplate => 1,
|
||||||
|
cacheTimeout => 1,
|
||||||
|
snippet => q|^SQL(select value from settings where name="<tmpl_var title>");|
|
||||||
|
});
|
||||||
|
|
||||||
|
my $sqlMacroAdded = exists $session->config->get('macros')->{'SQL'};
|
||||||
|
if (! $sqlMacroAdded) {
|
||||||
|
$session->config->addToHash('macros', 'SQL', 'SQL');
|
||||||
|
}
|
||||||
|
|
||||||
|
is($snippet->view(), 'WebGUI', 'Interpolating macros in works with template in the correct order');
|
||||||
|
|
||||||
|
if (! $sqlMacroAdded) {
|
||||||
|
$session->config->deleteFromHash('macros', 'SQL');
|
||||||
|
}
|
||||||
|
|
||||||
TODO: {
|
TODO: {
|
||||||
local $TODO = "Tests to make later";
|
local $TODO = "Tests to make later";
|
||||||
ok(0, 'Test indexContent method');
|
ok(0, 'Test indexContent method');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue