Merge pull request #3303 from overleaf/jpa-fix-user-model

[model] User: third-party-references is owner of .refProviders entries

GitOrigin-RevId: 8ac81869657f4fe7615928eae2ad3d93d24cef0f
This commit is contained in:
Jakob Ackermann 2020-10-21 11:48:16 +02:00 committed by Copybot
parent 7088651c0c
commit 21070a01a8
2 changed files with 23 additions and 2 deletions

View file

@ -141,8 +141,9 @@ const UserSchema = new Schema({
refered_users: [{ type: ObjectId, ref: 'User' }],
refered_user_count: { type: Number, default: 0 },
refProviders: {
mendeley: Boolean, // coerce the refProviders values to Booleans
zotero: Boolean
// The actual values are managed by third-party-references.
mendeley: Schema.Types.Mixed,
zotero: Schema.Types.Mixed
},
alphaProgram: { type: Boolean, default: false }, // experimental features
betaProgram: { type: Boolean, default: false },

View file

@ -59,4 +59,24 @@ describe('SettingsPage', function() {
})
})
})
describe('with third-party-references configured', function() {
beforeEach(function injectThirdPartyReferencesEntryIntoDb(done) {
this.user.mongoUpdate(
{ $set: { refProviders: { zotero: { encrypted: '2020.9:SNIP' } } } },
done
)
})
it('should be able to update settings', function(done) {
const newName = 'third-party-references'
this.user.updateSettings({ first_name: newName }, error => {
should.not.exist(error)
this.user.get((error, user) => {
user.first_name.should.equal(newName)
done()
})
})
})
})
})