mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Return features along with project details
This commit is contained in:
parent
31f39dada1
commit
6318d9ace1
2 changed files with 30 additions and 21 deletions
|
@ -1,4 +1,5 @@
|
||||||
ProjectGetter = require("./ProjectGetter")
|
ProjectGetter = require("./ProjectGetter")
|
||||||
|
UserGetter = require("../User/UserGetter")
|
||||||
Project = require('../../models/Project').Project
|
Project = require('../../models/Project').Project
|
||||||
logger = require("logger-sharelatex")
|
logger = require("logger-sharelatex")
|
||||||
|
|
||||||
|
@ -9,12 +10,15 @@ module.exports =
|
||||||
if err?
|
if err?
|
||||||
logger.err err:err, project_id:project_id, "error getting project"
|
logger.err err:err, project_id:project_id, "error getting project"
|
||||||
return callback(err)
|
return callback(err)
|
||||||
details =
|
UserGetter.getUser project.owner_ref, (err, user) ->
|
||||||
name : project.name
|
return callback(err) if err?
|
||||||
description: project.description
|
details =
|
||||||
compiler: project.compiler
|
name : project.name
|
||||||
logger.log project_id:project_id, details:details, "getting project details"
|
description: project.description
|
||||||
callback(err, details)
|
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)->
|
setProjectDescription: (project_id, description, callback)->
|
||||||
conditions = _id:project_id
|
conditions = _id:project_id
|
||||||
|
|
|
@ -8,36 +8,41 @@ require('chai').should()
|
||||||
describe 'Project details handler', ->
|
describe 'Project details handler', ->
|
||||||
|
|
||||||
beforeEach ->
|
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"
|
@project_id = "321l3j1kjkjl"
|
||||||
|
@user_id = "user-id-123"
|
||||||
@project =
|
@project =
|
||||||
name: "project"
|
name: "project"
|
||||||
description: "this is a great project"
|
description: "this is a great project"
|
||||||
something:"should not exist"
|
something:"should not exist"
|
||||||
compiler: "latexxxxxx"
|
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", ->
|
describe "getDetails", ->
|
||||||
|
|
||||||
it "should find the project", (done)->
|
it "should find the project and owner", (done)->
|
||||||
@ProjectGetter.getProjectWithoutDocLines.callsArgWith(1, null, @project)
|
|
||||||
@handler.getDetails @project_id, (err, details)=>
|
@handler.getDetails @project_id, (err, details)=>
|
||||||
details.name.should.equal @project.name
|
details.name.should.equal @project.name
|
||||||
details.description.should.equal @project.description
|
details.description.should.equal @project.description
|
||||||
details.compiler.should.equal @project.compiler
|
details.compiler.should.equal @project.compiler
|
||||||
|
details.features.should.equal @user.features
|
||||||
assert.equal(details.something, undefined)
|
assert.equal(details.something, undefined)
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
|
||||||
it "should return the error", (done)->
|
it "should return the error", (done)->
|
||||||
error = "some error"
|
error = "some error"
|
||||||
@ProjectGetter.getProjectWithoutDocLines.callsArgWith(1, error)
|
@ProjectGetter.getProjectWithoutDocLines.callsArgWith(1, error)
|
||||||
|
|
Loading…
Reference in a new issue