www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 9fa53439ef348e0fa0e139f775bbb3d4d3313711
parent 5a61ac48715f554426e700716de4e87227636f79
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sat,  8 Aug 2015 16:45:51 -0400

Update hasChildCollections() when child moved to another collection

Diffstat:
Mchrome/content/zotero/xpcom/data/collection.js | 2+-
Mtest/tests/collectionTest.js | 23+++++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)

diff --git 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 @@ -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');