Render a separate template if the invite is not found.

This commit is contained in:
Shane Kilkelly 2016-07-22 16:28:00 +01:00
parent 9e0c44573a
commit 78570817d5
4 changed files with 7 additions and 9 deletions

View file

@ -50,8 +50,8 @@ module.exports = CollaboratorsInviteController =
# TODO: render a not-valid view instead
if !invite
logger.log {projectId, token}, "no invite found for token"
return res.sendStatus(404)
res.render "project/invite", {invite}
return res.render "project/invite/not-valid"
res.render "project/invite/show", {invite}
acceptInvite: (req, res, next) ->
projectId = req.params.Project_id

View file

@ -0,0 +1 @@
h1 Invite Not Valid TEST

View file

@ -145,7 +145,7 @@ describe "CollaboratorsInviteController", ->
it 'should render the view template', ->
@res.render.callCount.should.equal 1
@res.render.calledWith('project/invite').should.equal true
@res.render.calledWith('project/invite/show').should.equal true
it 'should not call next', ->
@next.callCount.should.equal 0
@ -173,12 +173,9 @@ describe "CollaboratorsInviteController", ->
@CollaboratorsInviteHandler.getInviteByToken.callsArgWith(2, null, null)
@CollaboratorsInviteController.viewInvite @req, @res, @next
it 'should produce a 404 response', ->
@res.sendStatus.callCount.should.equal 1
@res.sendStatus.calledWith(404).should.equal true
it 'should not render the view template', ->
@res.render.callCount.should.equal 0
it 'should render the not-valid view template', ->
@res.render.callCount.should.equal 1
@res.render.calledWith('project/invite/not-valid').should.equal true
it 'should not call next', ->
@next.callCount.should.equal 0