filter track-changes updates for projects using project-history
This commit is contained in:
+8
-1
@@ -27,6 +27,7 @@ describe "DocumentManager", ->
|
||||
"./RangesManager": @RangesManager = {}
|
||||
@project_id = "project-id-123"
|
||||
@projectHistoryId = "history-id-123"
|
||||
@projectHistoryType = "project-history"
|
||||
@doc_id = "doc-id-123"
|
||||
@user_id = 1234
|
||||
@callback = sinon.stub()
|
||||
@@ -178,8 +179,9 @@ describe "DocumentManager", ->
|
||||
describe "when the doc does not exist in Redis", ->
|
||||
beforeEach ->
|
||||
@RedisManager.getDoc = sinon.stub().callsArgWith(2, null, null, null, null, null, null)
|
||||
@PersistenceManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname, @projectHistoryId)
|
||||
@PersistenceManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname, @projectHistoryId, @projectHistoryType)
|
||||
@RedisManager.putDocInMemory = sinon.stub().yields()
|
||||
@RedisManager.setHistoryType = sinon.stub().yields()
|
||||
@DocumentManager.getDoc @project_id, @doc_id, @callback
|
||||
|
||||
it "should try to get the doc from Redis", ->
|
||||
@@ -197,6 +199,11 @@ describe "DocumentManager", ->
|
||||
.calledWith(@project_id, @doc_id, @lines, @version, @ranges, @pathname, @projectHistoryId)
|
||||
.should.equal true
|
||||
|
||||
it "should set the history type in Redis", ->
|
||||
@RedisManager.setHistoryType
|
||||
.calledWith(@doc_id, @projectHistoryType)
|
||||
.should.equal true
|
||||
|
||||
it "should call the callback with the doc info", ->
|
||||
@callback.calledWith(null, @lines, @version, @ranges, @pathname, @projectHistoryId, null, false).should.equal true
|
||||
|
||||
|
||||
+19
-6
@@ -15,7 +15,7 @@ describe "HistoryManager", ->
|
||||
trackchanges:
|
||||
url: "http://trackchanges.example.com"
|
||||
}
|
||||
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
|
||||
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub(), debug: sinon.stub() }
|
||||
"./DocumentManager": @DocumentManager = {}
|
||||
"./HistoryRedisManager": @HistoryRedisManager = {}
|
||||
"./RedisManager": @RedisManager = {}
|
||||
@@ -28,12 +28,25 @@ describe "HistoryManager", ->
|
||||
beforeEach ->
|
||||
@request.post = sinon.stub().callsArgWith(1, null, statusCode: 204)
|
||||
|
||||
@HistoryManager.flushDocChangesAsync @project_id, @doc_id
|
||||
describe "when the project uses track changes", ->
|
||||
beforeEach ->
|
||||
@RedisManager.getHistoryType = sinon.stub().yields(null, 'track-changes')
|
||||
@HistoryManager.flushDocChangesAsync @project_id, @doc_id
|
||||
|
||||
it "should send a request to the track changes api", ->
|
||||
@request.post
|
||||
.calledWith("#{@Settings.apis.trackchanges.url}/project/#{@project_id}/doc/#{@doc_id}/flush")
|
||||
.should.equal true
|
||||
it "should send a request to the track changes api", ->
|
||||
@request.post
|
||||
.calledWith("#{@Settings.apis.trackchanges.url}/project/#{@project_id}/doc/#{@doc_id}/flush")
|
||||
.should.equal true
|
||||
|
||||
describe "when the project uses project history", ->
|
||||
beforeEach ->
|
||||
@RedisManager.getHistoryType = sinon.stub().yields(null, 'project-history')
|
||||
@HistoryManager.flushDocChangesAsync @project_id, @doc_id
|
||||
|
||||
it "should not send a request to the track changes api", ->
|
||||
@request.post
|
||||
.called
|
||||
.should.equal false
|
||||
|
||||
describe "flushProjectChangesAsync", ->
|
||||
beforeEach ->
|
||||
|
||||
@@ -34,6 +34,7 @@ describe "RedisManager", ->
|
||||
ranges: ({doc_id}) -> "Ranges:#{doc_id}"
|
||||
pathname: ({doc_id}) -> "Pathname:#{doc_id}"
|
||||
projectHistoryId: ({doc_id}) -> "ProjectHistoryId:#{doc_id}"
|
||||
projectHistoryType: ({doc_id}) -> "ProjectHistoryType:#{doc_id}"
|
||||
projectState: ({project_id}) -> "ProjectState:#{project_id}"
|
||||
unflushedTime: ({doc_id}) -> "UnflushedTime:#{doc_id}"
|
||||
lastUpdatedBy: ({doc_id}) -> "lastUpdatedBy:#{doc_id}"
|
||||
|
||||
Reference in New Issue
Block a user