Notify v1 by default

This commit is contained in:
James Allen 2018-05-29 17:31:15 +01:00
parent 301ae80f99
commit c5b553d4a6
3 changed files with 50 additions and 34 deletions

View file

@ -14,7 +14,7 @@ module.exports = FeaturesUpdater =
refreshFeatures: (user_id, notifyV1, callback)->
if !callback?
callback = notifyV1
notifyV1 = false
notifyV1 = true
if notifyV1
V1SubscriptionManager.notifyV1OfFeaturesChange user_id, (error) ->

View file

@ -13,7 +13,7 @@ logger = require "logger-sharelatex"
logger.logger.level("error")
syncUserAndGetFeatures = (user, callback = (error, features) ->) ->
FeaturesUpdater.refreshFeatures user._id, (error) ->
FeaturesUpdater.refreshFeatures user._id, false, (error) ->
return callback(error) if error?
User.findById user._id, (error, user) ->
return callback(error) if error?

View file

@ -22,6 +22,7 @@ describe "FeaturesUpdater", ->
describe "refreshFeatures", ->
beforeEach ->
@V1SubscriptionManager.notifyV1OfFeaturesChange = sinon.stub().yields()
@UserFeaturesUpdater.updateFeatures = sinon.stub().yields()
@FeaturesUpdater._getIndividualFeatures = sinon.stub().yields(null, { 'individual': 'features' })
@FeaturesUpdater._getGroupFeatureSets = sinon.stub().yields(null, [{ 'group': 'features' }, { 'group': 'features2' }])
@ -29,6 +30,9 @@ describe "FeaturesUpdater", ->
@ReferalFeatures.getBonusFeatures = sinon.stub().yields(null, { 'bonus': 'features' })
@FeaturesUpdater._mergeFeatures = sinon.stub().returns({'merged': 'features'})
@callback = sinon.stub()
describe "normally", ->
beforeEach ->
@FeaturesUpdater.refreshFeatures @user_id, @callback
it "should get the individual features", ->
@ -72,6 +76,18 @@ describe "FeaturesUpdater", ->
.calledWith(@user_id, {'merged': 'features'})
.should.equal true
it "should notify v1", ->
@V1SubscriptionManager.notifyV1OfFeaturesChange
.called.should.equal true
describe "with notifyV1 == false", ->
beforeEach ->
@FeaturesUpdater.refreshFeatures @user_id, false, @callback
it "should not notify v1", ->
@V1SubscriptionManager.notifyV1OfFeaturesChange
.called.should.equal false
describe "_mergeFeatures", ->
it "should prefer priority over standard for compileGroup", ->
expect(@FeaturesUpdater._mergeFeatures({