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"
|
Settings = require "settings-sharelatex"
|
||||||
mongojs = require "mongojs"
|
mongojs = require "mongojs"
|
||||||
db = mongojs.connect(Settings.mongo.url, ["docs", "docOps"])
|
db = mongojs(Settings.mongo.url, ["docs", "docOps"])
|
||||||
module.exports =
|
module.exports =
|
||||||
db: db
|
db: db
|
||||||
ObjectId: mongojs.ObjectId
|
ObjectId: mongojs.ObjectId
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0",
|
"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",
|
"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",
|
"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",
|
"express": "~4.1.1",
|
||||||
"underscore": "~1.6.0",
|
"underscore": "~1.6.0",
|
||||||
"body-parser": "~1.0.2",
|
"body-parser": "~1.0.2",
|
||||||
|
|
|
@ -26,12 +26,10 @@ describe "MongoManager", ->
|
||||||
@MongoManager.findDoc @project_id, @doc_id, @filter, @callback
|
@MongoManager.findDoc @project_id, @doc_id, @filter, @callback
|
||||||
|
|
||||||
it "should find the doc", ->
|
it "should find the doc", ->
|
||||||
@db.docs.find
|
@db.docs.find.lastCall.args.slice(0,2).should.deep.equal([
|
||||||
.calledWith({
|
{_id: ObjectId(@doc_id), project_id: ObjectId(@project_id)},
|
||||||
_id: ObjectId(@doc_id)
|
@filter
|
||||||
project_id: ObjectId(@project_id)
|
])
|
||||||
}, @filter)
|
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
it "should call the callback with the doc", ->
|
it "should call the callback with the doc", ->
|
||||||
@callback.calledWith(null, @doc).should.equal true
|
@callback.calledWith(null, @doc).should.equal true
|
||||||
|
@ -50,12 +48,9 @@ describe "MongoManager", ->
|
||||||
@MongoManager.getProjectsDocs @project_id, include_deleted: false, @filter, @callback
|
@MongoManager.getProjectsDocs @project_id, include_deleted: false, @filter, @callback
|
||||||
|
|
||||||
it "should find the non-deleted docs via the project_id", ->
|
it "should find the non-deleted docs via the project_id", ->
|
||||||
@db.docs.find
|
@db.docs.find.lastCall.args.slice(0,1).should.deep.equal([
|
||||||
.calledWith({
|
{project_id: ObjectId(@project_id), deleted: {$ne: true}}
|
||||||
project_id: ObjectId(@project_id)
|
])
|
||||||
deleted: { $ne: true }
|
|
||||||
}, @filter)
|
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
it "should call the callback with the docs", ->
|
it "should call the callback with the docs", ->
|
||||||
@callback.calledWith(null, [@doc, @doc3, @doc4]).should.equal true
|
@callback.calledWith(null, [@doc, @doc3, @doc4]).should.equal true
|
||||||
|
@ -65,11 +60,10 @@ describe "MongoManager", ->
|
||||||
@MongoManager.getProjectsDocs @project_id, include_deleted: true, @filter, @callback
|
@MongoManager.getProjectsDocs @project_id, include_deleted: true, @filter, @callback
|
||||||
|
|
||||||
it "should find all via the project_id", ->
|
it "should find all via the project_id", ->
|
||||||
@db.docs.find
|
@db.docs.find.lastCall.args.slice(0,2).should.deep.equal([
|
||||||
.calledWith({
|
{project_id: ObjectId(@project_id)},
|
||||||
project_id: ObjectId(@project_id)
|
@filter
|
||||||
}, @filter)
|
])
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
it "should call the callback with the docs", ->
|
it "should call the callback with the docs", ->
|
||||||
@callback.calledWith(null, [@doc, @doc3, @doc4]).should.equal true
|
@callback.calledWith(null, [@doc, @doc3, @doc4]).should.equal true
|
||||||
|
@ -119,9 +113,10 @@ describe "MongoManager", ->
|
||||||
@MongoManager.getDocVersion @doc_id, @callback
|
@MongoManager.getDocVersion @doc_id, @callback
|
||||||
|
|
||||||
it "should look for the doc in the database", ->
|
it "should look for the doc in the database", ->
|
||||||
@db.docOps.find
|
@db.docOps.find.lastCall.args.slice(0,2).should.deep.equal([
|
||||||
.calledWith({ doc_id: ObjectId(@doc_id) }, {version: 1})
|
{ doc_id: ObjectId(@doc_id) },
|
||||||
.should.equal true
|
{version: 1}
|
||||||
|
])
|
||||||
|
|
||||||
it "should call the callback with the version", ->
|
it "should call the callback with the version", ->
|
||||||
@callback.calledWith(null, @version).should.equal true
|
@callback.calledWith(null, @version).should.equal true
|
||||||
|
@ -141,16 +136,11 @@ describe "MongoManager", ->
|
||||||
@MongoManager.setDocVersion @doc_id, @version, @callback
|
@MongoManager.setDocVersion @doc_id, @version, @callback
|
||||||
|
|
||||||
it "should update the doc version", ->
|
it "should update the doc version", ->
|
||||||
@db.docOps.update
|
@db.docOps.update.lastCall.args.slice(0,3).should.deep.equal([
|
||||||
.calledWith({
|
{doc_id: ObjectId(@doc_id)},
|
||||||
doc_id: ObjectId(@doc_id)
|
{$set: {version: @version}},
|
||||||
}, {
|
{upsert: true}
|
||||||
$set:
|
])
|
||||||
version: @version
|
|
||||||
}, {
|
|
||||||
upsert: true
|
|
||||||
})
|
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
it "should call the callback", ->
|
it "should call the callback", ->
|
||||||
@callback.called.should.equal true
|
@callback.called.should.equal true
|
||||||
|
|
Loading…
Reference in a new issue