Fix #1100, Deleting collection also deletes items

This commit is contained in:
Dan Stillman 2016-09-27 02:10:14 -04:00
parent 2e8e3ffa5d
commit 4dc6ef3045
2 changed files with 23 additions and 3 deletions

View file

@ -1181,9 +1181,7 @@ Zotero.CollectionTreeView.prototype.deleteSelection = Zotero.Promise.coroutine(f
//erase collection from DB:
var treeRow = this.getRow(rows[i]-i);
if (treeRow.isCollection() || treeRow.isFeed()) {
yield treeRow.ref.eraseTx({
deleteItems: true
});
yield treeRow.ref.eraseTx({ deleteItems });
if (treeRow.isFeed()) {
refreshFeeds = true;
}

View file

@ -230,6 +230,28 @@ describe("ZoteroPane", function() {
})
})
describe("#deleteSelectedCollection()", function () {
it("should delete collection but not descendant items by default", function* () {
var collection = yield createDataObject('collection');
var item = yield createDataObject('item', { collections: [collection.id] });
var promise = waitForDialog();
yield zp.deleteSelectedCollection();
assert.isFalse(Zotero.Collections.exists(collection.id));
assert.isTrue(Zotero.Items.exists(item.id));
assert.isFalse(item.deleted);
});
it("should delete collection and descendant items when deleteItems=true", function* () {
var collection = yield createDataObject('collection');
var item = yield createDataObject('item', { collections: [collection.id] });
var promise = waitForDialog();
yield zp.deleteSelectedCollection(true);
assert.isFalse(Zotero.Collections.exists(collection.id));
assert.isTrue(Zotero.Items.exists(item.id));
assert.isTrue(item.deleted);
});
});
describe("#setVirtual()", function () {
var cv;