Return features along with project details

This commit is contained in:
James Allen 2014-03-28 12:47:15 +00:00
parent 31f39dada1
commit 6318d9ace1
2 changed files with 30 additions and 21 deletions

View file

@ -1,4 +1,5 @@
ProjectGetter = require("./ProjectGetter")
UserGetter = require("../User/UserGetter")
Project = require('../../models/Project').Project
logger = require("logger-sharelatex")
@ -9,12 +10,15 @@ module.exports =
if err?
logger.err err:err, project_id:project_id, "error getting project"
return callback(err)
details =
name : project.name
description: project.description
compiler: project.compiler
logger.log project_id:project_id, details:details, "getting project details"
callback(err, details)
UserGetter.getUser project.owner_ref, (err, user) ->
return callback(err) if err?
details =
name : project.name
description: project.description
compiler: project.compiler
features: user.features
logger.log project_id:project_id, details:details, "getting project details"
callback(err, details)
setProjectDescription: (project_id, description, callback)->
conditions = _id:project_id

View file

@ -8,36 +8,41 @@ require('chai').should()
describe 'Project details handler', ->
beforeEach ->
@ProjectGetter =
getProjectWithoutDocLines: sinon.stub()
@ProjectModel =
update: sinon.stub()
@handler = SandboxedModule.require modulePath, requires:
"./ProjectGetter":@ProjectGetter
'../../models/Project': Project:@ProjectModel
'logger-sharelatex':
log:->
err:->
@project_id = "321l3j1kjkjl"
@user_id = "user-id-123"
@project =
name: "project"
description: "this is a great project"
something:"should not exist"
compiler: "latexxxxxx"
owner_ref: @user_id
@user =
features: "mock-features"
@ProjectGetter =
getProjectWithoutDocLines: sinon.stub().callsArgWith(1, null, @project)
@ProjectModel =
update: sinon.stub()
@UserGetter =
getUser: sinon.stub().callsArgWith(1, null, @user)
@handler = SandboxedModule.require modulePath, requires:
"./ProjectGetter":@ProjectGetter
'../../models/Project': Project:@ProjectModel
"../User/UserGetter": @UserGetter
'logger-sharelatex':
log:->
err:->
describe "getDetails", ->
it "should find the project", (done)->
@ProjectGetter.getProjectWithoutDocLines.callsArgWith(1, null, @project)
it "should find the project and owner", (done)->
@handler.getDetails @project_id, (err, details)=>
details.name.should.equal @project.name
details.description.should.equal @project.description
details.compiler.should.equal @project.compiler
details.features.should.equal @user.features
assert.equal(details.something, undefined)
done()
it "should return the error", (done)->
error = "some error"
@ProjectGetter.getProjectWithoutDocLines.callsArgWith(1, error)