mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #746 from sharelatex/ta-refresh-features
Refresh Features After Confirming Email
This commit is contained in:
commit
f99b6b6f0a
2 changed files with 10 additions and 1 deletions
|
@ -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'
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue