Update the number of threads in the CS when a thread is archived. Fixes bug #11341.

This commit is contained in:
Colin Kuskie 2010-01-11 11:54:59 -08:00
parent b5f5f8f6e8
commit 6e0983a67b
4 changed files with 39 additions and 21 deletions

View file

@ -1,5 +1,6 @@
7.8.10
- fixed #11332: Pagination in webgui.org forum urls
- fixed #11341: tmpl_var forum.threads
7.8.9
- fixed #11235: wiki search

View file

@ -41,7 +41,7 @@ sub addRevision {
=head2 archive
Archives all posts under this thread.
Archives all posts under this thread. Update the thread count in the parent CS.
=cut
@ -50,6 +50,8 @@ sub archive {
foreach my $post (@{$self->getPosts}) {
$post->setStatusArchived;
}
my $cs = $self->getParent;
$cs->incrementThreads($cs->get("lastPostId"), $cs->get("lastPostDate"));
}
#-------------------------------------------------------------------

View file

@ -93,8 +93,8 @@ our $I18N = {
},
'forum.threads' => {
message => q|The total number of threads in this forum.|,
lastUpdated => 1149632734,
message => q|The total number of threads in this forum. This does not include those that have been archived.|,
lastUpdated => 1263239637,
},
'forum.url' => {

View file

@ -19,9 +19,15 @@ use WebGUI::Asset::Wobject::Collaboration;
use WebGUI::Asset::Post;
use WebGUI::Asset::Wobject::Layout;
use Data::Dumper;
use Test::More tests => 13; # increment this value for each test you create
use Test::More tests => 16; # increment this value for each test you create
my $session = WebGUI::Test->session;
my @addChildCoda = (undef, undef,
{
skipAutoCommitWorkflows => 1,
skipNotification => 1,
}
);
# Do our work in the import node
my $node = WebGUI::Asset->getImportNode($session);
@ -62,26 +68,23 @@ my $props = {
className => 'WebGUI::Asset::Post::Thread',
content => 'hello, world!',
};
my $post = $collab->addChild($props,
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $thread = $collab->addChild($props, @addChildCoda);
my $tag1 = WebGUI::VersionTag->getWorking($session);
$tag1->commit;
addToCleanup($tag1);
# Test for a sane object type
isa_ok($post, 'WebGUI::Asset::Post::Thread');
isa_ok($thread, 'WebGUI::Asset::Post::Thread');
$props = {
className => 'WebGUI::Asset::Post::Thread',
content => 'jello, world!',
};
$post = $collab->addChild($props,
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $thread2 = $collab->addChild($props, @addChildCoda);
my $tag2 = WebGUI::VersionTag->getWorking($session);
$tag2->commit;
addToCleanup($tag2);
my $rssitems = $collab->getRssFeedItems();
is(scalar @{ $rssitems }, 2, 'rssitems set to number of posts added');
@ -97,7 +100,19 @@ addToCleanup(WebGUI::VersionTag->new($session, $dupedCollab->get('tagId')));
ok($dupedCollab->get('getMailCronId'), 'Duplicated CS has a cron job');
isnt($dupedCollab->get('getMailCronId'), $collab->get('getMailCronId'), '... and it is different from its source asset');
TODO: {
local $TODO = "Tests to make later";
ok(0, 'A whole lot more work to do here');
}
note "Thread and Post count tests";
$collab = $collab->cloneFromDb;
is $collab->get('threads'), 2, 'CS has 2 thread';
is $collab->get('replies'), 0, '... and no replies (posts)';
$thread2->archive();
$collab = $collab->cloneFromDb;
is $collab->get('threads'), 1, 'CS lost 1 thread due to archiving';
my $thread3 = $collab->addChild($props, @addChildCoda);
my $tag3 = WebGUI::VersionTag->getWorking($session);
$tag3->commit;
addToCleanup($tag3);
$collab = $collab->cloneFromDb;
is $collab->get('threads'), 2, '... added 1 thread';