Test the invalid-invite page

This commit is contained in:
Shane Kilkelly 2016-07-29 11:54:08 +01:00
parent b33d4e103d
commit f3a1f32bb1
2 changed files with 23 additions and 2 deletions

View file

@ -56,7 +56,7 @@ module.exports = CollaboratorsInviteController =
currentUser = req.session.user currentUser = req.session.user
_renderInvalidPage = () -> _renderInvalidPage = () ->
logger.log {projectId, token}, "invite not valid, rendering not-valid page" logger.log {projectId, token}, "invite not valid, rendering not-valid page"
res.render "project/invite/not-valid" res.render "project/invite/not-valid", {title: "Invalid Invite"}
# get the target project # get the target project
Project.findOne {_id: projectId}, {owner_ref: 1, name: 1, collaberator_refs: 1, readOnly_refs: 1}, (err, project) -> Project.findOne {_id: projectId}, {owner_ref: 1, name: 1, collaberator_refs: 1, readOnly_refs: 1}, (err, project) ->
if err? if err?

View file

@ -91,7 +91,28 @@ describe "ProjectInviteTests", ->
expect(body).to.match new RegExp("<title>Project Invite - .*</title>") expect(body).to.match new RegExp("<title>Project Invite - .*</title>")
cb() cb()
# access the project page # forbid access to the project page
(cb) =>
@user.openProject @invite.projectId, (err) =>
expect(err).to.be.instanceof Error
cb()
], done
)
it 'should render the invalid-invite page if the token is invalid', (done) ->
Async.series(
[
# go to the invite page with an invalid token
(cb) =>
link = @link.replace(@invite.token, 'not_a_real_token')
followInviteLink @user, link, (err, response, body) =>
expect(err).to.be.oneOf [null, undefined]
expect(response.statusCode).to.equal 200
expect(body).to.match new RegExp("<title>Invalid Invite - .*</title>")
cb()
# forbid access to the project page
(cb) => (cb) =>
@user.openProject @invite.projectId, (err) => @user.openProject @invite.projectId, (err) =>
expect(err).to.be.instanceof Error expect(err).to.be.instanceof Error