2018-05-25 07:04:09 -04:00
|
|
|
should = require('chai').should()
|
|
|
|
async = require("async")
|
|
|
|
User = require "./helpers/User"
|
2018-09-20 09:59:30 -04:00
|
|
|
MockV1Api = require './helpers/MockV1Api'
|
2018-05-25 07:04:09 -04:00
|
|
|
|
|
|
|
describe 'SettingsPage', ->
|
|
|
|
|
|
|
|
before (done) ->
|
|
|
|
@user = new User()
|
2018-09-20 09:59:30 -04:00
|
|
|
@v1Id = 1234
|
|
|
|
@v1User =
|
|
|
|
id: @v1Id
|
|
|
|
email: @user.email
|
|
|
|
password: @user.password
|
|
|
|
profile:
|
|
|
|
id: @v1Id
|
|
|
|
email: @user.email
|
2018-05-25 07:04:09 -04:00
|
|
|
async.series [
|
|
|
|
@user.ensureUserExists.bind(@user)
|
|
|
|
@user.login.bind(@user)
|
2018-09-20 09:59:30 -04:00
|
|
|
(cb) => @user.mongoUpdate {$set: {'overleaf.id': @v1Id}}, cb
|
|
|
|
(cb) =>
|
|
|
|
MockV1Api.setUser @v1Id, @v1User
|
|
|
|
cb()
|
2018-05-25 07:04:09 -04:00
|
|
|
@user.activateSudoMode.bind(@user)
|
|
|
|
], done
|
|
|
|
|
2018-09-20 09:59:30 -04:00
|
|
|
it 'load settings page', (done) ->
|
2018-05-25 07:04:09 -04:00
|
|
|
@user.getUserSettingsPage (err, statusCode) ->
|
|
|
|
statusCode.should.equal 200
|
|
|
|
done()
|
|
|
|
|
|
|
|
it 'update main email address', (done) ->
|
|
|
|
newEmail = 'foo@bar.com'
|
|
|
|
@user.updateSettings email: newEmail, (error) =>
|
|
|
|
should.not.exist error
|
|
|
|
@user.get (error, user) ->
|
|
|
|
user.email.should.equal newEmail
|
|
|
|
user.emails.length.should.equal 1
|
|
|
|
user.emails[0].email.should.equal newEmail
|
|
|
|
done()
|