|
@@ -22,6 +22,7 @@ describe "HttpController", ->
|
|
|
@next = sinon.stub()
|
|
@next = sinon.stub()
|
|
|
@res =
|
|
@res =
|
|
|
send: sinon.stub()
|
|
send: sinon.stub()
|
|
|
|
|
+ json: sinon.stub()
|
|
|
|
|
|
|
|
describe "getDoc", ->
|
|
describe "getDoc", ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
@@ -47,15 +48,15 @@ describe "HttpController", ->
|
|
|
.should.equal true
|
|
.should.equal true
|
|
|
|
|
|
|
|
it "should return the doc as JSON", ->
|
|
it "should return the doc as JSON", ->
|
|
|
- @res.send
|
|
|
|
|
- .calledWith(JSON.stringify({
|
|
|
|
|
|
|
+ @res.json
|
|
|
|
|
+ .calledWith({
|
|
|
id: @doc_id
|
|
id: @doc_id
|
|
|
lines: @lines
|
|
lines: @lines
|
|
|
version: @version
|
|
version: @version
|
|
|
ops: []
|
|
ops: []
|
|
|
ranges: @ranges
|
|
ranges: @ranges
|
|
|
pathname: @pathname
|
|
pathname: @pathname
|
|
|
- }))
|
|
|
|
|
|
|
+ })
|
|
|
.should.equal true
|
|
.should.equal true
|
|
|
|
|
|
|
|
it "should log the request", ->
|
|
it "should log the request", ->
|
|
@@ -68,7 +69,7 @@ describe "HttpController", ->
|
|
|
|
|
|
|
|
describe "when recent ops are requested", ->
|
|
describe "when recent ops are requested", ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
- @DocumentManager.getDocAndRecentOpsWithLock = sinon.stub().callsArgWith(3, null, @lines, @version, @ops)
|
|
|
|
|
|
|
+ @DocumentManager.getDocAndRecentOpsWithLock = sinon.stub().callsArgWith(3, null, @lines, @version, @ops, @ranges, @pathname)
|
|
|
@req.query = fromVersion: "#{@fromVersion}"
|
|
@req.query = fromVersion: "#{@fromVersion}"
|
|
|
@HttpController.getDoc(@req, @res, @next)
|
|
@HttpController.getDoc(@req, @res, @next)
|
|
|
|
|
|
|
@@ -78,13 +79,15 @@ describe "HttpController", ->
|
|
|
.should.equal true
|
|
.should.equal true
|
|
|
|
|
|
|
|
it "should return the doc as JSON", ->
|
|
it "should return the doc as JSON", ->
|
|
|
- @res.send
|
|
|
|
|
- .calledWith(JSON.stringify({
|
|
|
|
|
|
|
+ @res.json
|
|
|
|
|
+ .calledWith({
|
|
|
id: @doc_id
|
|
id: @doc_id
|
|
|
lines: @lines
|
|
lines: @lines
|
|
|
version: @version
|
|
version: @version
|
|
|
ops: @ops
|
|
ops: @ops
|
|
|
- }))
|
|
|
|
|
|
|
+ ranges: @ranges
|
|
|
|
|
+ pathname: @pathname
|
|
|
|
|
+ })
|
|
|
.should.equal true
|
|
.should.equal true
|
|
|
|
|
|
|
|
it "should log the request", ->
|
|
it "should log the request", ->
|