From 545ce79c71de504e7d5202af0997aeb6f203cfa2 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Mon, 1 Aug 2016 10:14:08 +0100 Subject: [PATCH] Test clicking the invite after already accepting --- .../coffee/ProjectInviteTests.coffee | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/services/web/test/acceptance/coffee/ProjectInviteTests.coffee b/services/web/test/acceptance/coffee/ProjectInviteTests.coffee index 7824bb8fde..13afc57a2e 100644 --- a/services/web/test/acceptance/coffee/ProjectInviteTests.coffee +++ b/services/web/test/acceptance/coffee/ProjectInviteTests.coffee @@ -91,12 +91,21 @@ expectInvalidInvitePage = (user, link, callback=()->) -> callback() expectInviteRedirectToRegister = (user, link, callback=()->) -> + # view invite, redirect to `/register` tryFollowInviteLink user, link, (err, response, body) -> expect(err).to.be.oneOf [null, undefined] expect(response.statusCode).to.equal 302 expect(response.headers.location).to.match new RegExp("^/register\?.*redir=.*$") callback() +expectInviteRedirectToProject = (user, link, invite, callback=()->) -> + # view invite, redirect straight to project + tryFollowInviteLink user, link, (err, response, body) -> + expect(err).to.be.oneOf [null, undefined] + expect(response.statusCode).to.equal 302 + expect(response.headers.location).to.equal "/project/#{invite.projectId}" + callback() + expectAcceptInviteAndRedirect = (user, invite, callback=()->) -> # should accept the invite and redirect to project tryAcceptInvite user, invite, (err, response, body) => @@ -152,7 +161,25 @@ describe "ProjectInviteTests", -> (cb) => revokeInvite(@sendingUser, @projectId, @invite._id, cb) ], done - # describe 'user is already a member of the project', -> + describe 'user is already a member of the project', -> + + beforeEach (done) -> + Async.series [ + (cb) => + expectInvitePage @user, @link, cb + (cb) => + expectAcceptInviteAndRedirect @user, @invite, cb + ], done + + describe 'when user clicks on the invite a second time', -> + + it 'should just redirect to the project page', (done) -> + Async.series [ + (cb) => + expectProjectAccess @user, @invite.projectId, cb + (cb) => + expectInviteRedirectToProject @user, @link, @invite, cb + ], done describe 'user is not a member of the project', ->