 				@rclient.set
 					.calledWith("DocVersion:#{@doc_id}", @version)
 					.should.equal true
+				
+			it "should set the track changes entries", ->
+				@rclient.set
+					.calledWith("TrackChangesEntries:#{@doc_id}", JSON.stringify(@track_changes_entries))
+					.should.equal true
 
 			it "should push the doc op into the doc ops list", ->
 				@rclient.rpush

			@lines = ["one", "two", "three"]
			@jsonlines = JSON.stringify @lines
			@version = 42
			@rclient.get = sinon.stub()
			@rclient.exec = sinon.stub().callsArgWith(0, null, [@jsonlines, @version, @project_id])
			@RedisManager.getDoc @project_id, @doc_id, @callback
		
		it "should get the lines from redis", ->
			@rclient.get
				.calledWith("doclines:#{@doc_id}")
				.should.equal true
		
		it "should get the version from", ->
			@rclient.get
				.calledWith("DocVersion:#{@doc_id}")
				.should.equal true

		it 'should return the document', ->
			@callback
				.calledWith(null, @lines, @version)
				.should.equal true

	describe "getDoc with an invalid project id", ->
		beforeEach ->
			@lines = ["one", "two", "three"]
			@jsonlines = JSON.stringify @lines
			@version = 42
			@another_project_id = "project-id-456"
			@rclient.get = sinon.stub()
			@rclient.exec = sinon.stub().callsArgWith(0, null, [@jsonlines, @version, @another_project_id])
			@RedisManager.getDoc @project_id, @doc_id, @callback

		it 'should return an error', ->
			@callback
				.calledWith(new Errors.NotFoundError("not found"))
				.should.equal true

	describe "getPreviousDocOpsTests", ->
		describe "with a start and an end value", ->

			@lines = ["one", "two", "three"]
			@ops = [{ op: [{ i: "foo", p: 4 }] },{ op: [{ i: "bar", p: 8 }] }]
			@version = 42
			@track_changes_entries = { comments: "mock", entries: "mock" }

			@rclient.exec = sinon.stub().callsArg(0)

		describe "with a consistent version", ->
			beforeEach ->
				@RedisManager.getDocVersion.withArgs(@doc_id).yields(null, @version - @ops.length)
				@RedisManager.updateDocument @doc_id, @lines, @version, @ops, @track_changes_entries, @callback
		
			it "should get the current doc version to check for consistency", ->
				@RedisManager.getDocVersion
