Add version option to toResponseJSON()

This commit is contained in:
Dan Stillman 2018-01-26 03:33:01 -05:00
parent 3390f2405b
commit d67c654245
2 changed files with 8 additions and 4 deletions

View file

@ -1252,12 +1252,16 @@ Zotero.DataObject.prototype._finalizeErase = Zotero.Promise.coroutine(function*
Zotero.DataObject.prototype.toResponseJSON = function (options) {
// TODO: library block?
return {
var json = {
key: this.key,
version: this.version,
meta: {},
data: this.toJSON(options)
};
if (options.version) {
json.version = json.data.version = options.version;
}
return json;
}

View file

@ -782,9 +782,9 @@ describe("Zotero.Sync.Data.Engine", function () {
},
JSON.stringify({
successful: {
"0": item2.toResponseJSON(),
"1": item1.toResponseJSON(),
"2": item3.toResponseJSON()
"0": item2.toResponseJSON({ version: lastLibraryVersion }),
"1": item1.toResponseJSON({ version: lastLibraryVersion }),
"2": item3.toResponseJSON({ version: lastLibraryVersion })
},
unchanged: {},
failed: {}