Merge pull request #534 from sharelatex/ho-group-plan-redirect

null check subscription for group admin panel
This commit is contained in:
Shane Kilkelly 2017-06-27 08:24:10 +01:00 committed by GitHub
commit 04c3e4340d
2 changed files with 12 additions and 3 deletions

View file

@ -54,8 +54,8 @@ module.exports =
renderSubscriptionGroupAdminPage: (req, res)->
user_id = AuthenticationController.getLoggedInUserId(req)
SubscriptionLocator.getUsersSubscription user_id, (err, subscription)->
if !subscription.groupPlan
return res.redirect("/")
if !subscription?.groupPlan
return res.redirect("/user/subscription")
SubscriptionGroupHandler.getPopulatedListOfMembers user_id, (err, users)->
res.render "subscriptions/group_admin",
title: 'group_admin'

View file

@ -96,7 +96,16 @@ describe "SubscriptionGroupController", ->
res =
redirect : (path)=>
path.should.equal("/")
path.should.equal("/user/subscription")
done()
@Controller.renderSubscriptionGroupAdminPage @req, res
it "should redirect you don't have a subscription", (done)->
@SubscriptionLocator.getUsersSubscription = sinon.stub().callsArgWith(1)
res =
redirect : (path)=>
path.should.equal("/user/subscription")
done()
@Controller.renderSubscriptionGroupAdminPage @req, res