fixed broken tests in AuthenticationController

This commit is contained in:
Henry Oswald 2016-02-18 10:16:50 +00:00
parent fc4bd94a6e
commit bd54cc722a
2 changed files with 8 additions and 1 deletions

View file

@ -16,5 +16,5 @@ module.exports = UserHandler =
NotificationsBuilder.groupPlan(user, licence).create(callback) NotificationsBuilder.groupPlan(user, licence).create(callback)
setupLoginData: (user, callback = ->)-> setupLoginData: (user, callback = ->)->
_populateGroupLicenceInvite user, callback @_populateGroupLicenceInvite user, callback

View file

@ -18,6 +18,7 @@ describe "AuthenticationController", ->
"../User/UserUpdater" : @UserUpdater = {} "../User/UserUpdater" : @UserUpdater = {}
"../../infrastructure/Metrics": @Metrics = { inc: sinon.stub() } "../../infrastructure/Metrics": @Metrics = { inc: sinon.stub() }
"../Security/LoginRateLimiter": @LoginRateLimiter = { processLoginRequest:sinon.stub(), recordSuccessfulLogin:sinon.stub() } "../Security/LoginRateLimiter": @LoginRateLimiter = { processLoginRequest:sinon.stub(), recordSuccessfulLogin:sinon.stub() }
"../User/UserHandler": @UserHandler = {setupLoginData:sinon.stub()}
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() } "logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
"settings-sharelatex": {} "settings-sharelatex": {}
@user = @user =
@ -68,6 +69,9 @@ describe "AuthenticationController", ->
.calledWith(email: @email.toLowerCase(), @password) .calledWith(email: @email.toLowerCase(), @password)
.should.equal true .should.equal true
it "should setup the user data in the background", ->
@UserHandler.setupLoginData.calledWith(@user).should.equal true
it "should establish the user's session", -> it "should establish the user's session", ->
@AuthenticationController.establishUserSession @AuthenticationController.establishUserSession
.calledWith(@req, @user) .calledWith(@req, @user)
@ -109,6 +113,9 @@ describe "AuthenticationController", ->
it "should not establish a session", -> it "should not establish a session", ->
@AuthenticationController.establishUserSession.called.should.equal false @AuthenticationController.establishUserSession.called.should.equal false
it "should not setup the user data in the background", ->
@UserHandler.setupLoginData.called.should.equal false
it "should record a failed login", -> it "should record a failed login", ->
@AuthenticationController._recordFailedLogin.called.should.equal true @AuthenticationController._recordFailedLogin.called.should.equal true