Просмотр исходного кода

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

Henry Oswald 11 лет назад
Родитель
Сommit
0a64c1c8ac

+ 2 - 0
services/web/app/coffee/Features/User/UserController.coffee

@@ -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()

+ 9 - 0
services/web/test/UnitTests/coffee/User/UserControllerTests.coffee

@@ -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", ->