www

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

commit 4d56191f0cea1628579e219af74cacbd05cc3b9c
parent a33c53dcdbab4a826e7d93b63a9eef52f7c434bf
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 27 Jan 2017 20:51:12 -0500

Fix importing of files using relative paths

Diffstat:
Mchrome/content/zotero/xpcom/translation/translate_item.js | 2+-
Mtest/tests/translateTest.js | 39+++++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -57,7 +57,7 @@ Zotero.Translate.ItemSaver = function(options) { this._proxy = options.proxy; // the URI to which other URIs are assumed to be relative - if(typeof baseURI === "object" && baseURI instanceof Components.interfaces.nsIURI) { + if(typeof options.baseURI === "object" && options.baseURI instanceof Components.interfaces.nsIURI) { this._baseURI = options.baseURI; } else { // try to convert to a URI diff --git a/test/tests/translateTest.js b/test/tests/translateTest.js @@ -597,6 +597,45 @@ describe("Zotero.Translate", function() { }); }); + + describe("Translators", function () { + it("should round-trip child attachment via BibTeX", function* () { + var item = yield createDataObject('item'); + yield importFileAttachment('test.png', { parentItemID: item.id }); + + var translation = new Zotero.Translate.Export(); + var tmpDir = yield getTempDirectory(); + var exportDir = OS.Path.join(tmpDir, 'export'); + translation.setLocation(Zotero.File.pathToFile(exportDir)); + translation.setItems([item]); + translation.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); + translation.setDisplayOptions({ + exportFileData: true + }); + yield translation.translate(); + + var exportFile = OS.Path.join(exportDir, 'export.bib'); + assert.isTrue(yield OS.File.exists(exportFile)); + + var translation = new Zotero.Translate.Import(); + translation.setLocation(Zotero.File.pathToFile(exportFile)); + var translators = yield translation.getTranslators(); + translation.setTranslator(translators[0]); + var importCollection = yield createDataObject('collection'); + var items = yield translation.translate({ + libraryID: Zotero.Libraries.userLibraryID, + collections: [importCollection.id] + }); + + assert.lengthOf(items, 1); + var attachments = items[0].getAttachments(); + assert.lengthOf(attachments, 1); + var attachment = Zotero.Items.get(attachments[0]); + assert.isTrue(yield attachment.fileExists()); + }); + }); + + describe("ItemSaver", function () { describe("#saveCollections()", function () { it("should add top-level collections to specified collection", function* () {