Просмотр исходного кода

Render a separate template if the invite is not found.

Shane Kilkelly 10 лет назад
Родитель
Сommit
78570817d5

+ 2 - 2
services/web/app/coffee/Features/Collaborators/CollaboratorsInviteController.coffee

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

+ 1 - 0
services/web/app/views/project/invite/not-valid.jade

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

+ 0 - 0
services/web/app/views/project/invite.jade → services/web/app/views/project/invite/show.jade


+ 4 - 7
services/web/test/UnitTests/coffee/Collaborators/CollaboratorsInviteControllerTests.coffee

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