www

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

commit afee1d16ad54e70548545bde7577dbaa673def95
parent c5702abb7beedcc329d75ce515ce38678d77d172
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 25 Mar 2016 02:23:45 -0400

Fix saving an item with a child note into a collection

Diffstat:
Mchrome/content/zotero/xpcom/translation/translate_item.js | 2+-
Mtest/tests/browserTest.js | 23+++++++++++++++++++++++
Atest/tests/data/book_and_child_note.ris | 5+++++
3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -600,7 +600,7 @@ Zotero.Translate.ItemSaver.prototype = { } else { myNote.setNote(note); } - if (this._collections) { + if (!parentID && this._collections) { myNote.setCollections(this._collections); } yield myNote.save(); diff --git a/test/tests/browserTest.js b/test/tests/browserTest.js @@ -55,6 +55,29 @@ describe("Zotero_Browser", function () { assert.isTrue(collection.hasItem(items[0].id)); }) + it("should save book with child note to current collection", function* () { + var uri = OS.Path.join( + getTestDataDirectory().path, "book_and_child_note.ris" + ); + var deferred = Zotero.Promise.defer(); + win.addEventListener('pageshow', () => deferred.resolve()); + win.loadURI(uri); + yield deferred.promise; + + yield loadZoteroPane(win); + var collection = yield createDataObject('collection'); + + var promise = waitForItemEvent('add'); + yield win.Zotero_Browser.scrapeThisPage(); + + var ids = yield promise; + var items = Zotero.Items.get(ids); + assert.lengthOf(items, 2); + assert.equal(Zotero.ItemTypes.getName(items[0].itemTypeID), 'book'); + assert.isTrue(collection.hasItem(items[0].id)); + assert.equal(Zotero.ItemTypes.getName(items[1].itemTypeID), 'note'); + }); + it("should save PDF to library root", function* () { var uri = OS.Path.join(getTestDataDirectory().path, "test.pdf"); var deferred = Zotero.Promise.defer(); diff --git a/test/tests/data/book_and_child_note.ris b/test/tests/data/book_and_child_note.ris @@ -0,0 +1,5 @@ +TY - BOOK +TI - Parent +N1 - <p>Child</p> +ER - +