Skip skipped groups when syncing

Except if a library list is passed to Zotero.Sync.Data.Runner.sync() (which
isn't done currently but will be in #1053)

Follow-up to #1033
This commit is contained in:
Dan Stillman 2016-06-27 16:42:55 -04:00
parent b0f3a234d0
commit 9e6565fe00
3 changed files with 90 additions and 1 deletions

View file

@ -166,7 +166,13 @@ describe("Zotero.Sync.Runner", function () {
})
describe("#checkLibraries()", function () {
beforeEach(function* () {
Zotero.Prefs.clear('sync.librariesToSkip');
});
afterEach(function* () {
Zotero.Prefs.clear('sync.librariesToSkip');
var group = Zotero.Groups.get(responses.groups.ownerGroup.json.id);
if (group) {
yield group.eraseTx();
@ -243,6 +249,48 @@ describe("Zotero.Sync.Runner", function () {
assert.sameMembers(libraries, [group1.libraryID]);
})
it("should filter out skipped libraries if library list not provided", function* () {
var unskippedGroupID = responses.groups.ownerGroup.json.id;
var skippedGroupID = responses.groups.memberGroup.json.id;
Zotero.Prefs.set('sync.librariesToSkip', `["L4", "G${skippedGroupID}"]`);
setResponse('userGroups.groupVersions');
setResponse('groups.ownerGroup');
setResponse('groups.memberGroup');
var libraries = yield runner.checkLibraries(
runner.getAPIClient({ apiKey }),
false,
responses.keyInfo.fullAccess.json
);
var group = Zotero.Groups.get(unskippedGroupID);
assert.lengthOf(libraries, 2);
assert.sameMembers(libraries, [userLibraryID, group.libraryID]);
});
it("shouldn't filter out skipped libraries if library list is provided", function* () {
var groupData = responses.groups.memberGroup;
var group = yield createGroup({
id: groupData.json.id,
version: groupData.json.version
});
Zotero.Prefs.set('sync.librariesToSkip', `["L4", "G${group.id}"]`);
setResponse('userGroups.groupVersions');
setResponse('groups.ownerGroup');
setResponse('groups.memberGroup');
var libraries = yield runner.checkLibraries(
runner.getAPIClient({ apiKey }),
false,
responses.keyInfo.fullAccess.json,
[userLibraryID, publicationsLibraryID, group.libraryID]
);
assert.lengthOf(libraries, 3);
assert.sameMembers(libraries, [userLibraryID, publicationsLibraryID, group.libraryID]);
});
it("should update outdated group metadata", function* () {
// Create groups with same id as groups response but earlier versions
var groupData1 = responses.groups.ownerGroup;