null check subscription for group admin panel

This commit is contained in:
Henry Oswald 2017-06-22 14:07:07 +01:00
parent 2dda430691
commit 3da5ef818c
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