commit 0803bb84e359db2f8febdffcc028196da0ff2ae1
parent 5c32962bb113fffd856372ff4920f63d8b8f0365
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 29 Oct 2015 03:03:25 -0400
Don't set collections: "" in PATCH JSON when changing item to child
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git 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
@@ -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