mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Refactor
This commit is contained in:
parent
8af1a7b17a
commit
495bc1bcd3
1 changed files with 15 additions and 29 deletions
|
@ -153,7 +153,6 @@ expectRegistrationRedirectToInvite = (user, email, redir, link, callback=(err, r
|
||||||
expect(link).to.match new RegExp("^.*#{body.redir}\?.*$")
|
expect(link).to.match new RegExp("^.*#{body.redir}\?.*$")
|
||||||
callback(null, null)
|
callback(null, null)
|
||||||
|
|
||||||
|
|
||||||
expectInviteRedirectToProject = (user, link, invite, callback=(err,result)->) ->
|
expectInviteRedirectToProject = (user, link, invite, callback=(err,result)->) ->
|
||||||
# view invite, redirect straight to project
|
# view invite, redirect straight to project
|
||||||
tryFollowInviteLink user, link, (err, response, body) ->
|
tryFollowInviteLink user, link, (err, response, body) ->
|
||||||
|
@ -221,20 +220,16 @@ describe "ProjectInviteTests", ->
|
||||||
|
|
||||||
beforeEach (done) ->
|
beforeEach (done) ->
|
||||||
Async.series [
|
Async.series [
|
||||||
(cb) =>
|
(cb) => expectInvitePage @user, @link, cb
|
||||||
expectInvitePage @user, @link, cb
|
(cb) => expectAcceptInviteAndRedirect @user, @invite, cb
|
||||||
(cb) =>
|
|
||||||
expectAcceptInviteAndRedirect @user, @invite, cb
|
|
||||||
], done
|
], done
|
||||||
|
|
||||||
describe 'when user clicks on the invite a second time', ->
|
describe 'when user clicks on the invite a second time', ->
|
||||||
|
|
||||||
it 'should just redirect to the project page', (done) ->
|
it 'should just redirect to the project page', (done) ->
|
||||||
Async.series [
|
Async.series [
|
||||||
(cb) =>
|
(cb) => expectProjectAccess @user, @invite.projectId, cb
|
||||||
expectProjectAccess @user, @invite.projectId, cb
|
(cb) => expectInviteRedirectToProject @user, @link, @invite, cb
|
||||||
(cb) =>
|
|
||||||
expectInviteRedirectToProject @user, @link, @invite, cb
|
|
||||||
], done
|
], done
|
||||||
|
|
||||||
describe 'when the user recieves another invite to the same project', ->
|
describe 'when the user recieves another invite to the same project', ->
|
||||||
|
@ -248,10 +243,8 @@ describe "ProjectInviteTests", ->
|
||||||
@secondInvite = invite
|
@secondInvite = invite
|
||||||
@secondLink = CollaboratorsEmailHandler._buildInviteUrl(@fakeProject, invite)
|
@secondLink = CollaboratorsEmailHandler._buildInviteUrl(@fakeProject, invite)
|
||||||
cb()
|
cb()
|
||||||
(cb) =>
|
(cb) => expectInviteRedirectToProject @user, @secondLink, @secondInvite, cb
|
||||||
expectInviteRedirectToProject @user, @secondLink, @secondInvite, cb
|
(cb) => revokeInvite @sendingUser, @projectId, @secondInvite._id, cb
|
||||||
(cb) =>
|
|
||||||
revokeInvite @sendingUser, @projectId, @secondInvite._id, cb
|
|
||||||
], done
|
], done
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,10 +253,8 @@ describe "ProjectInviteTests", ->
|
||||||
it 'should not grant access if the user does not accept the invite', (done) ->
|
it 'should not grant access if the user does not accept the invite', (done) ->
|
||||||
Async.series(
|
Async.series(
|
||||||
[
|
[
|
||||||
(cb) =>
|
(cb) => expectInvitePage @user, @link, cb
|
||||||
expectInvitePage @user, @link, cb
|
(cb) => expectNoProjectAccess @user, @invite.projectId, cb
|
||||||
(cb) =>
|
|
||||||
expectNoProjectAccess @user, @invite.projectId, cb
|
|
||||||
], done
|
], done
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -281,12 +272,9 @@ describe "ProjectInviteTests", ->
|
||||||
it 'should allow the user to accept the invite and access the project', (done) ->
|
it 'should allow the user to accept the invite and access the project', (done) ->
|
||||||
Async.series(
|
Async.series(
|
||||||
[
|
[
|
||||||
(cb) =>
|
(cb) => expectInvitePage @user, @link, cb
|
||||||
expectInvitePage @user, @link, cb
|
(cb) => expectAcceptInviteAndRedirect @user, @invite, cb
|
||||||
(cb) =>
|
(cb) => expectProjectAccess @user, @invite.projectId, cb
|
||||||
expectAcceptInviteAndRedirect @user, @invite, cb
|
|
||||||
(cb) =>
|
|
||||||
expectProjectAccess @user, @invite.projectId, cb
|
|
||||||
], done
|
], done
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -326,12 +314,10 @@ describe "ProjectInviteTests", ->
|
||||||
expectInviteRedirectToRegister @user, @link, (err, redirectUrl) =>
|
expectInviteRedirectToRegister @user, @link, (err, redirectUrl) =>
|
||||||
@_redir = redirectUrl
|
@_redir = redirectUrl
|
||||||
cb()
|
cb()
|
||||||
(cb) =>
|
(cb) => expectRegistrationRedirectToInvite @user, "some_email@example.com", @_redir, @link, cb
|
||||||
expectRegistrationRedirectToInvite @user, "some_email@example.com", @_redir, @link, cb
|
(cb) => expectInvitePage @user, @link, cb
|
||||||
(cb) =>
|
(cb) => expectAcceptInviteAndRedirect @user, @invite, cb
|
||||||
expectInvitePage @user, @link, cb
|
(cb) => expectProjectAccess @user, @invite.projectId, cb
|
||||||
(cb) =>
|
|
||||||
expectAcceptInviteAndRedirect @user, @invite, cb
|
|
||||||
], done
|
], done
|
||||||
|
|
||||||
describe 'registration prompt workflow with non-valid token', ->
|
describe 'registration prompt workflow with non-valid token', ->
|
||||||
|
|
Loading…
Reference in a new issue