From af92ca70a17de24e3ff4c82720ae93ca8e698d0e Mon Sep 17 00:00:00 2001 From: Hayden Faulds Date: Mon, 23 Apr 2018 15:19:06 +0100 Subject: [PATCH] coerce projectHistoryId to integer after reading from Redis --- services/document-updater/app/coffee/RedisManager.coffee | 3 +++ .../test/unit/coffee/RedisManager/RedisManagerTests.coffee | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/services/document-updater/app/coffee/RedisManager.coffee b/services/document-updater/app/coffee/RedisManager.coffee index a940970176..25dbafc6e7 100644 --- a/services/document-updater/app/coffee/RedisManager.coffee +++ b/services/document-updater/app/coffee/RedisManager.coffee @@ -148,6 +148,9 @@ module.exports = RedisManager = logger.error project_id: project_id, doc_id: doc_id, doc_project_id: doc_project_id, "doc not in project" return callback(new Errors.NotFoundError("document not found")) + if projectHistoryId? + projectHistoryId = parseInt(projectHistoryId) + # doc is not in redis, bail out if !docLines? return callback null, docLines, version, ranges, pathname, projectHistoryId, unflushedTime diff --git a/services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee b/services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee index e2263c21f4..42d06d743a 100644 --- a/services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee @@ -60,7 +60,7 @@ describe "RedisManager", -> @doc_id = "doc-id-123" @project_id = "project-id-123" - @projectHistoryId = "history-id-123" + @projectHistoryId = 123 @callback = sinon.stub() describe "getDoc", -> @@ -74,7 +74,7 @@ describe "RedisManager", -> @unflushed_time = 12345 @pathname = '/a/b/c.tex' @multi.get = sinon.stub() - @multi.exec = sinon.stub().callsArgWith(0, null, [@jsonlines, @version, @hash, @project_id, @json_ranges, @pathname, @projectHistoryId, @unflushed_time]) + @multi.exec = sinon.stub().callsArgWith(0, null, [@jsonlines, @version, @hash, @project_id, @json_ranges, @pathname, @projectHistoryId.toString(), @unflushed_time]) @rclient.sadd = sinon.stub().yields(null, 0) describe "successfully", -> @@ -111,7 +111,7 @@ describe "RedisManager", -> .calledWith("Pathname:#{@doc_id}") .should.equal true - it "should get the projectHistoryId", -> + it "should get the projectHistoryId as an integer", -> @multi.get .calledWith("ProjectHistoryId:#{@doc_id}") .should.equal true