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)-> renderSubscriptionGroupAdminPage: (req, res)->
user_id = AuthenticationController.getLoggedInUserId(req) user_id = AuthenticationController.getLoggedInUserId(req)
SubscriptionLocator.getUsersSubscription user_id, (err, subscription)-> SubscriptionLocator.getUsersSubscription user_id, (err, subscription)->
if !subscription.groupPlan if !subscription?.groupPlan
return res.redirect("/") return res.redirect("/user/subscription")
SubscriptionGroupHandler.getPopulatedListOfMembers user_id, (err, users)-> SubscriptionGroupHandler.getPopulatedListOfMembers user_id, (err, users)->
res.render "subscriptions/group_admin", res.render "subscriptions/group_admin",
title: 'group_admin' title: 'group_admin'

View file

@ -96,7 +96,16 @@ describe "SubscriptionGroupController", ->
res = res =
redirect : (path)=> 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() done()
@Controller.renderSubscriptionGroupAdminPage @req, res @Controller.renderSubscriptionGroupAdminPage @req, res