mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-27 11:32:42 +00:00
improve doc manager so it calls get doc recursivly
This commit is contained in:
parent
6ea284b17b
commit
ef4e437c3f
2 changed files with 18 additions and 11 deletions
|
@ -22,7 +22,7 @@ module.exports = DocManager =
|
||||||
if err?
|
if err?
|
||||||
logger.err err:err, project_id:project_id, doc_id:doc_id, "error unarchiving doc"
|
logger.err err:err, project_id:project_id, doc_id:doc_id, "error unarchiving doc"
|
||||||
return callback(err)
|
return callback(err)
|
||||||
MongoManager.findDoc doc_id, callback
|
DocManager.getDoc project_id, doc_id, callback
|
||||||
else
|
else
|
||||||
callback err, doc
|
callback err, doc
|
||||||
|
|
||||||
|
|
|
@ -45,21 +45,28 @@ describe "DocManager", ->
|
||||||
done()
|
done()
|
||||||
|
|
||||||
describe "when the doc is deleted", ->
|
describe "when the doc is deleted", ->
|
||||||
|
beforeEach ->
|
||||||
|
@doc = { _id: @doc_id, lines: ["mock-lines"] }
|
||||||
|
@s3doc = { _id: @doc_id, inS3: true }
|
||||||
|
@MongoManager.findDoc = sinon.stub()
|
||||||
|
@MongoManager.findDoc.callsArgWith(1, null, @s3doc)
|
||||||
|
@MongoManager.findDoc.callsArgWith(1, null, @doc)
|
||||||
|
spy = sinon.spy @DocManager.getDoc
|
||||||
|
@DocArchiveManager.unarchiveDoc = sinon.stub().callsArgWith(2)
|
||||||
|
@DocManager.getDoc @project_id, @doc_id, @callback
|
||||||
|
|
||||||
|
it "should call the DocArchive to unarchive the doc", ->
|
||||||
|
@DocArchiveManager.unarchiveDoc.calledWith(@project_id, @doc_id).should.equal true
|
||||||
|
|
||||||
|
it "should return the doc", ->
|
||||||
|
@callback.calledWith(null, @doc).should.equal true
|
||||||
|
|
||||||
|
describe "when the doc is in s3", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@MongoManager.findDoc = sinon.stub().callsArgWith(1, null, @doc)
|
@MongoManager.findDoc = sinon.stub().callsArgWith(1, null, @doc)
|
||||||
|
|
||||||
@DocManager.getDoc @project_id, @doc_id, @callback
|
@DocManager.getDoc @project_id, @doc_id, @callback
|
||||||
|
|
||||||
it "should try to find the doc in the docs collection", ->
|
|
||||||
@MongoManager.findDoc
|
|
||||||
.calledWith(@doc_id)
|
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
it "should return the doc", ->
|
|
||||||
@callback
|
|
||||||
.calledWith(null, @doc)
|
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
describe "when the doc does not exist anywhere", ->
|
describe "when the doc does not exist anywhere", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@MongoManager.findDoc = sinon.stub().callsArgWith(1, null, null)
|
@MongoManager.findDoc = sinon.stub().callsArgWith(1, null, null)
|
||||||
|
|
Loading…
Reference in a new issue