|
|
@@ -319,17 +319,18 @@ describe "DocumentManager", ->
|
|
|
describe "acceptChanges", ->
|
|
|
beforeEach ->
|
|
|
@change_id = "mock-change-id"
|
|
|
+ @change_ids = [ "mock-change-id-1", "mock-change-id-2", "mock-change-id-3", "mock-change-id-4" ]
|
|
|
@version = 34
|
|
|
@lines = ["original", "lines"]
|
|
|
@ranges = { entries: "mock", comments: "mock" }
|
|
|
@updated_ranges = { entries: "updated", comments: "updated" }
|
|
|
@DocumentManager.getDoc = sinon.stub().yields(null, @lines, @version, @ranges)
|
|
|
- @RangesManager.acceptChange = sinon.stub().yields(null, @updated_ranges)
|
|
|
+ @RangesManager.acceptChanges = sinon.stub().yields(null, @updated_ranges)
|
|
|
@RedisManager.updateDocument = sinon.stub().yields()
|
|
|
|
|
|
- describe "successfully", ->
|
|
|
+ describe "successfully with a single change", ->
|
|
|
beforeEach ->
|
|
|
- @DocumentManager.acceptChange @project_id, @doc_id, @change_id, @callback
|
|
|
+ @DocumentManager.acceptChanges @project_id, @doc_id, [ @change_id ], @callback
|
|
|
|
|
|
it "should get the document's current ranges", ->
|
|
|
@DocumentManager.getDoc
|
|
|
@@ -337,8 +338,8 @@ describe "DocumentManager", ->
|
|
|
.should.equal true
|
|
|
|
|
|
it "should apply the accept change to the ranges", ->
|
|
|
- @RangesManager.acceptChange
|
|
|
- .calledWith(@change_id, @ranges)
|
|
|
+ @RangesManager.acceptChanges
|
|
|
+ .calledWith([ @change_id ], @ranges)
|
|
|
.should.equal true
|
|
|
|
|
|
it "should save the updated ranges", ->
|
|
|
@@ -349,10 +350,19 @@ describe "DocumentManager", ->
|
|
|
it "should call the callback", ->
|
|
|
@callback.called.should.equal true
|
|
|
|
|
|
+ describe "successfully with multiple changes", ->
|
|
|
+ beforeEach ->
|
|
|
+ @DocumentManager.acceptChanges @project_id, @doc_id, @change_ids, @callback
|
|
|
+
|
|
|
+ it "should apply the accept change to the ranges", ->
|
|
|
+ @RangesManager.acceptChanges
|
|
|
+ .calledWith(@change_ids, @ranges)
|
|
|
+ .should.equal true
|
|
|
+
|
|
|
describe "when the doc is not found", ->
|
|
|
beforeEach ->
|
|
|
@DocumentManager.getDoc = sinon.stub().yields(null, null, null, null)
|
|
|
- @DocumentManager.acceptChange @project_id, @doc_id, @change_id, @callback
|
|
|
+ @DocumentManager.acceptChanges @project_id, @doc_id, [ @change_id ], @callback
|
|
|
|
|
|
it "should not save anything", ->
|
|
|
@RedisManager.updateDocument.called.should.equal false
|
|
|
@@ -397,7 +407,7 @@ describe "DocumentManager", ->
|
|
|
describe "when the doc is not found", ->
|
|
|
beforeEach ->
|
|
|
@DocumentManager.getDoc = sinon.stub().yields(null, null, null, null)
|
|
|
- @DocumentManager.acceptChange @project_id, @doc_id, @comment_id, @callback
|
|
|
+ @DocumentManager.acceptChanges @project_id, @doc_id, [ @comment_id ], @callback
|
|
|
|
|
|
it "should not save anything", ->
|
|
|
@RedisManager.updateDocument.called.should.equal false
|