diff --git a/services/real-time/config/settings.defaults.coffee b/services/real-time/config/settings.defaults.coffee index 6d5e00e658..93a980931e 100644 --- a/services/real-time/config/settings.defaults.coffee +++ b/services/real-time/config/settings.defaults.coffee @@ -5,15 +5,15 @@ settings = port: process.env['REAL_TIME_REDIS_PORT'] or process.env['REDIS_PORT'] or "6379" password: process.env["REAL_TIME_REDIS_PASSWORD"] or process.env["REDIS_PASSWORD"] or "" key_schema: - clientsInProject: ({project_id}) -> "clients_in_project:#{project_id}" - connectedUser: ({project_id, client_id})-> "connected_user:#{project_id}:#{client_id}" + clientsInProject: ({project_id}) -> "clients_in_project:{#{project_id}}" + connectedUser: ({project_id, client_id})-> "connected_user:{#{project_id}}:#{client_id}" documentupdater: host: process.env['DOC_UPDATER_REDIS_HOST'] or process.env['REDIS_HOST'] or "localhost" port: process.env['DOC_UPDATER_REDIS_PORT'] or process.env['REDIS_PORT'] or "6379" password: process.env["DOC_UPDATER_REDIS_PASSWORD"] or process.env["REDIS_PASSWORD"] or "" key_schema: - pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}" + pendingUpdates: ({doc_id}) -> "PendingUpdates:{#{doc_id}}" websessions: host: process.env['WEB_REDIS_HOST'] or process.env['REDIS_HOST'] or "localhost" diff --git a/services/real-time/test/acceptance/coffee/ApplyUpdateTests.coffee b/services/real-time/test/acceptance/coffee/ApplyUpdateTests.coffee index 2509f21108..d9addc990d 100644 --- a/services/real-time/test/acceptance/coffee/ApplyUpdateTests.coffee +++ b/services/real-time/test/acceptance/coffee/ApplyUpdateTests.coffee @@ -10,6 +10,8 @@ settings = require "settings-sharelatex" redis = require "redis-sharelatex" rclient = redis.createClient(settings.redis.websessions) +redisSettings = settings.redis + describe "applyOtUpdate", -> before -> @update = { @@ -48,7 +50,7 @@ describe "applyOtUpdate", -> done() it "should push the update into redis", (done) -> - rclient.lrange "PendingUpdates:#{@doc_id}", 0, -1, (error, [update]) => + rclient.lrange redisSettings.documentupdater.key_schema.pendingUpdates({@doc_id}), 0, -1, (error, [update]) => update = JSON.parse(update) update.op.should.deep.equal @update.op update.meta.should.deep.equal { @@ -61,7 +63,7 @@ describe "applyOtUpdate", -> async.series [ (cb) => rclient.del "pending-updates-list", cb (cb) => rclient.del "DocsWithPendingUpdates", "#{@project_id}:#{@doc_id}", cb - (cb) => rclient.del "PendingUpdates:#{@doc_id}", cb + (cb) => rclient.del redisSettings.documentupdater.key_schema.pendingUpdates(@doc_id), cb ], done describe "when authorized to read-only with an edit update", -> @@ -102,7 +104,7 @@ describe "applyOtUpdate", -> , 300 it "should not put the update in redis", (done) -> - rclient.llen "PendingUpdates:#{@doc_id}", (error, len) => + rclient.llen redisSettings.documentupdater.key_schema.pendingUpdates({@doc_id}), (error, len) => len.should.equal 0 done() @@ -142,7 +144,7 @@ describe "applyOtUpdate", -> done() it "should push the update into redis", (done) -> - rclient.lrange "PendingUpdates:#{@doc_id}", 0, -1, (error, [update]) => + rclient.lrange redisSettings.documentupdater.key_schema.pendingUpdates({@doc_id}), 0, -1, (error, [update]) => update = JSON.parse(update) update.op.should.deep.equal @comment_update.op update.meta.should.deep.equal { @@ -155,5 +157,5 @@ describe "applyOtUpdate", -> async.series [ (cb) => rclient.del "pending-updates-list", cb (cb) => rclient.del "DocsWithPendingUpdates", "#{@project_id}:#{@doc_id}", cb - (cb) => rclient.del "PendingUpdates:#{@doc_id}", cb + (cb) => rclient.del redisSettings.documentupdater.key_schema.pendingUpdates({@doc_id}), cb ], done \ No newline at end of file