Просмотр исходного кода

if user is already annual tell them so on the annual upgrade page

Henry Oswald 12 лет назад
Родитель
Сommit
e740e4913d

+ 3 - 1
services/web/app/coffee/Features/Subscription/SubscriptionController.coffee

@@ -164,7 +164,9 @@ module.exports = SubscriptionController =
 		SecurityManager.getCurrentUser req, (error, user) ->
 			LimitationsManager.userHasSubscription user, (err, hasSubscription, subscription)->
 				planCode = subscription?.planCode.toLowerCase()
-				if planCode?.indexOf("student") != -1
+				if planCode?.indexOf("annual") != -1
+					planName = "annual"
+				else if planCode?.indexOf("student") != -1
 					planName = "student"
 				else if planCode?.indexOf("collaborator") != -1
 					planName = "collaborator"

+ 2 - 1
services/web/public/coffee/main/annual-upgrade.coffee

@@ -11,7 +11,8 @@ define [
 			collaborator:"36"
 		$scope.$watch $scope.planName, ->
 			$scope.yearlySaving = savings[$scope.planName]
-
+			if $scope.planName == "annual"
+				$scope.upgradeComplete = true
 		$scope.completeAnnualUpgrade = ->
 			body = 
 				planName: $scope.planName

+ 9 - 0
services/web/test/UnitTests/coffee/Subscription/SubscriptionControllerTests.coffee

@@ -323,6 +323,15 @@ describe "SubscriptionController sanboxed", ->
 				done()
 			@SubscriptionController.renderUpgradeToAnnualPlanPage @req, @res
 
+		it "should pass annual as the plan name if the user is already on an annual plan", (done)->
+
+			@LimitationsManager.userHasSubscription.callsArgWith(1, null, true, {planCode:"student annual with free trial"})
+			@res.render = (view, opts)->
+				opts.planName.should.equal "annual"
+				done()
+			@SubscriptionController.renderUpgradeToAnnualPlanPage @req, @res
+
+
 	describe "processUpgradeToAnnualPlan", ->
 
 		beforeEach ->