Prompt about username change at sync time, not just in prefs

This is necessary because you can copy a database synced with a
different account into the data directory without affecting the stored
pref.

Also tweak the text to use proper quotes and remove quaint references to
"the server".
This commit is contained in:
Dan Stillman 2016-04-26 16:27:49 -04:00
parent 758af2be9e
commit 098655d913
6 changed files with 157 additions and 153 deletions

View file

@ -21,6 +21,63 @@ describe("Zotero.Sync.Data.Local", function() {
})
describe("#checkUser()", function () {
it("should prompt for user update and perform on accept", function* () {
yield Zotero.Users.setCurrentUserID(1);
yield Zotero.Users.setCurrentUsername("A");
waitForDialog(function (dialog) {
var text = dialog.document.documentElement.textContent;
var matches = text.match(/'[^']*'/g);
assert.equal(matches.length, 4);
assert.equal(matches[0], "'A'");
assert.equal(matches[1], "'B'");
assert.equal(matches[2], "'B'");
assert.equal(matches[3], "'A'");
});
var cont = yield Zotero.Sync.Data.Local.checkUser(win, 2, "B");
assert.isTrue(cont);
assert.equal(Zotero.Users.getCurrentUserID(), 2);
assert.equal(Zotero.Users.getCurrentUsername(), "B");
})
it("should prompt for user update and cancel", function* () {
yield Zotero.Users.setCurrentUserID(1);
yield Zotero.Users.setCurrentUsername("A");
waitForDialog(false, 'cancel');
var cont = yield Zotero.Sync.Data.Local.checkUser(win, 2, "B");
assert.isFalse(cont);
assert.equal(Zotero.Users.getCurrentUserID(), 1);
assert.equal(Zotero.Users.getCurrentUsername(), "A");
})
it("should update local relations when syncing for the first time", function* () {
yield resetDB({
thisArg: this,
skipBundledFiles: true
});
var item1 = yield createDataObject('item');
var item2 = yield createDataObject(
'item', { libraryID: Zotero.Libraries.publicationsLibraryID }
);
yield item1.addLinkedItem(item2);
var cont = yield Zotero.Sync.Data.Local.checkUser(win, 1, "A");
assert.isTrue(cont);
var json = item1.toJSON();
var uri = json.relations[Zotero.Relations.linkedObjectPredicate][0];
assert.notInclude(uri, 'users/local');
assert.include(uri, 'users/1/publications');
})
});
describe("#getLatestCacheObjectVersions", function () {
before(function* () {
yield resetDB({