Exception and class handling for getLastPost in the Thread. Update a test accordingly.
This commit is contained in:
parent
4056d7019e
commit
9e50f5e8c2
2 changed files with 7 additions and 7 deletions
|
|
@ -410,12 +410,12 @@ Fetches the last post in this thread, otherwise, returns itself.
|
|||
sub getLastPost {
|
||||
my $self = shift;
|
||||
my $lastPostId = $self->lastPostId;
|
||||
my $lastPost;
|
||||
if ($lastPostId) {
|
||||
$lastPost = WebGUI::Asset::Post->newById($self->session, $lastPostId);
|
||||
}
|
||||
return $lastPost if (defined $lastPost);
|
||||
return $self;
|
||||
return $self unless $lastPostId;
|
||||
my $lastPost = eval { WebGUI::Asset->newById($self->session, $lastPostId); };
|
||||
if (Exception::Class->caught()) {
|
||||
return $self;
|
||||
}
|
||||
return $lastPost;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ ok( !$posts->[0]->{'user.isVisitor'}, 'first post made by visitor');
|
|||
ok( $posts->[0]->{'hideProfileUrl'}, 'hide profile url, and user is visitor');
|
||||
ok( !$posts->[0]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
|
||||
ok( $posts->[0]->{'lastReply.hideProfileUrl'}, 'lastReply hide profile url, since user is visitor');
|
||||
is( $posts->[0]->{'lastReply.url'}, $threads[1]->getUrl.'?pn=1#id'.$threads[1]->getId, 'lastReply url has a query fragment prefixed by "id"');
|
||||
is( $posts->[0]->{'lastReply.url'}, $threads[1]->getUrl.'#id'.$threads[1]->getId, 'lastReply url has a query fragment prefixed by "id"');
|
||||
is( $posts->[0]->{'url'}, $threads[1]->getUrl.'#id'.$threads[1]->getId, 'url has a query fragment prefixed by "id"');
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue