 				@rclient.del
 					.calledWith("Ranges:#{@doc_id}")
 					.should.equal true
+
+		describe "with a corrupted write", ->
+			beforeEach ->
+				@badHash = "INVALID-HASH-VALUE"
+				@rclient.exec = sinon.stub().callsArgWith(0, null, [@badHash])
+				@RedisManager.getDocVersion.withArgs(@doc_id).yields(null, @version - @ops.length)
+				@RedisManager.updateDocument @doc_id, @lines, @version, @ops, @ranges, @callback
+
+			it 'should log a hash error', ->
+				@logger.error.calledWith()
+					.should.equal true
+
+			it "should call the callback", ->
+				@callback.called.should.equal true
 
 	describe "putDocInMemory", ->
 		beforeEach ->

				@rclient.sadd
					.calledWith("DocsIn:#{@project_id}", @doc_id)
					.should.equal true
	
		describe "with empty ranges", ->
			beforeEach (done) ->

				@rclient.set
					.calledWith("Ranges:#{@doc_id}", JSON.stringify(@ranges))
					.should.equal false

		describe "with a corrupted write", ->
			beforeEach (done) ->
				@rclient.exec = sinon.stub().callsArgWith(0, null, ["INVALID-HASH-VALUE"])
				@RedisManager.putDocInMemory @project_id, @doc_id, @lines, @version, @ranges, done

			it 'should log a hash error', ->
				@logger.error.calledWith()
					.should.equal true

	describe "removeDocFromMemory", ->
		beforeEach (done) ->
