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)-> refreshFeatures: (user_id, notifyV1, callback)->
if !callback? if !callback?
callback = notifyV1 callback = notifyV1
notifyV1 = false notifyV1 = true
if notifyV1 if notifyV1
V1SubscriptionManager.notifyV1OfFeaturesChange user_id, (error) -> V1SubscriptionManager.notifyV1OfFeaturesChange user_id, (error) ->

View file

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

View file

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