diff --git a/services/web/app/coffee/Features/Compile/ClsiManager.coffee b/services/web/app/coffee/Features/Compile/ClsiManager.coffee index fd65454054..83eb72fcf7 100755 --- a/services/web/app/coffee/Features/Compile/ClsiManager.coffee +++ b/services/web/app/coffee/Features/Compile/ClsiManager.coffee @@ -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 diff --git a/services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee b/services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee index e47f72daca..00e02af13e 100644 --- a/services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee +++ b/services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee @@ -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