on register try and auto allocate a group licence if one exists

This commit is contained in:
Henry Oswald 2015-01-27 18:22:51 +00:00
parent 3360b3c35a
commit 0a64c1c8ac
2 changed files with 11 additions and 0 deletions

View file

@ -10,6 +10,7 @@ AuthenticationController = require("../Authentication/AuthenticationController")
AuthenticationManager = require("../Authentication/AuthenticationManager")
ReferalAllocator = require("../Referal/ReferalAllocator")
UserUpdater = require("./UserUpdater")
SubscriptionDomainAllocator = require("../Subscription/SubscriptionDomainAllocator")
module.exports =
@ -91,6 +92,7 @@ module.exports =
req.session.user = user
req.session.justRegistered = true
ReferalAllocator.allocate req.session.referal_id, user._id, req.session.referal_source, req.session.referal_medium
SubscriptionDomainAllocator.autoAllocate(user)
res.send
redir:redir
id:user._id.toString()

View file

@ -35,6 +35,8 @@ describe "UserController", ->
setUserPassword: sinon.stub()
@ReferalAllocator =
allocate:sinon.stub()
@SubscriptionDomainAllocator =
autoAllocate:sinon.stub()
@UserUpdater =
changeEmailAddress:sinon.stub()
@UserController = SandboxedModule.require modulePath, requires:
@ -47,6 +49,7 @@ describe "UserController", ->
"../Authentication/AuthenticationController": @AuthenticationController
"../Authentication/AuthenticationManager": @AuthenticationManager
"../Referal/ReferalAllocator":@ReferalAllocator
"../Subscription/SubscriptionDomainAllocator":@SubscriptionDomainAllocator
"logger-sharelatex": {log:->}
@ -212,6 +215,12 @@ describe "UserController", ->
done()
@UserController.register @req, @res
it "should auto allocate the subscription for that domain", (done)->
@UserRegistrationHandler.registerNewUser.callsArgWith(1, null, @user)
@res.send = (opts)=>
@SubscriptionDomainAllocator.autoAllocate.calledWith(@user).should.equal true
done()
@UserController.register @req, @res
describe "changePassword", ->