mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Upgrade mongojs dependency to version 2.4.0
- Upgrade in package.json - Use new connection syntax - Fix unit tests, issues with object equality
This commit is contained in:
parent
d90798008b
commit
1f3b0a3713
3 changed files with 22 additions and 32 deletions
|
@ -1,6 +1,6 @@
|
|||
Settings = require "settings-sharelatex"
|
||||
mongojs = require "mongojs"
|
||||
db = mongojs.connect(Settings.mongo.url, ["docs", "docOps"])
|
||||
db = mongojs(Settings.mongo.url, ["docs", "docOps"])
|
||||
module.exports =
|
||||
db: db
|
||||
ObjectId: mongojs.ObjectId
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0",
|
||||
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.4.0",
|
||||
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.7.1",
|
||||
"mongojs": "0.18.2",
|
||||
"mongojs": "2.4.0",
|
||||
"express": "~4.1.1",
|
||||
"underscore": "~1.6.0",
|
||||
"body-parser": "~1.0.2",
|
||||
|
|
|
@ -26,12 +26,10 @@ describe "MongoManager", ->
|
|||
@MongoManager.findDoc @project_id, @doc_id, @filter, @callback
|
||||
|
||||
it "should find the doc", ->
|
||||
@db.docs.find
|
||||
.calledWith({
|
||||
_id: ObjectId(@doc_id)
|
||||
project_id: ObjectId(@project_id)
|
||||
}, @filter)
|
||||
.should.equal true
|
||||
@db.docs.find.lastCall.args.slice(0,2).should.deep.equal([
|
||||
{_id: ObjectId(@doc_id), project_id: ObjectId(@project_id)},
|
||||
@filter
|
||||
])
|
||||
|
||||
it "should call the callback with the doc", ->
|
||||
@callback.calledWith(null, @doc).should.equal true
|
||||
|
@ -50,12 +48,9 @@ describe "MongoManager", ->
|
|||
@MongoManager.getProjectsDocs @project_id, include_deleted: false, @filter, @callback
|
||||
|
||||
it "should find the non-deleted docs via the project_id", ->
|
||||
@db.docs.find
|
||||
.calledWith({
|
||||
project_id: ObjectId(@project_id)
|
||||
deleted: { $ne: true }
|
||||
}, @filter)
|
||||
.should.equal true
|
||||
@db.docs.find.lastCall.args.slice(0,1).should.deep.equal([
|
||||
{project_id: ObjectId(@project_id), deleted: {$ne: true}}
|
||||
])
|
||||
|
||||
it "should call the callback with the docs", ->
|
||||
@callback.calledWith(null, [@doc, @doc3, @doc4]).should.equal true
|
||||
|
@ -65,11 +60,10 @@ describe "MongoManager", ->
|
|||
@MongoManager.getProjectsDocs @project_id, include_deleted: true, @filter, @callback
|
||||
|
||||
it "should find all via the project_id", ->
|
||||
@db.docs.find
|
||||
.calledWith({
|
||||
project_id: ObjectId(@project_id)
|
||||
}, @filter)
|
||||
.should.equal true
|
||||
@db.docs.find.lastCall.args.slice(0,2).should.deep.equal([
|
||||
{project_id: ObjectId(@project_id)},
|
||||
@filter
|
||||
])
|
||||
|
||||
it "should call the callback with the docs", ->
|
||||
@callback.calledWith(null, [@doc, @doc3, @doc4]).should.equal true
|
||||
|
@ -119,9 +113,10 @@ describe "MongoManager", ->
|
|||
@MongoManager.getDocVersion @doc_id, @callback
|
||||
|
||||
it "should look for the doc in the database", ->
|
||||
@db.docOps.find
|
||||
.calledWith({ doc_id: ObjectId(@doc_id) }, {version: 1})
|
||||
.should.equal true
|
||||
@db.docOps.find.lastCall.args.slice(0,2).should.deep.equal([
|
||||
{ doc_id: ObjectId(@doc_id) },
|
||||
{version: 1}
|
||||
])
|
||||
|
||||
it "should call the callback with the version", ->
|
||||
@callback.calledWith(null, @version).should.equal true
|
||||
|
@ -141,16 +136,11 @@ describe "MongoManager", ->
|
|||
@MongoManager.setDocVersion @doc_id, @version, @callback
|
||||
|
||||
it "should update the doc version", ->
|
||||
@db.docOps.update
|
||||
.calledWith({
|
||||
doc_id: ObjectId(@doc_id)
|
||||
}, {
|
||||
$set:
|
||||
version: @version
|
||||
}, {
|
||||
upsert: true
|
||||
})
|
||||
.should.equal true
|
||||
@db.docOps.update.lastCall.args.slice(0,3).should.deep.equal([
|
||||
{doc_id: ObjectId(@doc_id)},
|
||||
{$set: {version: @version}},
|
||||
{upsert: true}
|
||||
])
|
||||
|
||||
it "should call the callback", ->
|
||||
@callback.called.should.equal true
|
||||
|
|
Loading…
Reference in a new issue