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

This commit is contained in:
Henry Oswald 2014-08-29 14:13:05 +01:00
parent cffcdbae18
commit e740e4913d
3 changed files with 14 additions and 2 deletions

View file

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

View file

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

View file

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