diff --git a/chrome/content/zotero/xpcom/data/group.js b/chrome/content/zotero/xpcom/data/group.js index a17e52ab24..71b8a9948c 100644 --- a/chrome/content/zotero/xpcom/data/group.js +++ b/chrome/content/zotero/xpcom/data/group.js @@ -192,6 +192,10 @@ Zotero.Group.prototype.save = Zotero.Promise.coroutine(function* () { throw new Error("Group id not set"); } + if (!this.name) { + throw new Error("Group name not set"); + } + if (!this._changed) { Zotero.debug("Group " + this.id + " has not changed"); return false; @@ -319,14 +323,14 @@ Zotero.Group.prototype.fromJSON = function (json, userID) { if (userID) { // If user is owner or admin, make library editable, and make files editable unless they're // disabled altogether - if (json.owner == userID || json.admins.indexOf(userID) != -1) { + if (json.owner == userID || (json.admins && json.admins.indexOf(userID) != -1)) { editable = true; if (json.fileEditing != 'none') { filesEditable = true; } } // If user is member, make library and files editable if they're editable by all members - else if (json.members.indexOf(userID) != -1) { + else if (json.members && json.members.indexOf(userID) != -1) { if (json.libraryEditing == 'members') { editable = true; if (json.fileEditing == 'members') { diff --git a/test/tests/groupTest.js b/test/tests/groupTest.js index 2868f4cc67..00190e71e4 100644 --- a/test/tests/groupTest.js +++ b/test/tests/groupTest.js @@ -133,7 +133,7 @@ describe("Zotero.Group", function () { owner: 1, libraryEditing: 'members', fileEditing: 'none', - admins: [2], + // No admins members: [3] }, 3); assert.isTrue(group.editable);