From 87d252ec266f7fadaad9682e8a633a9e3c433592 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sun, 10 Jul 2011 18:29:52 -0700 Subject: [PATCH] Make sure that the keywords template variable is provided by processTemplate, since we documented that it does that. Fixes bug #12186. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset.pm | 1 + t/Asset/processTemplate.t | 56 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 t/Asset/processTemplate.t diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 7a2ecaac3..046801b9b 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -8,6 +8,7 @@ - fixed #12165: Default date in Thingy doesn't work - fixed #12188: Thingy broken after upgrade to 7.9.32-stable - fixed #12184: Apache error in modperl.error.log (William McKee, Knowmad Technologies) + - fixed #12186: keywords template variable not working properly in Article 7.10.19 - fixed #12169: extras uploads symlink export diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 96d52b164..b789157bb 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -2485,6 +2485,7 @@ sub processTemplate { %{$self->{_properties}}, 'title' => $self->getTitle, 'menuTitle' => $self->getMenuTitle, + 'keywords' => $self->get('keywords'), %{$var}, ); return $template->process(\%vars); diff --git a/t/Asset/processTemplate.t b/t/Asset/processTemplate.t new file mode 100644 index 000000000..745e1b707 --- /dev/null +++ b/t/Asset/processTemplate.t @@ -0,0 +1,56 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2009 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::Asset; + +use Test::More; +use Test::Deep; +use Clone qw/clone/; + +plan tests => 1; + +my $session = WebGUI::Test->session; + +##Set the maximum assets to 5 +WebGUI::Test->originalConfig('maximumAssets'); +$session->config->set('maximumAssets', 5); + +my $rootAsset = WebGUI::Asset->getRoot($session); + +my $versionTag = WebGUI::VersionTag->getWorking($session); +WebGUI::Test->addToCleanup($versionTag); +$rootAsset->addRevision({keywords => 'one,two,three,four'}); +$versionTag->commit; +$rootAsset = $rootAsset->cloneFromDb; + +##Override the user function style template so we can examine its output easily + #1234567890123456789012# +my $templateId = 'USER_STYLE_OVERRIDE___'; +my $templateMock = Test::MockObject->new({}); +$templateMock->set_isa('WebGUI::Asset::Template'); +$templateMock->set_always('getId', $templateId); +my $templateVars; +$templateMock->mock('process', sub { $templateVars = clone($_[1]); } ); + +{ + WebGUI::Test->mockAssetId($templateId, $templateMock); + $rootAsset->processTemplate({}, $templateId); + use WebGUI::Keyword; + my $keywords = WebGUI::Keyword::string2list($templateVars->{keywords}); + cmp_bag($keywords, [qw/one two three four/], 'Keywords are available when running processTemplate'); +} + +