mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-05 07:20:08 +00:00
return overleaf details from ProejctsDetailsHandler.getdetails
This commit is contained in:
parent
2d3bae2f7b
commit
2c0e9bb89a
2 changed files with 19 additions and 8 deletions
|
@ -9,7 +9,7 @@ Errors = require("../Errors/Errors")
|
|||
|
||||
module.exports = ProjectDetailsHandler =
|
||||
getDetails: (project_id, callback)->
|
||||
ProjectGetter.getProject project_id, {name:true, description:true, compiler:true, features:true, owner_ref:true}, (err, project)->
|
||||
ProjectGetter.getProject project_id, {name:true, description:true, compiler:true, features:true, owner_ref:true, overleaf:true}, (err, project)->
|
||||
if err?
|
||||
logger.err err:err, project_id:project_id, "error getting project"
|
||||
return callback(err)
|
||||
|
@ -21,7 +21,11 @@ module.exports = ProjectDetailsHandler =
|
|||
description: project.description
|
||||
compiler: project.compiler
|
||||
features: user.features
|
||||
logger.log project_id:project_id, details:details, "getting project details"
|
||||
|
||||
if project.overleaf?
|
||||
details.overleaf = project.overleaf
|
||||
|
||||
logger.log project_id:project_id, details: details, "getting project details"
|
||||
callback(err, details)
|
||||
|
||||
getProjectDescription: (project_id, callback)->
|
||||
|
@ -66,4 +70,4 @@ module.exports = ProjectDetailsHandler =
|
|||
logger.log project_id: project_id, level: newAccessLevel, "set public access level"
|
||||
if project_id? && newAccessLevel? and _.include [PublicAccessLevels.READ_ONLY, PublicAccessLevels.READ_AND_WRITE, PublicAccessLevels.PRIVATE], newAccessLevel
|
||||
Project.update {_id:project_id},{publicAccesLevel:newAccessLevel}, (err)->
|
||||
callback()
|
||||
callback()
|
||||
|
|
|
@ -12,7 +12,7 @@ describe 'ProjectDetailsHandler', ->
|
|||
beforeEach ->
|
||||
@project_id = "321l3j1kjkjl"
|
||||
@user_id = "user-id-123"
|
||||
@project =
|
||||
@project =
|
||||
name: "project"
|
||||
description: "this is a great project"
|
||||
something:"should not exist"
|
||||
|
@ -20,7 +20,7 @@ describe 'ProjectDetailsHandler', ->
|
|||
owner_ref: @user_id
|
||||
@user =
|
||||
features: "mock-features"
|
||||
@ProjectGetter =
|
||||
@ProjectGetter =
|
||||
getProjectWithoutDocLines: sinon.stub().callsArgWith(1, null, @project)
|
||||
getProject: sinon.stub().callsArgWith(2, null, @project)
|
||||
@ProjectModel =
|
||||
|
@ -42,7 +42,7 @@ describe 'ProjectDetailsHandler', ->
|
|||
describe "getDetails", ->
|
||||
|
||||
it "should find the project and owner", (done)->
|
||||
@handler.getDetails @project_id, (err, details)=>
|
||||
@handler.getDetails @project_id, (err, details)=>
|
||||
details.name.should.equal @project.name
|
||||
details.description.should.equal @project.description
|
||||
details.compiler.should.equal @project.compiler
|
||||
|
@ -50,6 +50,13 @@ describe 'ProjectDetailsHandler', ->
|
|||
assert.equal(details.something, undefined)
|
||||
done()
|
||||
|
||||
it "should find overleaf metadata if it exists", (done)->
|
||||
@project.overleaf = { id: 'id' }
|
||||
@handler.getDetails @project_id, (err, details)=>
|
||||
details.overleaf.should.equal @project.overleaf
|
||||
assert.equal(details.something, undefined)
|
||||
done()
|
||||
|
||||
it "should return an error for a non-existent project", (done)->
|
||||
@ProjectGetter.getProject.callsArg(2, null, null)
|
||||
err = new Errors.NotFoundError("project not found")
|
||||
|
@ -79,7 +86,7 @@ describe 'ProjectDetailsHandler', ->
|
|||
@handler.getProjectDescription @project_id, (returnedErr, returnedDescription)=>
|
||||
err.should.equal returnedErr
|
||||
description.should.equal returnedDescription
|
||||
done()
|
||||
done()
|
||||
|
||||
describe "setProjectDescription", ->
|
||||
|
||||
|
@ -110,7 +117,7 @@ describe 'ProjectDetailsHandler', ->
|
|||
@handler.renameProject @project_id, @newName, =>
|
||||
@tpdsUpdateSender.moveEntity.calledWith({project_id:@project_id, project_name:@project.name, newProjectName:@newName}).should.equal true
|
||||
done()
|
||||
|
||||
|
||||
it "should not do anything with an invalid name", (done) ->
|
||||
@handler.validateProjectName = sinon.stub().yields(new Error("invalid name"))
|
||||
@handler.renameProject @project_id, @newName, =>
|
||||
|
|
Loading…
Reference in a new issue