mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-10 21:23:25 +00:00
Merge pull request #1916 from overleaf/ta-join-project-404
Return 404 on JoinProject When Project Is Not Found GitOrigin-RevId: cd87ce6e2564fd4a80faa66e8b22edec7b0c783c
This commit is contained in:
parent
0e52453931
commit
cf940cc835
2 changed files with 23 additions and 2 deletions
|
@ -28,6 +28,7 @@ const CollaboratorsInviteHandler = require('../Collaborators/CollaboratorsInvite
|
|||
const PrivilegeLevels = require('../Authorization/PrivilegeLevels')
|
||||
const TokenAccessHandler = require('../TokenAccess/TokenAccessHandler')
|
||||
const AuthenticationController = require('../Authentication/AuthenticationController')
|
||||
const Errors = require('../Errors/Errors')
|
||||
|
||||
module.exports = EditorHttpController = {
|
||||
joinProject(req, res, next) {
|
||||
|
@ -73,7 +74,7 @@ module.exports = EditorHttpController = {
|
|||
return callback(error)
|
||||
}
|
||||
if (project == null) {
|
||||
return callback(new Error('not found'))
|
||||
return callback(new Errors.NotFoundError('project not found'))
|
||||
}
|
||||
return CollaboratorsHandler.getInvitedMembersWithPrivilegeLevels(
|
||||
project_id,
|
||||
|
|
|
@ -16,6 +16,7 @@ const modulePath = require('path').join(
|
|||
__dirname,
|
||||
'../../../../app/src/Features/Editor/EditorHttpController'
|
||||
)
|
||||
const Errors = require('../../../../app/src/Features/Errors/Errors')
|
||||
|
||||
describe('EditorHttpController', function() {
|
||||
beforeEach(function() {
|
||||
|
@ -37,7 +38,8 @@ describe('EditorHttpController', function() {
|
|||
'../Collaborators/CollaboratorsHandler': (this.CollaboratorsHandler = {}),
|
||||
'../Collaborators/CollaboratorsInviteHandler': (this.CollaboratorsInviteHandler = {}),
|
||||
'../TokenAccess/TokenAccessHandler': (this.TokenAccessHandler = {}),
|
||||
'../Authentication/AuthenticationController': (this.AuthenticationController = {})
|
||||
'../Authentication/AuthenticationController': (this.AuthenticationController = {}),
|
||||
'../Errors/Errors': Errors
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -186,6 +188,24 @@ describe('EditorHttpController', function() {
|
|||
.callsArgWith(2, null, this.user))
|
||||
})
|
||||
|
||||
describe('when project is not found', function() {
|
||||
beforeEach(function() {
|
||||
this.ProjectGetter.getProjectWithoutDocLines.yields(null, null)
|
||||
return this.EditorHttpController._buildJoinProjectView(
|
||||
this.req,
|
||||
this.project_id,
|
||||
this.user_id,
|
||||
this.callback
|
||||
)
|
||||
})
|
||||
|
||||
it('should handle return not found error', function() {
|
||||
let args = this.callback.lastCall.args
|
||||
args.length.should.equal(1)
|
||||
args[0].should.be.instanceof(Errors.NotFoundError)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when authorized', function() {
|
||||
beforeEach(function() {
|
||||
this.AuthorizationManager.getPrivilegeLevelForProject = sinon
|
||||
|
|
Loading…
Reference in a new issue