set user email on session again on change email

This commit is contained in:
Henry Oswald
2016-06-06 10:50:45 +01:00
parent 2339cda318
commit 829b37cd74
2 changed files with 19 additions and 2 deletions
@@ -57,7 +57,9 @@ describe "UserController", ->
"../Subscription/SubscriptionDomainHandler":@SubscriptionDomainHandler
"./UserHandler":@UserHandler
"settings-sharelatex": @settings
"logger-sharelatex": {log:->}
"logger-sharelatex":
log:->
err:->
"../../infrastructure/Metrics": inc:->
@req =
@@ -65,6 +67,7 @@ describe "UserController", ->
destroy:->
user :
_id : @user_id
email:"old@something.com"
body:{}
@res =
send: sinon.stub()
@@ -154,6 +157,20 @@ describe "UserController", ->
done()
@UserController.updateUserSettings @req, @res
it "should update the email on the session", (done)->
@req.body.email = @newEmail.toUpperCase()
@UserUpdater.changeEmailAddress.callsArgWith(2)
callcount = 0
@User.findById = (id, cb)=>
if ++callcount == 2
@user.email = @newEmail
cb(null, @user)
@res.sendStatus = (code)=>
code.should.equal 200
@req.session.user.email.should.equal @newEmail
done()
@UserController.updateUserSettings @req, @res
it "should call populateGroupLicenceInvite", (done)->
@req.body.email = @newEmail.toUpperCase()
@UserUpdater.changeEmailAddress.callsArgWith(2)