mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-11 17:06:43 -05:00
get template details now includes the markdown description of the project
This commit is contained in:
parent
c8c0030b7c
commit
91ca726e66
4 changed files with 41 additions and 1 deletions
|
@ -22,6 +22,9 @@ module.exports =
|
||||||
logger.log project_id:project_id, details:details, "getting project details"
|
logger.log project_id:project_id, details:details, "getting project details"
|
||||||
callback(err, details)
|
callback(err, details)
|
||||||
|
|
||||||
|
getProjectDescription: (project_id, callback)->
|
||||||
|
Project.find _id:project_id, "description", callback
|
||||||
|
|
||||||
setProjectDescription: (project_id, description, callback)->
|
setProjectDescription: (project_id, description, callback)->
|
||||||
conditions = _id:project_id
|
conditions = _id:project_id
|
||||||
update = description:description
|
update = description:description
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
path = require('path')
|
path = require('path')
|
||||||
ProjectUploadManager = require('../Uploads/ProjectUploadManager')
|
ProjectUploadManager = require('../Uploads/ProjectUploadManager')
|
||||||
ProjectOptionsHandler = require("../Project/ProjectOptionsHandler")
|
ProjectOptionsHandler = require("../Project/ProjectOptionsHandler")
|
||||||
|
ProjectDetailsHandler = require('../Project/ProjectDetailsHandler')
|
||||||
TemplatesPublisher = require("./TemplatesPublisher")
|
TemplatesPublisher = require("./TemplatesPublisher")
|
||||||
settings = require('settings-sharelatex')
|
settings = require('settings-sharelatex')
|
||||||
fs = require('fs')
|
fs = require('fs')
|
||||||
|
@ -46,7 +47,10 @@ module.exports =
|
||||||
TemplatesPublisher.getTemplateDetails user_id, project_id, (err, details)->
|
TemplatesPublisher.getTemplateDetails user_id, project_id, (err, details)->
|
||||||
if err?
|
if err?
|
||||||
logger.err err:err, user_id:user_id, project_id:project_id, "something went wrong getting template details"
|
logger.err err:err, user_id:user_id, project_id:project_id, "something went wrong getting template details"
|
||||||
callback(err, details)
|
return callback(err)
|
||||||
|
ProjectDetailsHandler.getProjectDescription project_id, (err, description)->
|
||||||
|
details.description = description
|
||||||
|
callback(err, details)
|
||||||
|
|
||||||
|
|
||||||
setCompiler = (project_id, compiler, callback)->
|
setCompiler = (project_id, compiler, callback)->
|
||||||
|
|
|
@ -23,6 +23,7 @@ describe 'Project details handler', ->
|
||||||
getProject: sinon.stub().callsArgWith(2, null, @project)
|
getProject: sinon.stub().callsArgWith(2, null, @project)
|
||||||
@ProjectModel =
|
@ProjectModel =
|
||||||
update: sinon.stub()
|
update: sinon.stub()
|
||||||
|
find: sinon.stub()
|
||||||
@UserGetter =
|
@UserGetter =
|
||||||
getUser: sinon.stub().callsArgWith(1, null, @user)
|
getUser: sinon.stub().callsArgWith(1, null, @user)
|
||||||
@tpdsUpdateSender =
|
@tpdsUpdateSender =
|
||||||
|
@ -54,6 +55,23 @@ describe 'Project details handler', ->
|
||||||
err.should.equal error
|
err.should.equal error
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
describe "getProjectDescription", ->
|
||||||
|
|
||||||
|
it "should make a call to mongo just for the description", (done)->
|
||||||
|
@ProjectModel.find.callsArgWith(2)
|
||||||
|
@handler.getProjectDescription @project_id, (err, description)=>
|
||||||
|
@ProjectModel.find.calledWith({_id:@project_id}, "description").should.equal true
|
||||||
|
done()
|
||||||
|
|
||||||
|
it "should return what the mongo call returns", (done)->
|
||||||
|
err = "error"
|
||||||
|
description = "cool project"
|
||||||
|
@ProjectModel.find.callsArgWith(2, err, description)
|
||||||
|
@handler.getProjectDescription @project_id, (returnedErr, returnedDescription)=>
|
||||||
|
err.should.equal returnedErr
|
||||||
|
description.should.equal returnedDescription
|
||||||
|
done()
|
||||||
|
|
||||||
describe "setProjectDescription", ->
|
describe "setProjectDescription", ->
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
@ -65,6 +83,8 @@ describe 'Project details handler', ->
|
||||||
@ProjectModel.update.calledWith({_id:@project_id}, {description:@description}).should.equal true
|
@ProjectModel.update.calledWith({_id:@project_id}, {description:@description}).should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe "renameProject", ->
|
describe "renameProject", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@ProjectModel.update.callsArgWith(2)
|
@ProjectModel.update.callsArgWith(2)
|
||||||
|
|
|
@ -25,9 +25,12 @@ describe 'TemplatesController', ->
|
||||||
publish: sinon.stub()
|
publish: sinon.stub()
|
||||||
unpublish:sinon.stub()
|
unpublish:sinon.stub()
|
||||||
getTemplateDetails: sinon.stub()
|
getTemplateDetails: sinon.stub()
|
||||||
|
@ProjectDetailsHandler =
|
||||||
|
getProjectDescription:sinon.stub()
|
||||||
@controller = SandboxedModule.require modulePath, requires:
|
@controller = SandboxedModule.require modulePath, requires:
|
||||||
'../Uploads/ProjectUploadManager':@ProjectUploadManager
|
'../Uploads/ProjectUploadManager':@ProjectUploadManager
|
||||||
'../Project/ProjectOptionsHandler':@ProjectOptionsHandler
|
'../Project/ProjectOptionsHandler':@ProjectOptionsHandler
|
||||||
|
'../Project/ProjectDetailsHandler':@ProjectDetailsHandler
|
||||||
'./TemplatesPublisher':@TemplatesPublisher
|
'./TemplatesPublisher':@TemplatesPublisher
|
||||||
"logger-sharelatex":
|
"logger-sharelatex":
|
||||||
log:->
|
log:->
|
||||||
|
@ -138,6 +141,9 @@ describe 'TemplatesController', ->
|
||||||
|
|
||||||
|
|
||||||
describe 'getTemplateDetails', ->
|
describe 'getTemplateDetails', ->
|
||||||
|
beforeEach ->
|
||||||
|
@description = "this project is nice"
|
||||||
|
@ProjectDetailsHandler.getProjectDescription.callsArgWith(1, null, @description)
|
||||||
|
|
||||||
it "should return an error the templatePublisher", (done)->
|
it "should return an error the templatePublisher", (done)->
|
||||||
error = "error"
|
error = "error"
|
||||||
|
@ -152,3 +158,10 @@ describe 'TemplatesController', ->
|
||||||
@controller.getTemplateDetails @user_id, @project_id, (err, passedDetails)=>
|
@controller.getTemplateDetails @user_id, @project_id, (err, passedDetails)=>
|
||||||
details.should.equal passedDetails
|
details.should.equal passedDetails
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
it "should get the template description", (done)->
|
||||||
|
@TemplatesPublisher.getTemplateDetails.callsArgWith(2, null, {})
|
||||||
|
@controller.getTemplateDetails @user_id, @project_id, (err, passedDetails)=>
|
||||||
|
passedDetails.description.should.equal @description
|
||||||
|
done()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue