fix catalog clear-and-rebuild. this finally fixes story 847941.
svn path=/plone.app.discussion/trunk/; revision=30610
This commit is contained in:
parent
9befc4c651
commit
f4a4b6e370
@ -30,7 +30,6 @@ def patchedClearFindAndRebuild(self):
|
||||
conversation = conversation.__of__(obj)
|
||||
for comment in conversation.getComments():
|
||||
try:
|
||||
comment = conversation.getComments().next()
|
||||
comment = comment.__of__(conversation)
|
||||
if catalog:
|
||||
catalog.indexObject(comment)
|
||||
|
@ -196,6 +196,8 @@ class CommentCatalogTest(PloneTestCase):
|
||||
|
||||
conversation = IConversation(self.portal.doc1)
|
||||
|
||||
self.conversation = conversation
|
||||
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.title = 'Comment 1'
|
||||
comment1.text = 'Comment text'
|
||||
@ -239,5 +241,61 @@ class CommentCatalogTest(PloneTestCase):
|
||||
comment_brain = brains[0]
|
||||
self.assertEquals(comment_brain.Title, 'Comment 1')
|
||||
|
||||
def test_clear_and_rebuild_catalog_for_nested_comments(self):
|
||||
|
||||
# Create a nested comment structure:
|
||||
#
|
||||
# Conversation
|
||||
# +- Comment 1
|
||||
# +- Comment 1_1
|
||||
# | +- Comment 1_1_1
|
||||
# +- Comment 1_2
|
||||
# +- Comment 2
|
||||
# +- Comment 2_1
|
||||
|
||||
comment1_1 = createObject('plone.Comment')
|
||||
comment1_1.title = 'Re: Comment 1'
|
||||
comment1_1.text = 'Comment text'
|
||||
|
||||
comment1_1_1 = createObject('plone.Comment')
|
||||
comment1_1_1.title = 'Re: Re: Comment 1'
|
||||
comment1_1_1.text = 'Comment text'
|
||||
|
||||
comment1_2 = createObject('plone.Comment')
|
||||
comment1_2.title = 'Re: Comment 1 (2)'
|
||||
comment1_2.text = 'Comment text'
|
||||
|
||||
comment2 = createObject('plone.Comment')
|
||||
comment2.title = 'Comment 2'
|
||||
comment2.text = 'Comment text'
|
||||
|
||||
comment2_1 = createObject('plone.Comment')
|
||||
comment2_1.title = 'Re: Comment 2'
|
||||
comment2_1.text = 'Comment text'
|
||||
|
||||
# Create the nested comment structure
|
||||
new_id_1 = self.conversation.addComment(self.comment)
|
||||
new_id_2 = self.conversation.addComment(comment2)
|
||||
|
||||
comment1_1.in_reply_to = self.comment_id
|
||||
new_id_1_1 = self.conversation.addComment(comment1_1)
|
||||
|
||||
comment1_1_1.in_reply_to = new_id_1_1
|
||||
new_id_1_1_1 = self.conversation.addComment(comment1_1_1)
|
||||
|
||||
comment1_2.in_reply_to = new_id_1
|
||||
new_id_1_2 = self.conversation.addComment(comment1_2)
|
||||
|
||||
comment2_1.in_reply_to = new_id_2
|
||||
new_id_2_1 = self.conversation.addComment(comment2_1)
|
||||
|
||||
# Clear and rebuild catalog
|
||||
self.catalog.clearFindAndRebuild()
|
||||
|
||||
# Check if comments are still there
|
||||
brains = self.catalog.searchResults(portal_type = 'Discussion Item')
|
||||
self.failUnless(brains)
|
||||
self.assertEquals(len(brains), 6)
|
||||
|
||||
def test_suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
Loading…
Reference in New Issue
Block a user