Threads should not show pagination query params in their URLs.

This commit is contained in:
Colin Kuskie 2010-01-07 08:34:27 -08:00
parent 2605a4c989
commit b5f5f8f6e8
3 changed files with 28 additions and 1 deletions

View file

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

View file

@ -336,6 +336,26 @@ sub getAutoCommitWorkflowId {
return $self->getThread->getParent->get("threadApprovalWorkflow");
}
#-------------------------------------------------------------------
=head2 getDirectLinkUrl ( )
Extend the base method from Post to remove the pagination query fragment
=cut
sub getDirectLinkUrl {
my $self = shift;
my $url = $self->SUPER::getDirectLinkUrl();
$url =~ s/\?pn=\d+//;
if ($url =~ m{;revision=\d+}) {
$url =~ s/;revision/?revision/;
}
return $url;
}
#-------------------------------------------------------------------
=head2 getLastPost

View file

@ -13,7 +13,7 @@ use strict;
use lib "$FindBin::Bin/../../lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 2; # increment this value for each test you create
use Test::More tests => 5; # increment this value for each test you create
use Test::MockObject::Extends;
use WebGUI::Asset::Wobject::Collaboration;
use WebGUI::Asset::Post::Thread;
@ -44,6 +44,8 @@ my $thread = $collab->addChild($props, @addArgs);
$versionTag->commit();
my $uncommittedThread = $collab->addChild($props, @addArgs);
# Test for a sane object type
isa_ok($thread, 'WebGUI::Asset::Post::Thread');
@ -61,4 +63,8 @@ $thread->rate(1);
$thread->trash;
is($thread->get('threadRating'), 0, 'trash does not die, and updates the threadRating to 0');
unlike $thread->getDirectLinkUrl, qr/\?pn=\d+/, 'threads do not need pagination url query fragments';
unlike $uncommittedThread->getDirectLinkUrl, qr/\?pn=\d+/, 'uncommitted threads, too';
like $uncommittedThread->getDirectLinkUrl, qr/\?revision=\d+/, 'uncommitted threads do have a revision query param';
# vim: syntax=perl filetype=perl