Update hasChildCollections() when child moved to another collection
This commit is contained in:
parent
5a61ac4871
commit
9fa53439ef
2 changed files with 24 additions and 1 deletions
|
@ -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
|
||||
);
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue