mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-29 20:11:32 +02:00
Fix SubscriptionUpdater -> FeaturesUpdater miscall
This commit is contained in:
@@ -2,7 +2,7 @@ _ = require("underscore")
|
||||
logger = require('logger-sharelatex')
|
||||
User = require('../../models/User').User
|
||||
Settings = require "settings-sharelatex"
|
||||
SubscriptionUpdater = require "../Subscription/SubscriptionUpdater"
|
||||
FeaturesUpdater = require "../Subscription/FeaturesUpdater"
|
||||
|
||||
module.exports = ReferalAllocator =
|
||||
allocate: (referal_id, new_user_id, referal_source, referal_medium, callback = ->)->
|
||||
@@ -25,6 +25,6 @@ module.exports = ReferalAllocator =
|
||||
if err?
|
||||
logger.err err:err, referal_id:referal_id, new_user_id:new_user_id, "something went wrong allocating referal"
|
||||
return callback(err)
|
||||
SubscriptionUpdater.refreshFeatures user._id, callback
|
||||
FeaturesUpdater.refreshFeatures user._id, callback
|
||||
else
|
||||
callback()
|
||||
|
||||
@@ -9,7 +9,7 @@ describe 'ReferalAllocator', ->
|
||||
beforeEach ->
|
||||
@ReferalAllocator = SandboxedModule.require modulePath, requires:
|
||||
'../../models/User': User: @User = {}
|
||||
"../Subscription/SubscriptionUpdater": @SubscriptionUpdater = {}
|
||||
"../Subscription/FeaturesUpdater": @FeaturesUpdater = {}
|
||||
"settings-sharelatex": @Settings = {}
|
||||
'logger-sharelatex':
|
||||
log:->
|
||||
@@ -26,7 +26,7 @@ describe 'ReferalAllocator', ->
|
||||
@referal_source = "bonus"
|
||||
@User.update = sinon.stub().callsArgWith 3, null
|
||||
@User.findOne = sinon.stub().callsArgWith 1, null, { _id: @user_id }
|
||||
@SubscriptionUpdater.refreshFeatures = sinon.stub().yields()
|
||||
@FeaturesUpdater.refreshFeatures = sinon.stub().yields()
|
||||
@ReferalAllocator.allocate @referal_id, @new_user_id, @referal_source, @referal_medium, @callback
|
||||
|
||||
it 'should update the referring user with the refered users id', ->
|
||||
@@ -45,7 +45,7 @@ describe 'ReferalAllocator', ->
|
||||
.should.equal true
|
||||
|
||||
it "should refresh the user's subscription", ->
|
||||
@SubscriptionUpdater.refreshFeatures
|
||||
@FeaturesUpdater.refreshFeatures
|
||||
.calledWith(@user_id)
|
||||
.should.equal true
|
||||
|
||||
@@ -57,7 +57,7 @@ describe 'ReferalAllocator', ->
|
||||
@referal_source = "public_share"
|
||||
@User.update = sinon.stub().callsArgWith 3, null
|
||||
@User.findOne = sinon.stub().callsArgWith 1, null, { _id: @user_id }
|
||||
@SubscriptionUpdater.refreshFeatures = sinon.stub().yields()
|
||||
@FeaturesUpdater.refreshFeatures = sinon.stub().yields()
|
||||
@ReferalAllocator.allocate @referal_id, @new_user_id, @referal_source, @referal_medium, @callback
|
||||
|
||||
it 'should not update the referring user with the refered users id', ->
|
||||
@@ -69,7 +69,7 @@ describe 'ReferalAllocator', ->
|
||||
.should.equal true
|
||||
|
||||
it "should not assign the user a bonus", ->
|
||||
@SubscriptionUpdater.refreshFeatures.called.should.equal false
|
||||
@FeaturesUpdater.refreshFeatures.called.should.equal false
|
||||
|
||||
it "should call the callback", ->
|
||||
@callback.called.should.equal true
|
||||
|
||||
Reference in New Issue
Block a user