From fec648666c30e881de9bbd0e55473e6d0e904bea Mon Sep 17 00:00:00 2001 From: James Allen Date: Wed, 19 Mar 2014 16:14:17 +0000 Subject: [PATCH] Add in project_id to flushing HTTP endpoint --- services/track-changes/app.coffee | 2 +- .../coffee/AppendingUpdatesTests.coffee | 16 ++++++++++------ .../coffee/helpers/TrackChangesClient.coffee | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/services/track-changes/app.coffee b/services/track-changes/app.coffee index 7c47607aeb..4e62a63c28 100644 --- a/services/track-changes/app.coffee +++ b/services/track-changes/app.coffee @@ -10,7 +10,7 @@ app = express() app.use express.logger() -app.post "/doc/:doc_id/flush", HttpController.flushUpdatesWithLock +app.post "/project/:project_id/doc/:doc_id/flush", HttpController.flushUpdatesWithLock app.get "/project/:project_id/doc/:doc_id/diff", HttpController.getDiff diff --git a/services/track-changes/test/acceptance/coffee/AppendingUpdatesTests.coffee b/services/track-changes/test/acceptance/coffee/AppendingUpdatesTests.coffee index 827d238239..80d6815acc 100644 --- a/services/track-changes/test/acceptance/coffee/AppendingUpdatesTests.coffee +++ b/services/track-changes/test/acceptance/coffee/AppendingUpdatesTests.coffee @@ -13,6 +13,7 @@ TrackChangesClient = require "./helpers/TrackChangesClient" describe "Appending doc ops to the history", -> describe "when the history does not exist yet", -> before (done) -> + @project_id = ObjectId().toString() @doc_id = ObjectId().toString() @user_id = ObjectId().toString() TrackChangesClient.pushRawUpdates @doc_id, [{ @@ -29,7 +30,7 @@ describe "Appending doc ops to the history", -> v: 5 }], (error) => throw error if error? - TrackChangesClient.flushAndGetCompressedUpdates @doc_id, (error, @updates) => + TrackChangesClient.flushAndGetCompressedUpdates @project_id, @doc_id, (error, @updates) => throw error if error? done() @@ -43,6 +44,7 @@ describe "Appending doc ops to the history", -> describe "when the history has already been started", -> beforeEach (done) -> + @project_id = ObjectId().toString() @doc_id = ObjectId().toString() @user_id = ObjectId().toString() TrackChangesClient.pushRawUpdates @doc_id, [{ @@ -59,7 +61,7 @@ describe "Appending doc ops to the history", -> v: 5 }], (error) => throw error if error? - TrackChangesClient.flushAndGetCompressedUpdates @doc_id, (error, updates) => + TrackChangesClient.flushAndGetCompressedUpdates @project_id, @doc_id, (error, updates) => throw error if error? done() @@ -79,7 +81,7 @@ describe "Appending doc ops to the history", -> v: 8 }], (error) => throw error if error? - TrackChangesClient.flushAndGetCompressedUpdates @doc_id, (error, @updates) => + TrackChangesClient.flushAndGetCompressedUpdates @project_id, @doc_id, (error, @updates) => throw error if error? done() @@ -109,7 +111,7 @@ describe "Appending doc ops to the history", -> v: 8 }], (error) => throw error if error? - TrackChangesClient.flushAndGetCompressedUpdates @doc_id, (error, @updates) => + TrackChangesClient.flushAndGetCompressedUpdates @project_id, @doc_id, (error, @updates) => throw error if error? done() @@ -123,6 +125,7 @@ describe "Appending doc ops to the history", -> describe "when the updates need processing in batches", -> before (done) -> + @project_id = ObjectId().toString() @doc_id = ObjectId().toString() @user_id = ObjectId().toString() updates = [] @@ -137,7 +140,7 @@ describe "Appending doc ops to the history", -> TrackChangesClient.pushRawUpdates @doc_id, updates, (error) => throw error if error? - TrackChangesClient.flushAndGetCompressedUpdates @doc_id, (error, @updates) => + TrackChangesClient.flushAndGetCompressedUpdates @project_id, @doc_id, (error, @updates) => throw error if error? done() @@ -150,6 +153,7 @@ describe "Appending doc ops to the history", -> describe "when there are multiple ops in each update", -> before (done) -> + @project_id = ObjectId().toString() @doc_id = ObjectId().toString() @user_id = ObjectId().toString() oneDay = 24 * 60 * 60 * 1000 @@ -163,7 +167,7 @@ describe "Appending doc ops to the history", -> v: 4 }], (error) => throw error if error? - TrackChangesClient.flushAndGetCompressedUpdates @doc_id, (error, @updates) => + TrackChangesClient.flushAndGetCompressedUpdates @project_id, @doc_id, (error, @updates) => throw error if error? done() diff --git a/services/track-changes/test/acceptance/coffee/helpers/TrackChangesClient.coffee b/services/track-changes/test/acceptance/coffee/helpers/TrackChangesClient.coffee index 6c65941570..71efab30b8 100644 --- a/services/track-changes/test/acceptance/coffee/helpers/TrackChangesClient.coffee +++ b/services/track-changes/test/acceptance/coffee/helpers/TrackChangesClient.coffee @@ -3,9 +3,9 @@ rclient = require("redis").createClient() # Only works locally for now {db, ObjectId} = require "../../../../app/js/mongojs" module.exports = TrackChangesClient = - flushAndGetCompressedUpdates: (doc_id, callback = (error, updates) ->) -> + flushAndGetCompressedUpdates: (project_id, doc_id, callback = (error, updates) ->) -> request.post { - url: "http://localhost:3015/doc/#{doc_id}/flush" + url: "http://localhost:3015/project/#{project_id}/doc/#{doc_id}/flush" }, (error, response, body) => response.statusCode.should.equal 204 db.docHistory