diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js index 8c4e11718b..1060128766 100644 --- a/chrome/content/zotero/xpcom/data/collection.js +++ b/chrome/content/zotero/xpcom/data/collection.js @@ -326,7 +326,7 @@ Zotero.Collection.prototype._saveData = Zotero.Promise.coroutine(function* (env) } // Remove this from the previous parent's cached collection lists after commit, // if the parent was loaded - else if (!isNew && this._previousData.parentKey) { + if (!isNew && this._previousData.parentKey) { let parentCollectionID = this.ObjectsClass.getIDFromLibraryAndKey( this.libraryID, this._previousData.parentKey ); diff --git a/test/tests/collectionTest.js b/test/tests/collectionTest.js index a4ea2cde88..ca7ef3d7cb 100644 --- a/test/tests/collectionTest.js +++ b/test/tests/collectionTest.js @@ -98,6 +98,29 @@ describe("Zotero.Collection", function() { }); }) + describe("#hasChildCollections()", function () { + it("should be false if child made top-level", function* () { + var collection1 = yield createDataObject('collection'); + var collection2 = yield createDataObject('collection', { parentID: collection1.id }); + + assert.isTrue(collection1.hasChildCollections()); + collection2.parentKey = false; + yield collection2.saveTx(); + assert.isFalse(collection1.hasChildCollections()); + }) + + it("should be false if child moved to another collection", function* () { + var collection1 = yield createDataObject('collection'); + var collection2 = yield createDataObject('collection', { parentID: collection1.id }); + var collection3 = yield createDataObject('collection'); + + assert.isTrue(collection1.hasChildCollections()); + collection2.parentKey = collection3.key; + yield collection2.saveTx(); + assert.isFalse(collection1.hasChildCollections()); + }) + }) + describe("#getChildCollections()", function () { it("should include child collections", function* () { var collection1 = yield createDataObject('collection');