Revert "Revert "Revert "clear rootDoc_id when deleting doc, reset on compiles if invalid"""

This reverts commit 034ae6fa4d8515944683395ef14d99801829cb6a.

GitOrigin-RevId: 16801e6f35e1ee879d36ca46e262f8bb6e506a54
This commit is contained in:
Ersun Warncke
2020-02-12 04:20:56 +00:00
committed by Copybot
parent b4cdfc43cf
commit ba253bee12
5 changed files with 21 additions and 83 deletions
@@ -6,7 +6,6 @@ const fs = require('fs')
const Settings = require('settings-sharelatex')
const _ = require('underscore')
const { Project } = require('../../../app/src/models/Project')
const ProjectGetter = require('../../../app/src/Features/Project/ProjectGetter.js')
const MockDocUpdaterApi = require('./helpers/MockDocUpdaterApi')
@@ -1099,68 +1098,6 @@ describe('ProjectStructureChanges', function() {
})
})
describe('deleting docs', function() {
beforeEach(function(done) {
createExampleProject(this, () => {
createExampleFolder(this, () => {
createExampleDoc(this, () => {
MockDocUpdaterApi.clearProjectStructureUpdates()
ProjectGetter.getProject(
this.exampleProjectId,
(error, project) => {
if (error) {
throw error
}
this.project0 = project
done()
})
})
})
})
})
describe('when rootDoc_id matches doc being deleted', () => {
beforeEach(function(done) {
Project.update({_id: this.exampleProjectId}, {$set: {rootDoc_id: this.exampleDocId}}, done)
})
it('should clear rootDoc_id', function(done) {
deleteItem(this, 'doc', this.exampleDocId, () => {
ProjectGetter.getProject(
this.exampleProjectId,
(error, project) => {
if (error) {
throw error
}
expect(project.rootDoc_id).to.be.undefined
done()
})
})
})
})
describe('when rootDoc_id does not match doc being deleted', () => {
beforeEach(function(done) {
this.exampleRootDocId = new ObjectId()
Project.update({_id: this.exampleProjectId}, {$set: {rootDoc_id: this.exampleRootDocId}}, done)
})
it('should not clear rootDoc_id', function(done) {
deleteItem(this, 'doc', this.exampleDocId, () => {
ProjectGetter.getProject(
this.exampleProjectId,
(error, project) => {
if (error) {
throw error
}
expect(project.rootDoc_id.toString()).to.equal(this.exampleRootDocId.toString())
done()
})
})
})
})
})
describe('tpds', function() {
let projectName, exampleProjectId, oldVersion, rootFolderId