|
@@ -71,23 +71,45 @@ describe "WebRedisManager", ->
|
|
|
@callback.calledWith(null, @length).should.equal true
|
|
@callback.calledWith(null, @length).should.equal true
|
|
|
|
|
|
|
|
describe "pushUncompressedHistoryOps", ->
|
|
describe "pushUncompressedHistoryOps", ->
|
|
|
- beforeEach (done) ->
|
|
|
|
|
|
|
+ beforeEach ->
|
|
|
@ops = [{ op: [{ i: "foo", p: 4 }] },{ op: [{ i: "bar", p: 56 }] }]
|
|
@ops = [{ op: [{ i: "foo", p: 4 }] },{ op: [{ i: "bar", p: 56 }] }]
|
|
|
@rclient.rpush = sinon.stub().yields(null, @length = 42)
|
|
@rclient.rpush = sinon.stub().yields(null, @length = 42)
|
|
|
@rclient.sadd = sinon.stub().yields()
|
|
@rclient.sadd = sinon.stub().yields()
|
|
|
- @WebRedisManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, (args...) =>
|
|
|
|
|
- @callback(args...)
|
|
|
|
|
- done()
|
|
|
|
|
|
|
|
|
|
- it "should push the doc op into the doc ops list as JSON", ->
|
|
|
|
|
- @rclient.rpush
|
|
|
|
|
- .calledWith("UncompressedHistoryOps:#{@doc_id}", JSON.stringify(@ops[0]), JSON.stringify(@ops[1]))
|
|
|
|
|
- .should.equal true
|
|
|
|
|
|
|
+ describe "with ops", ->
|
|
|
|
|
+ beforeEach (done) ->
|
|
|
|
|
+ @WebRedisManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, (args...) =>
|
|
|
|
|
+ @callback(args...)
|
|
|
|
|
+ done()
|
|
|
|
|
+
|
|
|
|
|
+ it "should push the doc op into the doc ops list as JSON", ->
|
|
|
|
|
+ @rclient.rpush
|
|
|
|
|
+ .calledWith("UncompressedHistoryOps:#{@doc_id}", JSON.stringify(@ops[0]), JSON.stringify(@ops[1]))
|
|
|
|
|
+ .should.equal true
|
|
|
|
|
|
|
|
- it "should add the doc_id to the set of which records the project docs", ->
|
|
|
|
|
- @rclient.sadd
|
|
|
|
|
- .calledWith("DocsWithHistoryOps:#{@project_id}", @doc_id)
|
|
|
|
|
- .should.equal true
|
|
|
|
|
|
|
+ it "should add the doc_id to the set of which records the project docs", ->
|
|
|
|
|
+ @rclient.sadd
|
|
|
|
|
+ .calledWith("DocsWithHistoryOps:#{@project_id}", @doc_id)
|
|
|
|
|
+ .should.equal true
|
|
|
|
|
|
|
|
- it "should call the callback with the length", ->
|
|
|
|
|
- @callback.calledWith(null, @length).should.equal true
|
|
|
|
|
|
|
+ it "should call the callback with the length", ->
|
|
|
|
|
+ @callback.calledWith(null, @length).should.equal true
|
|
|
|
|
+
|
|
|
|
|
+ describe "with no ops", ->
|
|
|
|
|
+ beforeEach (done) ->
|
|
|
|
|
+ @WebRedisManager.pushUncompressedHistoryOps @project_id, @doc_id, [], (args...) =>
|
|
|
|
|
+ @callback(args...)
|
|
|
|
|
+ done()
|
|
|
|
|
+
|
|
|
|
|
+ it "should not push the doc op into the doc ops list as JSON", ->
|
|
|
|
|
+ @rclient.rpush
|
|
|
|
|
+ .called
|
|
|
|
|
+ .should.equal false
|
|
|
|
|
+
|
|
|
|
|
+ it "should not add the doc_id to the set of which records the project docs", ->
|
|
|
|
|
+ @rclient.sadd
|
|
|
|
|
+ .called
|
|
|
|
|
+ .should.equal false
|
|
|
|
|
+
|
|
|
|
|
+ it "should call the callback with the length", ->
|
|
|
|
|
+ @callback.calledWith(null, 0).should.equal true
|