Эх сурвалжийг харах

coerce projectHistoryId to integer after reading from Redis

Hayden Faulds 8 жил өмнө
parent
commit
af92ca70a1

+ 3 - 0
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"
 				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"))
 				return callback(new Errors.NotFoundError("document not found"))
 
 
+			if projectHistoryId?
+				projectHistoryId = parseInt(projectHistoryId)
+
 			# doc is not in redis, bail out
 			# doc is not in redis, bail out
 			if !docLines?
 			if !docLines?
 				return callback null, docLines, version, ranges, pathname, projectHistoryId, unflushedTime
 				return callback null, docLines, version, ranges, pathname, projectHistoryId, unflushedTime

+ 3 - 3
services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee

@@ -60,7 +60,7 @@ describe "RedisManager", ->
 
 
 		@doc_id = "doc-id-123"
 		@doc_id = "doc-id-123"
 		@project_id = "project-id-123"
 		@project_id = "project-id-123"
-		@projectHistoryId = "history-id-123"
+		@projectHistoryId = 123
 		@callback = sinon.stub()
 		@callback = sinon.stub()
 
 
 	describe "getDoc", ->
 	describe "getDoc", ->
@@ -74,7 +74,7 @@ describe "RedisManager", ->
 			@unflushed_time = 12345
 			@unflushed_time = 12345
 			@pathname = '/a/b/c.tex'
 			@pathname = '/a/b/c.tex'
 			@multi.get = sinon.stub()
 			@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)
 			@rclient.sadd = sinon.stub().yields(null, 0)
 
 
 		describe "successfully", ->
 		describe "successfully", ->
@@ -111,7 +111,7 @@ describe "RedisManager", ->
 					.calledWith("Pathname:#{@doc_id}")
 					.calledWith("Pathname:#{@doc_id}")
 					.should.equal true
 					.should.equal true
 
 
-			it "should get the projectHistoryId", ->
+			it "should get the projectHistoryId as an integer", ->
 				@multi.get
 				@multi.get
 					.calledWith("ProjectHistoryId:#{@doc_id}")
 					.calledWith("ProjectHistoryId:#{@doc_id}")
 					.should.equal true
 					.should.equal true