|
|
@@ -213,11 +213,12 @@ describe 'Flushing documents :', ->
|
|
|
describe "setDocument", ->
|
|
|
beforeEach ->
|
|
|
@callback = sinon.stub()
|
|
|
+ @source = "dropbox"
|
|
|
|
|
|
describe "successfully", ->
|
|
|
beforeEach ->
|
|
|
@request.post = sinon.stub().callsArgWith(1, null, {statusCode: 204}, "")
|
|
|
- @handler.setDocument @project_id, @doc_id, @lines, @callback
|
|
|
+ @handler.setDocument @project_id, @doc_id, @lines, @source, @callback
|
|
|
|
|
|
it 'should set the document in the document updater', ->
|
|
|
url = "#{@settings.apis.documentupdater.url}/project/#{@project_id}/doc/#{@doc_id}"
|
|
|
@@ -226,6 +227,8 @@ describe 'Flushing documents :', ->
|
|
|
url: url
|
|
|
json:
|
|
|
lines: @lines
|
|
|
+ headers:
|
|
|
+ "x-sl-update-source": @source
|
|
|
})
|
|
|
.should.equal true
|
|
|
|
|
|
@@ -235,7 +238,7 @@ describe 'Flushing documents :', ->
|
|
|
describe "when the document updater API returns an error", ->
|
|
|
beforeEach ->
|
|
|
@request.post = sinon.stub().callsArgWith(1, @error = new Error("something went wrong"), null, null)
|
|
|
- @handler.setDocument @project_id, @doc_id, @lines, @callback
|
|
|
+ @handler.setDocument @project_id, @doc_id, @lines, @source, @callback
|
|
|
|
|
|
it "should return an error to the callback", ->
|
|
|
@callback.calledWith(@error).should.equal true
|
|
|
@@ -243,7 +246,7 @@ describe 'Flushing documents :', ->
|
|
|
describe "when the document updater returns a failure error code", ->
|
|
|
beforeEach ->
|
|
|
@request.post = sinon.stub().callsArgWith(1, null, { statusCode: 500 }, "")
|
|
|
- @handler.setDocument @project_id, @doc_id, @lines, @callback
|
|
|
+ @handler.setDocument @project_id, @doc_id, @lines, @source, @callback
|
|
|
|
|
|
it "should return the callback with an error", ->
|
|
|
@callback
|