From 021b7f8fede5c0c0bae991a11ea0785a8daad756 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 10 Sep 2009 08:34:30 -0700 Subject: [PATCH] Fix import Story Archive packages with sub-stories. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Wobject/StoryArchive.pm | 3 +++ t/Asset/Wobject/StoryArchive.t | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 2fa6248f7..2b8d17190 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -31,6 +31,7 @@ - fixed #10943: ThingyRecord JS Broken - added Subscribable AssetAspect to Wiki - fixed #10941: New user profile fields with unfortunate names + - fixed #10955: Story Manager: unable to import packages 7.7.19 - fixed #10838: Forwarded forum post email to new CS adds reply to original thread diff --git a/lib/WebGUI/Asset/Wobject/StoryArchive.pm b/lib/WebGUI/Asset/Wobject/StoryArchive.pm index 16d2cf162..c69cc0b91 100644 --- a/lib/WebGUI/Asset/Wobject/StoryArchive.pm +++ b/lib/WebGUI/Asset/Wobject/StoryArchive.pm @@ -41,6 +41,9 @@ sub addChild { my $self = shift; my ($properties) = @_; ##Allow subclassing + if ($properties->{className} eq 'WebGUI::Asset::Wobject::Folder') { + return $self->SUPER::addChild(@_); + } return undef unless $properties->{className} =~ /^WebGUI::Asset::Story/; my $todayFolder = $self->getFolder; return undef unless $todayFolder; diff --git a/t/Asset/Wobject/StoryArchive.t b/t/Asset/Wobject/StoryArchive.t index 5285eb7c6..c51e8a226 100644 --- a/t/Asset/Wobject/StoryArchive.t +++ b/t/Asset/Wobject/StoryArchive.t @@ -63,7 +63,7 @@ $canPostMaker->prepare({ fail => [1, $reader ], }); -my $tests = 48 +my $tests = 50 + $canPostMaker->plan ; plan tests => 1 @@ -161,15 +161,23 @@ is($archive->getChildCount, 0, 'leaving with an empty archive'); my $child = $archive->addChild({className => 'WebGUI::Asset::Wobject::StoryTopic'}); is($child, undef, 'addChild: Will only add Stories'); +$child = $archive->addChild({className => 'WebGUI::Asset::Snippet'}); +is($child, undef, '... will not add snippets'); + +$child = $archive->addChild({className => 'WebGUI::Asset::Wobject::Folder'}); +isa_ok($child, 'WebGUI::Asset::Wobject::Folder', '... will add folders, so importing a package works'); + +$child->purge; + $child = $archive->addChild({className => 'WebGUI::Asset::Story', title => 'First Story'}, @skipAutoCommit); my $tag1 = WebGUI::VersionTag->getWorking($session); $tag1->commit; WebGUI::Test->tagsToRollback($tag1); isa_ok($child, 'WebGUI::Asset::Story', 'addChild added and returned a Story'); -is($archive->getChildCount, 1, 'addChild: added it to the archive'); +is($archive->getChildCount, 1, '... added it to the archive'); my $folder = $archive->getFirstChild(); -isa_ok($folder, 'WebGUI::Asset::Wobject::Folder', 'Folder was added to Archive'); -is($folder->getChildCount, 1, 'The folder has 1 child...'); +isa_ok($folder, 'WebGUI::Asset::Wobject::Folder', '... Folder was added to Archive'); +is($folder->getChildCount, 1, '... The folder has 1 child...'); is($folder->getFirstChild->getTitle, 'First Story', '... and it is the correct child'); ################################################################