From b43a735b93051da1cd867d5eed1927b797973350 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 8 Jun 2015 03:01:19 -0400 Subject: [PATCH] Include libraryID in group.erase() notifier data --- chrome/content/zotero/xpcom/data/group.js | 8 +++++++- test/tests/groupTest.js | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/data/group.js b/chrome/content/zotero/xpcom/data/group.js index 9d36e5b33a..a17e52ab24 100644 --- a/chrome/content/zotero/xpcom/data/group.js +++ b/chrome/content/zotero/xpcom/data/group.js @@ -260,6 +260,8 @@ Zotero.Group.prototype.save = Zotero.Promise.coroutine(function* () { * Deletes group and all descendant objects **/ Zotero.Group.prototype.erase = Zotero.Promise.coroutine(function* () { + Zotero.debug("Removing group " + this.id); + Zotero.DB.requireTransaction(); // Delete items @@ -291,7 +293,11 @@ Zotero.Group.prototype.erase = Zotero.Promise.coroutine(function* () { Zotero.Groups.unregister(this.id); //yield Zotero.purgeDataObjects(); }.bind(this)) - Zotero.Notifier.queue('delete', 'group', this.id); + var notifierData = {}; + notifierData[this.id] = { + libraryID: this.libraryID + }; + Zotero.Notifier.queue('delete', 'group', this.id, notifierData); }); diff --git a/test/tests/groupTest.js b/test/tests/groupTest.js index 18a3c9888b..2868f4cc67 100644 --- a/test/tests/groupTest.js +++ b/test/tests/groupTest.js @@ -10,6 +10,26 @@ describe("Zotero.Group", function () { }.bind(this)); assert.isFalse(Zotero.Groups.exists(id)); }) + + it("should provide libraryID in extraData", function* () { + var group = yield createGroup(); + var libraryID = group.libraryID; + + var deferred = Zotero.Promise.defer(); + var observerID = Zotero.Notifier.registerObserver({ + notify: function (event, type, ids, extraData) { + deferred.resolve(extraData[ids[0]]); + } + }, ['group'], "test"); + try { + yield group.eraseTx(); + let extraData = yield deferred.promise; + assert.equal(extraData.libraryID, libraryID); + } + finally { + Zotero.Notifier.unregisterObserver(observerID); + } + }) }) describe("#fromJSON()", function () {