From 4dc6ef3045dfd257066d166f94d904ae4dfc45dd Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 27 Sep 2016 02:10:14 -0400 Subject: [PATCH] Fix #1100, Deleting collection also deletes items --- .../zotero/xpcom/collectionTreeView.js | 4 +--- test/tests/zoteroPaneTest.js | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index 6976e4ade..143a02757 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -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; } diff --git a/test/tests/zoteroPaneTest.js b/test/tests/zoteroPaneTest.js index ff1cd084f..f7c47eb3e 100644 --- a/test/tests/zoteroPaneTest.js +++ b/test/tests/zoteroPaneTest.js @@ -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;