mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-28 23:33:42 -05:00
added logging around publishing templates and changed another templates-api -> templates
This commit is contained in:
parent
69904e2acd
commit
04bdde4d0d
4 changed files with 16 additions and 6 deletions
|
@ -38,7 +38,10 @@ module.exports =
|
||||||
TemplatesPublisher.unpublish user_id, project_id, callback
|
TemplatesPublisher.unpublish user_id, project_id, callback
|
||||||
|
|
||||||
getTemplateDetails: (user_id, project_id, callback)->
|
getTemplateDetails: (user_id, project_id, callback)->
|
||||||
TemplatesPublisher.getTemplateDetails user_id, project_id, callback
|
TemplatesPublisher.getTemplateDetails user_id, project_id, (err, details)->
|
||||||
|
if err?
|
||||||
|
logger.err err:err, user_id:user_id, project_id:project_id, "something went wrong getting template details"
|
||||||
|
callback(err, details)
|
||||||
|
|
||||||
|
|
||||||
setCompiler = (project_id, compiler, callback)->
|
setCompiler = (project_id, compiler, callback)->
|
||||||
|
|
|
@ -20,12 +20,17 @@ module.exports =
|
||||||
getTemplateDetails: (user_id, project_id, callback)->
|
getTemplateDetails: (user_id, project_id, callback)->
|
||||||
url = buildUrl(user_id, project_id)+"/details"
|
url = buildUrl(user_id, project_id)+"/details"
|
||||||
request.get url, (err, res, body)->
|
request.get url, (err, res, body)->
|
||||||
|
if err?
|
||||||
|
logger.err err:err, user_id:user_id, project_id:project_id, body:body, "error getting template details"
|
||||||
|
return callback err
|
||||||
try
|
try
|
||||||
json = JSON.parse body
|
json = JSON.parse body
|
||||||
catch err
|
catch err
|
||||||
|
logger.err err:err, user_id:user_id, project_id:project_id, body:body, "error parsing project json details"
|
||||||
return callback err
|
return callback err
|
||||||
|
logger.log json:json, user_id:user_id, project_id:project_id, "got template details"
|
||||||
callback(err, json)
|
callback(err, json)
|
||||||
|
|
||||||
|
|
||||||
buildUrl = (user_id, project_id)->
|
buildUrl = (user_id, project_id)->
|
||||||
url = "#{settings.apis.templates_api.url}/templates-api/user/#{user_id}/project/#{project_id}"
|
url = "#{settings.apis.templates_api.url}/templates/user/#{user_id}/project/#{project_id}"
|
||||||
|
|
|
@ -29,7 +29,9 @@ describe 'Templates Controller', ->
|
||||||
'../Uploads/ProjectUploadManager':@ProjectUploadManager
|
'../Uploads/ProjectUploadManager':@ProjectUploadManager
|
||||||
'../Project/ProjectOptionsHandler':@ProjectOptionsHandler
|
'../Project/ProjectOptionsHandler':@ProjectOptionsHandler
|
||||||
'./TemplatesPublisher':@TemplatesPublisher
|
'./TemplatesPublisher':@TemplatesPublisher
|
||||||
"logger-sharelatex": log:->
|
"logger-sharelatex":
|
||||||
|
log:->
|
||||||
|
err:->
|
||||||
"settings-sharelatex":
|
"settings-sharelatex":
|
||||||
path:
|
path:
|
||||||
dumpFolder:@dumpFolder
|
dumpFolder:@dumpFolder
|
||||||
|
|
|
@ -28,7 +28,7 @@ describe 'Templates publish', ->
|
||||||
|
|
||||||
it 'should post the project to the templates api', (done)->
|
it 'should post the project to the templates api', (done)->
|
||||||
@TemplatesPublisher.publish @user_id, @project_id, =>
|
@TemplatesPublisher.publish @user_id, @project_id, =>
|
||||||
uri = "#{@settings.apis.templates_api.url}/templates-api/user/#{@user_id}/project/#{@project_id}"
|
uri = "#{@settings.apis.templates_api.url}/templates/user/#{@user_id}/project/#{@project_id}"
|
||||||
console.log @request.post.args, uri
|
console.log @request.post.args, uri
|
||||||
@request.post.calledWith(uri).should.equal true
|
@request.post.calledWith(uri).should.equal true
|
||||||
done()
|
done()
|
||||||
|
@ -38,7 +38,7 @@ describe 'Templates publish', ->
|
||||||
|
|
||||||
it "should make a DELETE request to templates api", (done)->
|
it "should make a DELETE request to templates api", (done)->
|
||||||
@TemplatesPublisher.unpublish @user_id, @project_id, =>
|
@TemplatesPublisher.unpublish @user_id, @project_id, =>
|
||||||
uri = "#{@settings.apis.templates_api.url}/templates-api/user/#{@user_id}/project/#{@project_id}"
|
uri = "#{@settings.apis.templates_api.url}/templates/user/#{@user_id}/project/#{@project_id}"
|
||||||
@request.del.calledWith(uri).should.equal true
|
@request.del.calledWith(uri).should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ describe 'Templates publish', ->
|
||||||
exists:true
|
exists:true
|
||||||
@request.get.callsArgWith(1, null, null, JSON.stringify(body))
|
@request.get.callsArgWith(1, null, null, JSON.stringify(body))
|
||||||
@TemplatesPublisher.getTemplateDetails @user_id, @project_id, (err, details)=>
|
@TemplatesPublisher.getTemplateDetails @user_id, @project_id, (err, details)=>
|
||||||
uri = "#{@settings.apis.templates_api.url}/templates-api/user/#{@user_id}/project/#{@project_id}/details"
|
uri = "#{@settings.apis.templates_api.url}/templates/user/#{@user_id}/project/#{@project_id}/details"
|
||||||
@request.get.calledWith(uri).should.equal true
|
@request.get.calledWith(uri).should.equal true
|
||||||
assert.deepEqual details, body
|
assert.deepEqual details, body
|
||||||
done()
|
done()
|
||||||
|
|
Loading…
Reference in a new issue