James Allen 8 лет назад
Родитель
Сommit
c5b553d4a6

+ 1 - 1
services/web/app/coffee/Features/Subscription/FeaturesUpdater.coffee

@@ -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) ->

+ 1 - 1
services/web/test/acceptance/coffee/FeatureUpdaterTests.coffee

@@ -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?

+ 48 - 32
services/web/test/unit/coffee/Subscription/FeaturesUpdaterTests.coffee

@@ -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,48 +30,63 @@ describe "FeaturesUpdater", ->
 			@ReferalFeatures.getBonusFeatures = sinon.stub().yields(null, { 'bonus': 'features' })
 			@FeaturesUpdater._mergeFeatures = sinon.stub().returns({'merged': 'features'})
 			@callback = sinon.stub()
-			@FeaturesUpdater.refreshFeatures @user_id, @callback
 
-		it "should get the individual features", ->
-			@FeaturesUpdater._getIndividualFeatures
-				.calledWith(@user_id)
-				.should.equal true
+		describe "normally", ->
+			beforeEach ->
+				@FeaturesUpdater.refreshFeatures @user_id, @callback
 
-		it "should get the group features", ->
-			@FeaturesUpdater._getGroupFeatureSets
-				.calledWith(@user_id)
-				.should.equal true
+			it "should get the individual features", ->
+				@FeaturesUpdater._getIndividualFeatures
+					.calledWith(@user_id)
+					.should.equal true
 
-		it "should get the v1 features", ->
-			@FeaturesUpdater._getV1Features
-				.calledWith(@user_id)
-				.should.equal true
+			it "should get the group features", ->
+				@FeaturesUpdater._getGroupFeatureSets
+					.calledWith(@user_id)
+					.should.equal true
 
-		it "should get the bonus features", ->
-			@ReferalFeatures.getBonusFeatures
-				.calledWith(@user_id)
-				.should.equal true
+			it "should get the v1 features", ->
+				@FeaturesUpdater._getV1Features
+					.calledWith(@user_id)
+					.should.equal true
 
-		it "should merge from the default features", ->
-			@FeaturesUpdater._mergeFeatures.calledWith(@Settings.defaultFeatures).should.equal true
+			it "should get the bonus features", ->
+				@ReferalFeatures.getBonusFeatures
+					.calledWith(@user_id)
+					.should.equal true
 
-		it "should merge the individual features", ->
-			@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'individual': 'features' }).should.equal true
+			it "should merge from the default features", ->
+				@FeaturesUpdater._mergeFeatures.calledWith(@Settings.defaultFeatures).should.equal true
 
-		it "should merge the group features", ->
-			@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 individual features", ->
+				@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'individual': 'features' }).should.equal true
 
-		it "should merge the v1 features", ->
-			@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'v1': 'features' }).should.equal true
+			it "should merge the group features", ->
+				@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", ->
-			@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'bonus': 'features' }).should.equal true
+			it "should merge the v1 features", ->
+				@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'v1': '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 merge the bonus features", ->
+				@FeaturesUpdater._mergeFeatures.calledWith(sinon.match.any, { 'bonus': '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", ->
 		it "should prefer priority over standard for compileGroup", ->