Test when the user does not accept the invite

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

View file

@ -80,6 +80,26 @@ describe "ProjectInviteTests", ->
@link = CollaboratorsEmailHandler._buildInviteUrl(@fakeProject, @invite)
done()
it 'should not grant access if the user does not accept the invite', (done) ->
Async.series(
[
# go to the invite page
(cb) =>
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>Project Invite - .*</title>")
cb()
# access the project page
(cb) =>
@user.openProject @invite.projectId, (err) =>
expect(err).to.be.instanceof Error
cb()
], done
)
it 'should allow the user to accept the invite and access the project', (done) ->
Async.series(
[

View file

@ -73,7 +73,10 @@ class User
@request.get {
url: "/project/#{project_id}"
}, (error, response, body) ->
return callback(error) if error? or response.statusCode != 200
return callback(error) if error?
if response.statusCode != 200
err = new Error("Non-success response when opening project: #{response.statusCode}")
return callback(err)
callback(null)
addUserToProject: (project_id, email, privileges, callback = (error, user) ->) ->