mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Pass image to wordcount end point in CLSI
This commit is contained in:
parent
5125aa0089
commit
ed5872702a
2 changed files with 15 additions and 2 deletions
|
@ -111,8 +111,11 @@ module.exports = ClsiManager =
|
|||
ClsiManager._buildRequest project_id, options, (error, req) ->
|
||||
compilerUrl = ClsiManager._getCompilerUrl(options?.compileGroup)
|
||||
filename = file || req?.compile?.rootResourcePath
|
||||
wordcount_url = "#{compilerUrl}/project/#{project_id}/wordcount?file=#{encodeURIComponent(filename)}"
|
||||
if req.compile.options.imageName?
|
||||
wordcount_url += "&image=#{encodeURIComponent(req.compile.options.imageName)}"
|
||||
request.get {
|
||||
url: "#{compilerUrl}/project/#{project_id}/wordcount?file=#{filename}"
|
||||
url: wordcount_url
|
||||
}, (error, response, body) ->
|
||||
return callback(error) if error?
|
||||
if 200 <= response.statusCode < 300
|
||||
|
|
|
@ -266,7 +266,7 @@ describe "ClsiManager", ->
|
|||
describe "wordCount", ->
|
||||
beforeEach ->
|
||||
@request.get = sinon.stub().callsArgWith(1, null, {statusCode: 200}, @body = { mock: "foo" })
|
||||
@ClsiManager._buildRequest = sinon.stub().callsArgWith(2, null, { compile: { rootResourcePath: "rootfile.text" } })
|
||||
@ClsiManager._buildRequest = sinon.stub().callsArgWith(2, null, @req = { compile: { rootResourcePath: "rootfile.text", options: {} } })
|
||||
@ClsiManager._getCompilerUrl = sinon.stub().returns "compiler.url"
|
||||
|
||||
describe "with root file", ->
|
||||
|
@ -289,3 +289,13 @@ describe "ClsiManager", ->
|
|||
@request.get
|
||||
.calledWith({ url: "compiler.url/project/#{@project_id}/wordcount?file=main.tex" })
|
||||
.should.equal true
|
||||
|
||||
describe "with image", ->
|
||||
beforeEach ->
|
||||
@req.compile.options.imageName = @image = "example.com/mock/image"
|
||||
@ClsiManager.wordCount @project_id, "main.tex", {}, @callback
|
||||
|
||||
it "should call wordCount with file and image", ->
|
||||
@request.get
|
||||
.calledWith({ url: "compiler.url/project/#{@project_id}/wordcount?file=main.tex&image=#{encodeURIComponent(@image)}" })
|
||||
.should.equal true
|
||||
|
|
Loading…
Reference in a new issue