mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge branch 'master' into ja-track-changes
Conflicts: test/acceptance/coffee/GettingAllDocsTests.coffee
This commit is contained in:
commit
b8a97731e4
3 changed files with 13 additions and 6 deletions
|
@ -7,7 +7,7 @@ module.exports = MongoManager =
|
|||
callback error, docs[0]
|
||||
|
||||
getProjectsDocs: (project_id, callback)->
|
||||
db.docs.find project_id: ObjectId(project_id.toString()), {}, callback
|
||||
db.docs.find {project_id: ObjectId(project_id.toString()), deleted: { $ne: true }}, {}, callback
|
||||
|
||||
getArchivedProjectDocs: (project_id, callback)->
|
||||
query =
|
||||
|
|
|
@ -22,17 +22,23 @@ describe "Getting all docs", ->
|
|||
lines: ["111", "222", "333"]
|
||||
rev: 6
|
||||
}]
|
||||
@deleted_doc = {
|
||||
_id: ObjectId()
|
||||
lines: ["deleted"]
|
||||
rev: 8
|
||||
}
|
||||
version = 42
|
||||
ranges = 42
|
||||
jobs = for doc in @docs
|
||||
do (doc) =>
|
||||
(callback) =>
|
||||
DocstoreClient.createDoc @project_id, doc._id, doc.lines, version, ranges, (err)=>
|
||||
doc.lines[0] = doc.lines[0]+" added"
|
||||
DocstoreClient.updateDoc @project_id, doc._id, doc.lines, version, ranges, callback
|
||||
DocstoreClient.createDoc @project_id, doc._id, doc.lines, version, ranges, callback
|
||||
jobs.push (cb) =>
|
||||
DocstoreClient.createDoc @project_id, @deleted_doc._id, @deleted_doc.lines, version, {}, (err)=>
|
||||
DocstoreClient.deleteDoc @project_id, @deleted_doc._id, cb
|
||||
async.series jobs, done
|
||||
|
||||
it "should return all the docs", (done) ->
|
||||
it "should return all the (non-deleted) docs", (done) ->
|
||||
DocstoreClient.getAllDocs @project_id, (error, res, docs) =>
|
||||
throw error if error?
|
||||
docs.length.should.equal @docs.length
|
||||
|
|
|
@ -42,10 +42,11 @@ describe "MongoManager", ->
|
|||
@db.docs.find = sinon.stub().callsArgWith(2, null, [@doc, @doc3, @doc4])
|
||||
@MongoManager.getProjectsDocs @project_id, @callback
|
||||
|
||||
it "should find the docs via the project_id", ->
|
||||
it "should find the non-deleted docs via the project_id", ->
|
||||
@db.docs.find
|
||||
.calledWith({
|
||||
project_id: ObjectId(@project_id)
|
||||
deleted: { $ne: true }
|
||||
}, {})
|
||||
.should.equal true
|
||||
|
||||
|
|
Loading…
Reference in a new issue