fix bad import of help template variables. Loops are now handled correctly. Added a test with supporting collateral to make sure this does not happen again
This commit is contained in:
parent
9db0430032
commit
0c2f9f5ec7
4 changed files with 316 additions and 7 deletions
|
|
@ -13,6 +13,7 @@
|
|||
- fix: EMS edit badge event list can display incorrectly in IE
|
||||
- fix: Expired SessionScratch not deleted (thanks to Michelle Lamar)
|
||||
http://www.plainblack.com/bugs/tracker/expired-sessionscratch-not-deleted
|
||||
- fix: Bad import of help template variables from other topics. (perlDreamer Consulting, LLC.)
|
||||
|
||||
7.4.12
|
||||
- fix: extra empty/grey area at the bottom of pages
|
||||
|
|
|
|||
|
|
@ -57,9 +57,33 @@ sub _loadHelp {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _processVariables ( $helpVar, $namespace )
|
||||
|
||||
Recursively descend down any nested template variables and give
|
||||
them default namespaces. Also, handle copying the variables
|
||||
entry.
|
||||
|
||||
=cut
|
||||
|
||||
sub _processVar {
|
||||
my ($helpVar, $namespace) = @_;
|
||||
my $processed = {};
|
||||
$processed->{name} = $helpVar->{name},
|
||||
$processed->{description} = $helpVar->{description},
|
||||
$processed->{namespace} = $helpVar->{namespace} || $namespace;
|
||||
if ($helpVar->{variables}) {
|
||||
foreach my $helpVariable (@{ $helpVar->{variables} }) {
|
||||
push @{ $processed->{variables} }, _processVar($helpVariable, $namespace);
|
||||
}
|
||||
}
|
||||
return $processed;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _process ( $session, $cmd, $key )
|
||||
|
||||
Do all post processing for an entry in a freshly loaded help file.
|
||||
Do almost all the post processing for an entry in a freshly loaded help file.
|
||||
Resolve the related key, add a default isa key if it is missing,
|
||||
and set the __PROCESSED flag to prevent processing entries twice.
|
||||
|
||||
|
|
@ -78,7 +102,7 @@ sub _process {
|
|||
$helpEntry->{__PROCESSED} = 0;
|
||||
}
|
||||
foreach my $isa ( @{ $helpEntry->{isa} } ) {
|
||||
my $oCmd = "WebGUI::Help::".$isa->{namespace};
|
||||
my $oCmd = "WebGUI::Help::".$isa->{namespace};
|
||||
my $other = _loadHelp($session, $oCmd);
|
||||
my $otherHelp = $other->{ $isa->{tag} };
|
||||
_process($session, $otherHelp, $isa->{tag});
|
||||
|
|
@ -88,11 +112,7 @@ sub _process {
|
|||
@{$helpEntry->{related}} = (@{ $helpEntry->{related} }, @{ $add });
|
||||
$add = $otherHelp->{variables};
|
||||
foreach my $row (@{$add}) {
|
||||
push(@{$helpEntry->{variables}}, {
|
||||
name=> $row->{name},
|
||||
description => $row->{description},
|
||||
namespace => $row->{namespace} || $isa->{namespace}
|
||||
});
|
||||
push(@{$helpEntry->{variables}}, _processVar($row, $isa->{namespace}));
|
||||
}
|
||||
}
|
||||
$helpEntry->{__PROCESSED} = 1;
|
||||
|
|
|
|||
179
t/Help/isa.t
Normal file
179
t/Help/isa.t
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Operation::Help;
|
||||
|
||||
use File::Copy;
|
||||
use File::Spec;
|
||||
|
||||
#The goal of this test is to verify Help inheritance, via the isa key field.
|
||||
#isa should bring in related items, form entries and template variables,
|
||||
#recursively.
|
||||
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
plan tests => 4;
|
||||
|
||||
installCollateral();
|
||||
|
||||
my $allHelp = WebGUI::Operation::Help::_load($session, 'HelpTest');
|
||||
|
||||
cmp_deeply(
|
||||
$allHelp->{'base one'},
|
||||
{
|
||||
title => 'base one title',
|
||||
body => 'base one body',
|
||||
variables => [
|
||||
{ name => 'base one var1', },
|
||||
{ name => 'base one var2', },
|
||||
{ name => 'base one var3', },
|
||||
],
|
||||
related => [],
|
||||
fields => [],
|
||||
isa => [],
|
||||
__PROCESSED => 1,
|
||||
},
|
||||
'fetching help with no isa relationships'
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
$allHelp->{'isa one'},
|
||||
{
|
||||
title => 'isa one title',
|
||||
body => 'isa one body',
|
||||
variables => [
|
||||
{ name => 'isa one var1', },
|
||||
{ name => 'isa one var2', },
|
||||
{ name => 'isa one var3', },
|
||||
{ name => 'base one var1',
|
||||
description => undef,
|
||||
namespace => 'HelpTest'
|
||||
},
|
||||
{ name => 'base one var2',
|
||||
description => undef,
|
||||
namespace => 'HelpTest'
|
||||
},
|
||||
{ name => 'base one var3',
|
||||
description => undef,
|
||||
namespace => 'HelpTest'
|
||||
},
|
||||
],
|
||||
related => [],
|
||||
fields => [],
|
||||
isa => [
|
||||
{ namespace => "HelpTest",
|
||||
tag => "base one"
|
||||
},
|
||||
],
|
||||
__PROCESSED => 1,
|
||||
},
|
||||
'isa imports variables. Imported variables have explicit description and namespaces'
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
$allHelp->{'isa loop one'},
|
||||
{
|
||||
title => 'isa loop one title',
|
||||
body => 'isa loop one body',
|
||||
variables => [
|
||||
{ name => 'isa loop one var1', },
|
||||
{ name => 'loop one var1',
|
||||
description => undef,
|
||||
namespace => 'HelpTest',
|
||||
variables => [
|
||||
{ name => 'loop one loop1',
|
||||
description => undef,
|
||||
namespace => 'HelpTest',
|
||||
},
|
||||
{ name => 'loop one loop2',
|
||||
description => undef,
|
||||
namespace => 'HelpTest',
|
||||
},
|
||||
],
|
||||
},
|
||||
{ name => 'loop one var2',
|
||||
description => undef,
|
||||
namespace => 'HelpTest',
|
||||
},
|
||||
],
|
||||
related => [],
|
||||
fields => [],
|
||||
isa => [
|
||||
{ namespace => "HelpTest",
|
||||
tag => "loop one"
|
||||
},
|
||||
],
|
||||
__PROCESSED => 1,
|
||||
},
|
||||
'isa imports variables with loops'
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
$allHelp->{'isa deep loop'},
|
||||
{
|
||||
title => 'isa deep loop title',
|
||||
body => 'isa deep loop body',
|
||||
variables => [
|
||||
{ name => 'isa deep loop var1', },
|
||||
{ name => 'deep loop var1',
|
||||
description => undef,
|
||||
namespace => 'HelpTest',
|
||||
variables => [
|
||||
{ name => 'deep loop loop2',
|
||||
description => undef,
|
||||
namespace => 'HelpTest',
|
||||
variables => [
|
||||
{ name => 'deep loop loop3',
|
||||
description => undef,
|
||||
namespace => 'HelpTest',
|
||||
variables => [
|
||||
{ name => 'deep loop loop4',
|
||||
description => undef,
|
||||
namespace => 'HelpTest',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
related => [],
|
||||
fields => [],
|
||||
isa => [
|
||||
{ namespace => "HelpTest",
|
||||
tag => "deep loop"
|
||||
},
|
||||
],
|
||||
__PROCESSED => 1,
|
||||
},
|
||||
'isa imports variables with nested loops'
|
||||
);
|
||||
|
||||
sub installCollateral {
|
||||
copy(
|
||||
File::Spec->catfile( WebGUI::Test->getTestCollateralPath, qw/Help HelpTest.pm/),
|
||||
File::Spec->catfile( WebGUI::Test->lib, qw/WebGUI Help/)
|
||||
);
|
||||
}
|
||||
|
||||
END: {
|
||||
unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI Help HelpTest.pm/);
|
||||
}
|
||||
|
||||
109
t/supporting_collateral/Help/HelpTest.pm
Normal file
109
t/supporting_collateral/Help/HelpTest.pm
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
package WebGUI::Help::HelpTest;
|
||||
|
||||
our $HELP = {
|
||||
|
||||
'base one' => {
|
||||
title => 'base one title',
|
||||
body => 'base one body',
|
||||
variables => [
|
||||
{ name => 'base one var1', },
|
||||
{ name => 'base one var2', },
|
||||
{ name => 'base one var3', },
|
||||
],
|
||||
fields => [],
|
||||
related => []
|
||||
},
|
||||
|
||||
'isa one' => {
|
||||
title => 'isa one title',
|
||||
body => 'isa one body',
|
||||
isa => [
|
||||
{ namespace => "HelpTest",
|
||||
tag => "base one"
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{ name => 'isa one var1', },
|
||||
{ name => 'isa one var2', },
|
||||
{ name => 'isa one var3', },
|
||||
],
|
||||
fields => [],
|
||||
related => [],
|
||||
},
|
||||
|
||||
'loop one' => {
|
||||
title => 'loop one title',
|
||||
body => 'loop one body',
|
||||
isa => [
|
||||
],
|
||||
variables => [
|
||||
{ name => 'loop one var1',
|
||||
variables => [
|
||||
{ name => 'loop one loop1', },
|
||||
{ name => 'loop one loop2', },
|
||||
],
|
||||
},
|
||||
{ name => 'loop one var2', },
|
||||
],
|
||||
fields => [],
|
||||
related => [],
|
||||
},
|
||||
|
||||
'isa loop one' => {
|
||||
title => 'isa loop one title',
|
||||
body => 'isa loop one body',
|
||||
isa => [
|
||||
{ namespace => "HelpTest",
|
||||
tag => "loop one"
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{ name => 'isa loop one var1', },
|
||||
],
|
||||
fields => [],
|
||||
related => [],
|
||||
},
|
||||
|
||||
'deep loop' => {
|
||||
title => 'deep loop title',
|
||||
body => 'deep loop body',
|
||||
isa => [
|
||||
],
|
||||
variables => [
|
||||
{ name => 'deep loop var1',
|
||||
variables => [
|
||||
{ name => 'deep loop loop2',
|
||||
variables => [
|
||||
{ name => 'deep loop loop3',
|
||||
variables => [
|
||||
{ name => 'deep loop loop4',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
fields => [],
|
||||
related => [],
|
||||
},
|
||||
|
||||
'isa deep loop' => {
|
||||
title => 'isa deep loop title',
|
||||
body => 'isa deep loop body',
|
||||
isa => [
|
||||
{ namespace => "HelpTest",
|
||||
tag => "deep loop"
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{ name => 'isa deep loop var1', },
|
||||
],
|
||||
fields => [],
|
||||
related => [],
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue