Merge pull request #17 from sharelatex/ho-always-check-s3

Always get inS3 when getting doc
This commit is contained in:
Henry Oswald 2017-03-10 10:36:59 +00:00 committed by GitHub
commit c2b96c7e1e
3 changed files with 31 additions and 3 deletions

View file

@ -10,7 +10,9 @@ module.exports = DocManager =
# collection (which is all that this collection contains). In future, we should
# migrate this version property to be part of the docs collection, to guarantee
# consitency between lines and version when writing/reading, and for a simpler schema.
getDoc: (project_id, doc_id, filter = { version: false }, callback = (error, doc) ->) ->
getDoc: (project_id, doc_id, filter = { version: false, inS3:true}, callback = (error, doc) ->) ->
if filter? and !filter.inS3?
filter.inS3 = true
MongoManager.findDoc project_id, doc_id, filter, (err, doc)->
if err?
return callback(err)

File diff suppressed because one or more lines are too long

View file

@ -34,6 +34,20 @@ describe "DocManager", ->
@MongoManager.findDoc = sinon.stub()
@MongoManager.getDocVersion = sinon.stub().yields(null, @version)
describe "when using a filter", ->
beforeEach ->
@MongoManager.findDoc.yields(null, @doc)
it "should always get inS3 even when filter is passed", (done)->
@DocManager.getDoc @project_id, @doc_id, {version: true}, =>
@MongoManager.findDoc.args[0][2].inS3.should.equal true
done()
it "should always get inS3 even when no filter is passed", (done)->
@DocManager.getDoc @project_id, @doc_id, undefined, =>
@MongoManager.findDoc.args[0][2].inS3.should.equal true
done()
describe "when the doc is in the doc collection", ->
beforeEach ->
@MongoManager.findDoc.yields(null, @doc)