mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
get invite and link for test
This commit is contained in:
parent
9c6195fbec
commit
23c94c9599
2 changed files with 46 additions and 10 deletions
|
@ -3,6 +3,19 @@ Async = require("async")
|
||||||
User = require "./helpers/User"
|
User = require "./helpers/User"
|
||||||
request = require "./helpers/request"
|
request = require "./helpers/request"
|
||||||
settings = require "settings-sharelatex"
|
settings = require "settings-sharelatex"
|
||||||
|
CollaboratorsEmailHandler = require "../../../app/js/Features/Collaborators/CollaboratorsEmailHandler"
|
||||||
|
|
||||||
|
|
||||||
|
_createInvite = (projectId, user, email, callback=(err, invite)->) ->
|
||||||
|
user.getCsrfToken (err) ->
|
||||||
|
return callback(err) if err
|
||||||
|
user.request.post {
|
||||||
|
url: "/project/#{projectId}/invite",
|
||||||
|
json:
|
||||||
|
email: email
|
||||||
|
}, (err, response, body) ->
|
||||||
|
return callback(err) if err
|
||||||
|
callback(err, body.invite)
|
||||||
|
|
||||||
describe "ProjectInviteTests", ->
|
describe "ProjectInviteTests", ->
|
||||||
before (done) ->
|
before (done) ->
|
||||||
|
@ -10,17 +23,28 @@ describe "ProjectInviteTests", ->
|
||||||
@sendingUser = new User()
|
@sendingUser = new User()
|
||||||
@user = new User()
|
@user = new User()
|
||||||
@site_admin = new User({email: "admin@example.com"})
|
@site_admin = new User({email: "admin@example.com"})
|
||||||
|
@email = 'user@example.com'
|
||||||
|
@projectName = 'sharing test'
|
||||||
@projectId = null
|
@projectId = null
|
||||||
|
@fakeProject = null
|
||||||
Async.series [
|
Async.series [
|
||||||
(cb) => @user.login cb
|
(cb) => @user.login cb
|
||||||
(cb) => @user.logout cb
|
|
||||||
(cb) => @sendingUser.login cb
|
(cb) => @sendingUser.login cb
|
||||||
(cb) => @sendingUser.createProject('sharing test', (err, projectId) =>
|
(cb) => @sendingUser.createProject(@projectName, (err, projectId, project) =>
|
||||||
throw err if err
|
throw err if err
|
||||||
@projectId = projectId
|
@projectId = projectId
|
||||||
|
@fakeProject = {
|
||||||
|
_id: projectId,
|
||||||
|
name: @projectName,
|
||||||
|
owner_ref: @sendingUser
|
||||||
|
}
|
||||||
cb()
|
cb()
|
||||||
)
|
)
|
||||||
(cb) => @sendingUser.logout cb
|
], done
|
||||||
|
|
||||||
|
after (done) ->
|
||||||
|
Async.series [
|
||||||
|
(cb) => @sendingUser.deleteProject(@projectId, cb)
|
||||||
], done
|
], done
|
||||||
|
|
||||||
describe "user is logged in", ->
|
describe "user is logged in", ->
|
||||||
|
@ -33,16 +57,21 @@ describe "ProjectInviteTests", ->
|
||||||
|
|
||||||
describe 'user is already a member of the project', ->
|
describe 'user is already a member of the project', ->
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach (done) ->
|
||||||
|
@invite = null
|
||||||
|
@link = null
|
||||||
|
_createInvite @projectId, @sendingUser, @email, (err, invite) =>
|
||||||
|
@invite = invite
|
||||||
|
@link = CollaboratorsEmailHandler._buildInviteUrl(@fakeProject, @invite)
|
||||||
|
done()
|
||||||
|
|
||||||
it 'should redirect to the project page', (done) ->
|
it 'should redirect to the project page', (done) ->
|
||||||
Async.series(
|
Async.series(
|
||||||
[
|
[
|
||||||
(cb) =>
|
(cb) =>
|
||||||
|
console.log ">> yes"
|
||||||
cb()
|
cb()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
], (err, result) =>
|
], (err, result) =>
|
||||||
if err
|
if err
|
||||||
throw err
|
throw err
|
||||||
|
|
|
@ -58,7 +58,14 @@ class User
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
if !body?.project_id?
|
if !body?.project_id?
|
||||||
console.error "SOMETHING WENT WRONG CREATING PROJECT", response.statusCode, response.headers["location"], body
|
console.error "SOMETHING WENT WRONG CREATING PROJECT", response.statusCode, response.headers["location"], body
|
||||||
callback(null, body.project_id)
|
callback(null, body.project_id, body)
|
||||||
|
|
||||||
|
deleteProject: (project_id, callback=(error)) ->
|
||||||
|
@request.delete {
|
||||||
|
url: "/project/#{project_id}"
|
||||||
|
}, (error, response, body) ->
|
||||||
|
return callback(error) if error?
|
||||||
|
callback(null)
|
||||||
|
|
||||||
addUserToProject: (project_id, email, privileges, callback = (error, user) ->) ->
|
addUserToProject: (project_id, email, privileges, callback = (error, user) ->) ->
|
||||||
@request.post {
|
@request.post {
|
||||||
|
|
Loading…
Reference in a new issue