Move project locator to mongojs

This commit is contained in:
Henry Oswald 2016-02-26 08:31:47 +00:00
parent 586d4cbae1
commit 6ca69f88ac
2 changed files with 6 additions and 2 deletions

View file

@ -1,4 +1,5 @@
Project = require('../../models/Project').Project
ProjectGetter = require("./ProjectGetter")
Errors = require "../../errors"
_ = require('underscore')
logger = require('logger-sharelatex')
@ -50,7 +51,7 @@ module.exports =
if project?
startSearch(project)
else
Project.findById project_id, (err, project)->
ProjectGetter.getProject project_id, (err, project)->
return callback(err) if err?
if !project?
return callback(new Errors.NotFoundError("project not found"))

View file

@ -30,7 +30,7 @@ project.rootFolder[0] = rootFolder
project.rootDoc_id = rootDoc._id
describe 'project model', ->
describe 'ProjectLocatorTests', ->
beforeEach ->
Project.getProject = (project_id, fields, callback)=>
@ -38,9 +38,12 @@ describe 'project model', ->
Project.findById = (project_id, callback)=>
callback(null, project)
@ProjectGetter =
getProject: sinon.stub().callsArgWith(1, null, project)
@locator = SandboxedModule.require modulePath, requires:
'../../models/Project':{Project:Project}
'../../models/User':{User:@User}
"./ProjectGetter":@ProjectGetter
'logger-sharelatex':
log:->
err:->