From 9a0ec9c292101fc02b1cad44fc882d57fa39e9ef Mon Sep 17 00:00:00 2001 From: James Allen Date: Mon, 21 Mar 2016 13:54:45 +0000 Subject: [PATCH] Don't throw fatal error when recently compiled --- .../coffee/Features/Compile/CompileManager.coffee | 3 ++- .../coffee/Compile/CompileManagerTests.coffee | 13 +++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/services/web/app/coffee/Features/Compile/CompileManager.coffee b/services/web/app/coffee/Features/Compile/CompileManager.coffee index 7cac827789..c89e7107dd 100755 --- a/services/web/app/coffee/Features/Compile/CompileManager.coffee +++ b/services/web/app/coffee/Features/Compile/CompileManager.coffee @@ -26,7 +26,8 @@ module.exports = CompileManager = CompileManager._checkIfRecentlyCompiled project_id, user_id, (error, recentlyCompiled) -> return callback(error) if error? if recentlyCompiled - return callback new Error("project was recently compiled so not continuing") + logger.warn {project_id, user_id}, "project was recently compiled so not continuing" + return callback null, "too-recently-compiled", [] CompileManager._ensureRootDocumentIsSet project_id, (error) -> return callback(error) if error? diff --git a/services/web/test/UnitTests/coffee/Compile/CompileManagerTests.coffee b/services/web/test/UnitTests/coffee/Compile/CompileManagerTests.coffee index e68f5fa422..814b4f258b 100644 --- a/services/web/test/UnitTests/coffee/Compile/CompileManagerTests.coffee +++ b/services/web/test/UnitTests/coffee/Compile/CompileManagerTests.coffee @@ -27,7 +27,7 @@ describe "CompileManager", -> Timer: class Timer done: sinon.stub() inc: sinon.stub() - "logger-sharelatex": @logger = { log: sinon.stub() } + "logger-sharelatex": @logger = { log: sinon.stub(), warn: sinon.stub() } @project_id = "mock-project-id-123" @user_id = "mock-user-id-123" @callback = sinon.stub() @@ -90,15 +90,12 @@ describe "CompileManager", -> .should.equal true describe "when the project has been recently compiled", -> - beforeEach -> + it "should return", (done)-> @CompileManager._checkIfAutoCompileLimitHasBeenHit = (_, cb)-> cb(null, true) @CompileManager._checkIfRecentlyCompiled = sinon.stub().callsArgWith(2, null, true) - @CompileManager.compile @project_id, @user_id, {}, @callback - - it "should return the callback with an error", -> - @callback - .calledWith(new Error("project was recently compiled so not continuing")) - .should.equal true + @CompileManager.compile @project_id, @user_id, {}, (err, status)-> + status.should.equal "too-recently-compiled" + done() describe "should check the rate limit", -> it "should return", (done)->