Add in project flushing end point
This commit is contained in:
@@ -4,17 +4,24 @@ rclient = require("redis").createClient() # Only works locally for now
|
||||
|
||||
module.exports = TrackChangesClient =
|
||||
flushAndGetCompressedUpdates: (project_id, doc_id, callback = (error, updates) ->) ->
|
||||
TrackChangesClient.flushUpdates project_id, doc_id, (error) ->
|
||||
TrackChangesClient.flushDoc project_id, doc_id, (error) ->
|
||||
return callback(error) if error?
|
||||
TrackChangesClient.getCompressedUpdates doc_id, callback
|
||||
|
||||
flushUpdates: (project_id, doc_id, callback = (error) ->) ->
|
||||
flushDoc: (project_id, doc_id, callback = (error) ->) ->
|
||||
request.post {
|
||||
url: "http://localhost:3015/project/#{project_id}/doc/#{doc_id}/flush"
|
||||
}, (error, response, body) =>
|
||||
response.statusCode.should.equal 204
|
||||
callback(error)
|
||||
|
||||
flushProject: (project_id, callback = (error) ->) ->
|
||||
request.post {
|
||||
url: "http://localhost:3015/project/#{project_id}/flush"
|
||||
}, (error, response, body) =>
|
||||
response.statusCode.should.equal 204
|
||||
callback(error)
|
||||
|
||||
getCompressedUpdates: (doc_id, callback = (error, updates) ->) ->
|
||||
db.docHistory
|
||||
.find(doc_id: ObjectId(doc_id))
|
||||
|
||||
@@ -18,7 +18,7 @@ describe "HttpController", ->
|
||||
@user_id = "mock-user-123"
|
||||
@now = Date.now()
|
||||
|
||||
describe "flushUpdatesWithLock", ->
|
||||
describe "flushDoc", ->
|
||||
beforeEach ->
|
||||
@req =
|
||||
params:
|
||||
@@ -27,7 +27,7 @@ describe "HttpController", ->
|
||||
@res =
|
||||
send: sinon.stub()
|
||||
@UpdatesManager.processUncompressedUpdatesWithLock = sinon.stub().callsArg(2)
|
||||
@HttpController.flushUpdatesWithLock @req, @res, @next
|
||||
@HttpController.flushDoc @req, @res, @next
|
||||
|
||||
it "should process the updates", ->
|
||||
@UpdatesManager.processUncompressedUpdatesWithLock
|
||||
@@ -37,6 +37,25 @@ describe "HttpController", ->
|
||||
it "should return a success code", ->
|
||||
@res.send.calledWith(204).should.equal true
|
||||
|
||||
describe "flushProject", ->
|
||||
beforeEach ->
|
||||
@req =
|
||||
params:
|
||||
project_id: @project_id
|
||||
@res =
|
||||
send: sinon.stub()
|
||||
@UpdatesManager.processUncompressedUpdatesForProject = sinon.stub().callsArg(1)
|
||||
@HttpController.flushProject @req, @res, @next
|
||||
|
||||
it "should process the updates", ->
|
||||
@UpdatesManager.processUncompressedUpdatesForProject
|
||||
.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
it "should return a success code", ->
|
||||
@res.send.calledWith(204).should.equal true
|
||||
|
||||
|
||||
describe "getDiff", ->
|
||||
beforeEach ->
|
||||
@from = 42
|
||||
|
||||
Reference in New Issue
Block a user