Merge branch 'master' into ja-track-changes

Conflicts:
	test/acceptance/coffee/GettingAllDocsTests.coffee
This commit is contained in:
James Allen 2016-12-05 14:58:57 +00:00
commit b8a97731e4
3 changed files with 13 additions and 6 deletions

View file

@ -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 =

View file

@ -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

View file

@ -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