소스 검색

Fix ReferalFeatures tests

Alberto Fernández Capel 8 년 전
부모
커밋
8b8742d60f
1개의 변경된 파일과 11개의 추가작업 그리고 12개의 파일을 삭제
  1. 11 12
      services/web/test/unit/coffee/Referal/ReferalFeaturesTests.coffee

+ 11 - 12
services/web/test/unit/coffee/Referal/ReferalFeaturesTests.coffee

@@ -8,7 +8,7 @@ describe 'ReferalFeatures', ->
 
 
 	beforeEach ->
 	beforeEach ->
 		@ReferalFeatures = SandboxedModule.require modulePath, requires:
 		@ReferalFeatures = SandboxedModule.require modulePath, requires:
-			'../../models/User': User: @User = {}
+			'../User/UserGetter': @UserGetter = {}
 			"settings-sharelatex": @Settings = {}
 			"settings-sharelatex": @Settings = {}
 			'logger-sharelatex':
 			'logger-sharelatex':
 				log:->
 				log:->
@@ -27,17 +27,17 @@ describe 'ReferalFeatures', ->
 						collaborators: 3
 						collaborators: 3
 						dropbox: false
 						dropbox: false
 						versioning: false
 						versioning: false
-				stubbedUser = { 
-					refered_user_count: @refered_user_count, 
-					features:{collaborators:1, dropbox:false, versioning:false} 
+				stubbedUser = {
+					refered_user_count: @refered_user_count,
+					features:{collaborators:1, dropbox:false, versioning:false}
 				}
 				}
 
 
-				@User.findOne = sinon.stub().callsArgWith 1, null, stubbedUser
+				@UserGetter.getUserOrUserStubById = sinon.stub().yields null, stubbedUser
 				@ReferalFeatures.getBonusFeatures @user_id, @callback
 				@ReferalFeatures.getBonusFeatures @user_id, @callback
 
 
 			it "should get the users number of refered user", ->
 			it "should get the users number of refered user", ->
-				@User.findOne
-					.calledWith(_id: @user_id)
+				@UserGetter.getUserOrUserStubById
+					.calledWith(@user_id, { _id: 1 })
 					.should.equal true
 					.should.equal true
 
 
 			it "should call the callback with the features", ->
 			it "should call the callback with the features", ->
@@ -51,15 +51,14 @@ describe 'ReferalFeatures', ->
 						collaborators: 3
 						collaborators: 3
 						dropbox: false
 						dropbox: false
 						versioning: false
 						versioning: false
-				@User.findOne = sinon.stub().callsArgWith 1, null, { refered_user_count: @refered_user_count }
+				@UserGetter.getUserOrUserStubById =
+					sinon.stub().yields null, { refered_user_count: @refered_user_count }
 				@ReferalFeatures.getBonusFeatures @user_id, @callback
 				@ReferalFeatures.getBonusFeatures @user_id, @callback
 
 
 			it "should get the users number of refered user", ->
 			it "should get the users number of refered user", ->
-				@User.findOne
-					.calledWith(_id: @user_id)
+				@UserGetter.getUserOrUserStubById
+					.calledWith(@user_id, { _id: 1 })
 					.should.equal true
 					.should.equal true
 
 
 			it "should call the callback with no features", ->
 			it "should call the callback with no features", ->
 				@callback.calledWith(null, {}).should.equal true
 				@callback.calledWith(null, {}).should.equal true
-
-