From 6fe662ef834b32002cb7dd99560ace64a78de6cf Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 18 Jan 2010 10:57:24 -0800 Subject: [PATCH] Make sure template attachments are duplicated. Fixes bug #11355. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Template.pm | 1 + t/Asset/Template.t | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 72f0ca304..28b4bfd0b 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -9,6 +9,7 @@ - fixed #11350: Story Topic asset missing description... - fixed #11351: Double submits on ITransact checkout - fixed #11353: shop - sales - error + - fixed #11355: Duplicate template error 7.8.9 - fixed #11235: wiki search diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index 41771e009..c12e4f882 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -189,6 +189,7 @@ sub duplicate { my $self = shift; my $newTemplate = $self->SUPER::duplicate; $newTemplate->update({isDefault => 0}); + $newTemplate->addAttachments($self->getAttachments); return $newTemplate; } diff --git a/t/Asset/Template.t b/t/Asset/Template.t index 18657936f..95275b6e0 100644 --- a/t/Asset/Template.t +++ b/t/Asset/Template.t @@ -16,7 +16,7 @@ use WebGUI::Test; use WebGUI::Session; use WebGUI::Asset::Template; use Exception::Class; -use Test::More tests => 43; # increment this value for each test you create +use Test::More tests => 44; # increment this value for each test you create use Test::Deep; use JSON qw{ from_json }; @@ -103,6 +103,14 @@ ok(exists $session->style->{_javascript}->{$_}, "$_ in style") for qw(foo bar bo # sleep so the revisiondate isn't duplicated sleep 1; +my $template3dup = $template3->duplicate; +my @atts3dup = map { delete @{ $_ }{qw/attachId templateId revisionDate/}; $_; } @{ $template3dup->getAttachments }; +cmp_bag( + [@atts3dup], + [@atts], + 'attachments are duplicated' +); + my $template3rev = $template3->addRevision(); my $att4 = $template3rev->getAttachments('headScript'); is($att4->[0]->{url}, 'foo', 'rev has foo');