Fix saving an item with a child note into a collection

This commit is contained in:
Dan Stillman 2016-03-25 02:23:45 -04:00
parent c5702abb7b
commit afee1d16ad
3 changed files with 29 additions and 1 deletions

View file

@ -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();

View file

@ -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();

View file

@ -0,0 +1,5 @@
TY - BOOK
TI - Parent
N1 - <p>Child</p>
ER -