diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index ec1737b..fabd721 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -218,8 +218,12 @@ class CommentsViewlet(ViewletBase, layout.FormWrapper): """Returns true if there are replies. """ if self.get_replies(workflow_actions): - self.get_replies(workflow_actions).next() - return True + try: + self.get_replies(workflow_actions).next() + return True + except StopIteration: + pass + return False def get_replies(self, workflow_actions=False): """Returns all replies to a content object. diff --git a/plone/app/discussion/tests/test_comments_viewlet.py b/plone/app/discussion/tests/test_comments_viewlet.py index 2007215..74a5045 100644 --- a/plone/app/discussion/tests/test_comments_viewlet.py +++ b/plone/app/discussion/tests/test_comments_viewlet.py @@ -134,13 +134,13 @@ class TestCommentsViewlet(PloneTestCase): self.failUnless(self.viewlet.is_discussion_allowed()) def test_has_replies(self): - self.failIf(self.viewlet.has_replies()) + self.assertEquals(self.viewlet.has_replies(), False) comment = createObject('plone.Comment') comment.title = 'Comment 1' comment.text = 'Comment text' conversation = IConversation(self.portal.doc1) conversation.addComment(comment) - self.failUnless(self.viewlet.has_replies()) + self.assertEquals(self.viewlet.has_replies(), True) def test_get_replies(self): self.failIf(self.viewlet.get_replies())