From a4624663cf7f06614a2e288d8d50f74e34e0af20 Mon Sep 17 00:00:00 2001 From: Scott Walters Date: Tue, 6 Sep 2011 20:26:55 -0400 Subject: [PATCH] Mobile template is not being inherited (#12246) Applied SquOnk's patch and added tests; modify www_add to inherit mobileStyleTemplateId from the parent as well as mobileTemplateId. mobileTemplateId is only used by PageLayout currently. If other assets start using this and this gets inherited cross asset types, thing will break. A better design here would be to flag on a case-by-case basis in asset definitions whether any given property should be inherited globally, of children of the same asset class, or not at all. --- lib/WebGUI/Asset.pm | 2 ++ t/Asset/Wobject/Layout.t | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index c669e2441..831211ae1 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -2921,6 +2921,8 @@ sub www_add { encryptPage => $self->get("encryptPage"), styleTemplateId => $self->get("styleTemplateId"), printableStyleTemplateId => $self->get("printableStyleTemplateId"), + mobileStyleTemplateId => $self->get("mobileStyleTemplateId"), + mobileTemplateId => $self->get("mobileTemplateId"), isHidden => $self->get("isHidden"), className=>$class, assetId=>"new", diff --git a/t/Asset/Wobject/Layout.t b/t/Asset/Wobject/Layout.t index c69cb794b..7e0a72c40 100644 --- a/t/Asset/Wobject/Layout.t +++ b/t/Asset/Wobject/Layout.t @@ -16,8 +16,9 @@ use lib "$FindBin::Bin/../../lib"; use Test::MockTime qw/:all/; ##Must be loaded before all other code use WebGUI::Test; use WebGUI::Session; -use Test::More tests => 3; # increment this value for each test you create +use Test::More tests => 5; # increment this value for each test you create use WebGUI::Asset::Wobject::Layout; +use WebGUI::Asset::Template; my $session = WebGUI::Test->session; @@ -64,4 +65,25 @@ set_relative_time(-100); $snip1 = $snip1->addRevision({ title => 'titular', }, 18); is $page->getContentLastModifiedBy, $revised_user1->userId, '... check that a new revision tracks'; +# inheriting mobileStyleTemplateId and mobileTemplateId; from ``Mobile template is not being inherited (#12246)'' + +my $importNode = WebGUI::Asset::Template->getImportNode($session); +my $template1 = $importNode->addChild({className=>"WebGUI::Asset::Template"}); +my $template2 = $importNode->addChild({className=>"WebGUI::Asset::Template"}); +WebGUI::Test->addToCleanup($template1, $template2); + +my $mobileStyleTemplateId = $template1->getId; +my $mobileTemplateId = $template2->getId; +$page->update({ mobileStyleTemplateId => $mobileStyleTemplateId, mobileTemplateId => $mobileTemplateId }); +my $url = $page->get('url') . '/layout_child_test'; +my $html = WebGUI::Test->getPage($page, "www_add", { + userId => 3, + formParams => { + class => 'WebGUI::Asset::Wobject::Layout', + url => $page->get('url') . '/layout_child_test', + }, +}); + +like $html, qr/name="mobileTemplateId" value="$mobileTemplateId"/, 'child PageLayout inherited parents mobileTempaleId'; +like $html, qr/name="mobileStyleTemplateId" value="$mobileStyleTemplateId"/, 'child PageLayout inherited parents mobileStyleTempaleId';