mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Notify v1 by default
This commit is contained in:
parent
301ae80f99
commit
c5b553d4a6
3 changed files with 50 additions and 34 deletions
|
@ -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) ->
|
||||||
|
|
|
@ -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?
|
||||||
|
|
|
@ -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,48 +30,63 @@ 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()
|
||||||
@FeaturesUpdater.refreshFeatures @user_id, @callback
|
|
||||||
|
|
||||||
it "should get the individual features", ->
|
describe "normally", ->
|
||||||
@FeaturesUpdater._getIndividualFeatures
|
beforeEach ->
|
||||||
.calledWith(@user_id)
|
@FeaturesUpdater.refreshFeatures @user_id, @callback
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
it "should get the group features", ->
|
it "should get the individual features", ->
|
||||||
@FeaturesUpdater._getGroupFeatureSets
|
@FeaturesUpdater._getIndividualFeatures
|
||||||
.calledWith(@user_id)
|
.calledWith(@user_id)
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
it "should get the v1 features", ->
|
it "should get the group features", ->
|
||||||
@FeaturesUpdater._getV1Features
|
@FeaturesUpdater._getGroupFeatureSets
|
||||||
.calledWith(@user_id)
|
.calledWith(@user_id)
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
it "should get the bonus features", ->
|
it "should get the v1 features", ->
|
||||||
@ReferalFeatures.getBonusFeatures
|
@FeaturesUpdater._getV1Features
|
||||||
.calledWith(@user_id)
|
.calledWith(@user_id)
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
it "should merge from the default features", ->
|
it "should get the bonus features", ->
|
||||||
@FeaturesUpdater._mergeFeatures.calledWith(@Settings.defaultFeatures).should.equal true
|
@ReferalFeatures.getBonusFeatures
|
||||||
|
.calledWith(@user_id)
|
||||||
|
.should.equal true
|
||||||
|
|
||||||
it "should merge the individual features", ->
|
it "should merge from the default features", ->
|
||||||
@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'individual': 'features' }).should.equal true
|
@FeaturesUpdater._mergeFeatures.calledWith(@Settings.defaultFeatures).should.equal true
|
||||||
|
|
||||||
it "should merge the group features", ->
|
it "should merge the individual features", ->
|
||||||
@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'group': 'features' }).should.equal true
|
@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'individual': 'features' }).should.equal true
|
||||||
@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'group': 'features2' }).should.equal true
|
|
||||||
|
|
||||||
it "should merge the v1 features", ->
|
it "should merge the group features", ->
|
||||||
@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'v1': 'features' }).should.equal true
|
@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'group': 'features' }).should.equal true
|
||||||
|
@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'group': 'features2' }).should.equal true
|
||||||
|
|
||||||
it "should merge the bonus features", ->
|
it "should merge the v1 features", ->
|
||||||
@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'bonus': 'features' }).should.equal true
|
@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'v1': 'features' }).should.equal true
|
||||||
|
|
||||||
it "should update the user with the merged features", ->
|
it "should merge the bonus features", ->
|
||||||
@UserFeaturesUpdater.updateFeatures
|
@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'bonus': 'features' }).should.equal true
|
||||||
.calledWith(@user_id, {'merged': 'features'})
|
|
||||||
.should.equal true
|
it "should update the user with the merged features", ->
|
||||||
|
@UserFeaturesUpdater.updateFeatures
|
||||||
|
.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", ->
|
describe "_mergeFeatures", ->
|
||||||
it "should prefer priority over standard for compileGroup", ->
|
it "should prefer priority over standard for compileGroup", ->
|
||||||
|
|
Loading…
Reference in a new issue