Merge pull request #746 from sharelatex/ta-refresh-features

Refresh Features After Confirming Email
This commit is contained in:
James Allen 2018-07-24 10:04:48 +01:00 committed by GitHub
commit f99b6b6f0a
2 changed files with 10 additions and 1 deletions

View file

@ -6,6 +6,7 @@ async = require("async")
ObjectId = mongojs.ObjectId
UserGetter = require("./UserGetter")
{ addAffiliation, removeAffiliation } = require("./UserAffiliationsManager")
FeaturesUpdater = require("../Subscription/FeaturesUpdater")
EmailHelper = require "../Helpers/EmailHelper"
Errors = require "../Errors/Errors"
@ -126,7 +127,7 @@ module.exports = UserUpdater =
logger.log {res, userId, email}, "tried to confirm email"
if res.n == 0
return callback(new Errors.NotFoundError('user id and email do no match'))
callback()
FeaturesUpdater.refreshFeatures userId, true, callback
[
'updateUser'

View file

@ -21,12 +21,14 @@ describe "UserUpdater", ->
@logger = err: sinon.stub(), log: ->
@addAffiliation = sinon.stub().yields()
@removeAffiliation = sinon.stub().callsArgWith(2, null)
@refreshFeatures = sinon.stub().yields()
@UserUpdater = SandboxedModule.require modulePath, requires:
"logger-sharelatex": @logger
"./UserGetter": @UserGetter
'./UserAffiliationsManager':
addAffiliation: @addAffiliation
removeAffiliation: @removeAffiliation
'../Subscription/FeaturesUpdater': refreshFeatures: @refreshFeatures
"../../infrastructure/mongojs":@mongojs
"metrics-sharelatex": timeAsyncMethod: sinon.stub()
@ -245,3 +247,9 @@ describe "UserUpdater", ->
should.exist(err)
@UserUpdater.updateUser.called.should.equal false
done()
it 'refresh features', (done)->
@UserUpdater.confirmEmail @stubbedUser._id, @newEmail, (err)=>
should.not.exist(err)
sinon.assert.calledWith(@refreshFeatures, @stubbedUser._id, true)
done()