mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-05 18:01:01 +00:00
find project by name should only find active projects
This commit is contained in:
parent
297e33f1a0
commit
13af9b7b56
2 changed files with 14 additions and 5 deletions
|
@ -122,11 +122,11 @@ module.exports =
|
|||
async.waterfall jobs, callback
|
||||
|
||||
findUsersProjectByName: (user_id, projectName, callback)->
|
||||
Project.findAllUsersProjects user_id, 'name', (err, projects, collabertions=[])->
|
||||
Project.findAllUsersProjects user_id, 'name archived', (err, projects, collabertions=[])->
|
||||
projects = projects.concat(collabertions)
|
||||
projectName = projectName.toLowerCase()
|
||||
project = _.find projects, (project)->
|
||||
project.name.toLowerCase() == projectName
|
||||
project = _.find projects, (project)->
|
||||
project.name.toLowerCase() == projectName and project.archived != true
|
||||
logger.log user_id:user_id, projectName:projectName, totalProjects:projects.length, project:project, "looking for project by name"
|
||||
callback(null, project)
|
||||
|
||||
|
|
|
@ -293,8 +293,8 @@ describe 'project model', ->
|
|||
done()
|
||||
|
||||
|
||||
describe 'finding a project by user_id and project name', ()->
|
||||
it 'should return the projet from an array case insenstive', (done)->
|
||||
describe 'findUsersProjectByName finding a project by user_id and project name', ()->
|
||||
it 'should return the project from an array case insenstive', (done)->
|
||||
user_id = "123jojoidns"
|
||||
stubbedProject = {name:"findThis"}
|
||||
projects = [{name:"notThis"}, {name:"wellll"}, stubbedProject, {name:"Noooo"}]
|
||||
|
@ -303,6 +303,15 @@ describe 'project model', ->
|
|||
project.should.equal stubbedProject
|
||||
done()
|
||||
|
||||
it 'should return the project which is not archived', (done)->
|
||||
user_id = "123jojoidns"
|
||||
stubbedProject = {name:"findThis", _id:12331321}
|
||||
projects = [{name:"notThis"}, {name:"wellll"}, {name:"findThis",archived:true}, stubbedProject, {name:"findThis",archived:true}, {name:"Noooo"}]
|
||||
Project.findAllUsersProjects = sinon.stub().callsArgWith(2, null, projects)
|
||||
@locator.findUsersProjectByName user_id, stubbedProject.name.toLowerCase(), (err, project)->
|
||||
project._id.should.equal stubbedProject._id
|
||||
done()
|
||||
|
||||
it 'should search collab projects as well', (done)->
|
||||
user_id = "123jojoidns"
|
||||
stubbedProject = {name:"findThis"}
|
||||
|
|
Loading…
Reference in a new issue