From 0803bb84e359db2f8febdffcc028196da0ff2ae1 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 29 Oct 2015 03:03:25 -0400 Subject: [PATCH] Don't set collections: "" in PATCH JSON when changing item to child --- .../content/zotero/xpcom/data/dataObjectUtilities.js | 5 +++++ test/tests/dataObjectUtilitiesTest.js | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/chrome/content/zotero/xpcom/data/dataObjectUtilities.js b/chrome/content/zotero/xpcom/data/dataObjectUtilities.js index 0cba7a299..c95b47b26 100644 --- a/chrome/content/zotero/xpcom/data/dataObjectUtilities.js +++ b/chrome/content/zotero/xpcom/data/dataObjectUtilities.js @@ -132,6 +132,11 @@ Zotero.DataObjectUtilities = { // If field from base doesn't exist in new version, clear it else { switch (i) { + // When changing an item from top-level to child, the collections property is + // no valid, so it doesn't need to be cleared + case 'collections': + break; + case 'deleted': target[i] = false; break; diff --git a/test/tests/dataObjectUtilitiesTest.js b/test/tests/dataObjectUtilitiesTest.js index 414484cd1..99caea1eb 100644 --- a/test/tests/dataObjectUtilitiesTest.js +++ b/test/tests/dataObjectUtilitiesTest.js @@ -1,6 +1,17 @@ "use strict"; describe("Zotero.DataObjectUtilities", function() { + describe("#patch()", function () { + it("should omit 'collections' if it doesn't exist", function* () { + var patchBase = { + collections: ['AAAAAAAA'] + }; + var obj = {}; + obj = Zotero.DataObjectUtilities.patch(patchBase, obj); + assert.notProperty(obj, 'collections'); + }) + }) + describe("#diff()", function () { // This is mostly covered by syncLocal::_reconcileChanges() tests, but we test some // additional things here