mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
updated building proj from template, no longer suport other domains and work in different envs
This commit is contained in:
@@ -19,9 +19,8 @@ module.exports =
|
||||
dumpPath = "#{settings.path.dumpFolder}/#{uuid.v4()}"
|
||||
writeStream = fs.createWriteStream(dumpPath)
|
||||
zipUrl = req.session.templateData.zipUrl
|
||||
if zipUrl.indexOf("www") == -1
|
||||
zipUrl = "www.sharelatex.com#{zipUrl}"
|
||||
request("http://#{zipUrl}").pipe(writeStream)
|
||||
zipUrl = "#{settings.apis.templates_api.url}#{zipUrl}"
|
||||
request(zipUrl).pipe(writeStream)
|
||||
writeStream.on 'close', ->
|
||||
ProjectUploadManager.createProjectFromZipArchive req.session.user._id, req.session.templateData.templateName, dumpPath, (err, project)->
|
||||
setCompiler project._id, req.session.templateData.compiler, ->
|
||||
|
||||
@@ -6,7 +6,7 @@ sinon = require('sinon')
|
||||
modulePath = path.join __dirname, '../../../../app/js/Features/Templates/TemplatesController'
|
||||
|
||||
|
||||
describe 'Templates Controller', ->
|
||||
describe 'TemplatesController', ->
|
||||
|
||||
project_id = "213432"
|
||||
|
||||
@@ -36,6 +36,9 @@ describe 'Templates Controller', ->
|
||||
path:
|
||||
dumpFolder:@dumpFolder
|
||||
siteUrl: "http://localhost:3000"
|
||||
apis:
|
||||
templates_api:
|
||||
url: @templateApiUrl="http://templates.sharelatex.env"
|
||||
"node-uuid":v4:=>@uuid
|
||||
"request": @request
|
||||
"fs":@fs
|
||||
@@ -53,34 +56,12 @@ describe 'Templates Controller', ->
|
||||
it 'should take the zip url and write it to disk', (done)->
|
||||
redirect = =>
|
||||
@ProjectUploadManager.createProjectFromZipArchive.calledWith(@user_id, @templateName, "#{@dumpFolder}/#{@uuid}").should.equal true
|
||||
@request.calledWith("http://#{@zipUrl}").should.equal true
|
||||
@request.calledWith("#{@templateApiUrl}#{@zipUrl}").should.equal true
|
||||
@fs.unlink.calledWith("#{@dumpFolder}/#{@uuid}").should.equal true
|
||||
done()
|
||||
res = redirect:redirect
|
||||
@controller.createProjectFromZipTemplate @req, res
|
||||
|
||||
|
||||
|
||||
describe 'reciving a request to create project from non specified domain', ->
|
||||
|
||||
it 'should default to www.sharelatex.com', (done)->
|
||||
@zipUrl = "/templates/cv/different.zip"
|
||||
@req.session.templateData.zipUrl = @zipUrl
|
||||
redirect = =>
|
||||
@request.calledWith("http://www.sharelatex.com#{@zipUrl}").should.equal true
|
||||
done()
|
||||
res = redirect:redirect
|
||||
@controller.createProjectFromZipTemplate @req, res
|
||||
|
||||
it 'should use the different domain if specified', (done)->
|
||||
@zipUrl = "www.latextemplates.com/templates/cv/remote.zip"
|
||||
@req.session.templateData.zipUrl = @zipUrl
|
||||
redirect = =>
|
||||
@request.calledWith("http://#{@zipUrl}").should.equal true
|
||||
done()
|
||||
res = redirect:redirect
|
||||
@controller.createProjectFromZipTemplate @req, res
|
||||
|
||||
describe 'publishProject', (done)->
|
||||
beforeEach ->
|
||||
@user_id = "sdijdlsakjlkajdklaj"
|
||||
|
||||
Reference in New Issue
Block a user