mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
remove code left over from migration
This commit is contained in:
parent
e156d8017c
commit
ab527c3c5d
4 changed files with 14 additions and 26 deletions
|
@ -84,8 +84,4 @@ module.exports = DocManager =
|
|||
DocManager.getDoc project_id, doc_id, { version: false }, (error, doc) ->
|
||||
return callback(error) if error?
|
||||
return callback new Errors.NotFoundError("No such project/doc to delete: #{project_id}/#{doc_id}") if !doc?
|
||||
MongoManager.upsertIntoDocCollection project_id, doc_id, doc.lines, (error) ->
|
||||
return callback(error) if error?
|
||||
MongoManager.markDocAsDeleted doc_id, (error) ->
|
||||
return callback(error) if error?
|
||||
callback()
|
||||
MongoManager.markDocAsDeleted project_id, doc_id, callback
|
||||
|
|
|
@ -27,12 +27,13 @@ module.exports = MongoManager =
|
|||
db.docs.update _id: ObjectId(doc_id), update, {upsert: true}, callback
|
||||
|
||||
|
||||
markDocAsDeleted: (doc_id, callback)->
|
||||
update =
|
||||
$set: {}
|
||||
update.$set["deleted"] = true
|
||||
db.docs.update _id: ObjectId(doc_id), update, (err)->
|
||||
callback(err)
|
||||
markDocAsDeleted: (project_id, doc_id, callback)->
|
||||
db.docs.update {
|
||||
_id: ObjectId(doc_id),
|
||||
project_id: ObjectId(project_id)
|
||||
}, {
|
||||
$set: { deleted: true }
|
||||
}, callback
|
||||
|
||||
markDocAsArchived: (doc_id, rev, callback)->
|
||||
update =
|
||||
|
|
|
@ -129,8 +129,7 @@ describe "DocManager", ->
|
|||
@lines = ["mock", "doc", "lines"]
|
||||
@rev = 77
|
||||
@DocManager.getDoc = sinon.stub().callsArgWith(3, null, {lines: @lines, rev:@rev})
|
||||
@MongoManager.upsertIntoDocCollection = sinon.stub().callsArg(3)
|
||||
@MongoManager.markDocAsDeleted = sinon.stub().callsArg(1)
|
||||
@MongoManager.markDocAsDeleted = sinon.stub().callsArg(2)
|
||||
@DocManager.deleteDoc @project_id, @doc_id, @callback
|
||||
|
||||
it "should get the doc", ->
|
||||
|
@ -138,14 +137,9 @@ describe "DocManager", ->
|
|||
.calledWith(@project_id, @doc_id)
|
||||
.should.equal true
|
||||
|
||||
it "should update the doc lines", ->
|
||||
@MongoManager.upsertIntoDocCollection
|
||||
.calledWith(@project_id, @doc_id, @lines)
|
||||
.should.equal true
|
||||
|
||||
it "should mark doc as deleted", ->
|
||||
@MongoManager.markDocAsDeleted
|
||||
.calledWith(@doc_id)
|
||||
.calledWith(@project_id, @doc_id)
|
||||
.should.equal true
|
||||
|
||||
it "should return the callback", ->
|
||||
|
@ -154,11 +148,8 @@ describe "DocManager", ->
|
|||
describe "when the doc does not exist", ->
|
||||
beforeEach ->
|
||||
@DocManager.getDoc = sinon.stub().callsArgWith(3, null, null)
|
||||
@MongoManager.upsertIntoDocCollection = sinon.stub()
|
||||
@DocManager.deleteDoc @project_id, @doc_id, @callback
|
||||
|
||||
it "should not try to insert a deleted doc", ->
|
||||
@MongoManager.upsertIntoDocCollection.called.should.equal false
|
||||
|
||||
it "should return a NotFoundError", ->
|
||||
@callback
|
||||
|
|
|
@ -76,15 +76,15 @@ describe "MongoManager", ->
|
|||
@db.docs.update = sinon.stub().callsArgWith(2, @stubbedErr)
|
||||
@oldRev = 77
|
||||
|
||||
it "should process the update", (done)->
|
||||
@MongoManager.markDocAsDeleted @doc_id, (err)=>
|
||||
it "should process the update", (done) ->
|
||||
@MongoManager.markDocAsDeleted @project_id, @doc_id, (err)=>
|
||||
args = @db.docs.update.args[0]
|
||||
assert.deepEqual args[0], {_id: ObjectId(@doc_id)}
|
||||
assert.deepEqual args[0], {_id: ObjectId(@doc_id), project_id: ObjectId(@project_id)}
|
||||
assert.equal args[1]["$set"]["deleted"], true
|
||||
done()
|
||||
|
||||
it "should return the error", (done)->
|
||||
@MongoManager.markDocAsDeleted @doc_id, (err)=>
|
||||
@MongoManager.markDocAsDeleted @project_id, @doc_id, (err)=>
|
||||
err.should.equal @stubbedErr
|
||||
done()
|
||||
|
||||
|
|
Loading…
Reference in a new issue