Make sure the comment brains are updated properly when the content object is renamed. Thanks hannosch for the code review.
svn path=/plone.app.discussion/trunk/; revision=51526
This commit is contained in:
parent
ca163009cc
commit
0e47299c75
@ -1,6 +1,14 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
2.1.0 (unreleased)
|
||||
------------------
|
||||
|
||||
- Make sure the comment brains are updated properly when the content object is
|
||||
renamed.
|
||||
[hannosch, timo]
|
||||
|
||||
|
||||
2.0.9 (2011-07-25)
|
||||
------------------
|
||||
|
||||
|
@ -223,8 +223,7 @@ def notify_content_object_moved(obj, event):
|
||||
"""Update all comments of a content object that has been moved.
|
||||
"""
|
||||
if event.oldParent is None or event.newParent is None \
|
||||
or event.oldName is None or event.newName is None \
|
||||
or event.oldParent == event.newParent:
|
||||
or event.oldName is None or event.newName is None:
|
||||
return
|
||||
# Remove comments at the old location from catalog
|
||||
catalog = getToolByName(obj, 'portal_catalog')
|
||||
|
@ -314,6 +314,18 @@ class CommentCatalogTest(unittest.TestCase):
|
||||
'/plone/folder1/doc1/++conversation++default/' +
|
||||
str(self.comment_id))
|
||||
|
||||
def test_update_comments_when_content_object_is_renamed(self):
|
||||
# We need to commit here so that _p_jar isn't None and move will work
|
||||
transaction.savepoint(optimistic=True)
|
||||
|
||||
self.portal.manage_renameObject("doc1", "doc2")
|
||||
|
||||
brains = self.catalog.searchResults(portal_type = 'Discussion Item')
|
||||
self.assertEquals(len(brains), 1)
|
||||
self.assertEquals(brains[0].getPath(),
|
||||
'/plone/doc2/++conversation++default/' +
|
||||
str(self.comment_id))
|
||||
|
||||
def test_clear_and_rebuild_catalog(self):
|
||||
# Clear and rebuild catalog
|
||||
self.catalog.clearFindAndRebuild()
|
||||
|
Loading…
Reference in New Issue
Block a user