mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #4690 from overleaf/tm-upgraded-history-allow-downgrade
Projects migrated to full project history should send history to both systems if allowDowngrade is set GitOrigin-RevId: 52c46345eb8606e363ae85727d29e87f35cea37d
This commit is contained in:
parent
b2e6eaf936
commit
84559790f2
2 changed files with 66 additions and 3 deletions
|
@ -69,10 +69,19 @@ module.exports = {
|
|||
return res.send(lines.join('\n'))
|
||||
} else {
|
||||
const projectHistoryId = _.get(project, 'overleaf.history.id')
|
||||
const projectHistoryType = _.get(
|
||||
const projectHistoryDisplay = _.get(
|
||||
project,
|
||||
'overleaf.history.display'
|
||||
)
|
||||
const sendToBothHistorySystems = _.get(
|
||||
project,
|
||||
'overleaf.history.allowDowngrade'
|
||||
)
|
||||
// if project has been switched but has 'allowDowngrade' set
|
||||
// then leave projectHistoryType undefined to (temporarily)
|
||||
// continue sending updates to both SL and full project history
|
||||
const projectHistoryType =
|
||||
projectHistoryDisplay && !sendToBothHistorySystems
|
||||
? 'project-history'
|
||||
: undefined // for backwards compatibility, don't send anything if the project is still on track-changes
|
||||
return res.json({
|
||||
|
|
|
@ -191,6 +191,60 @@ describe('DocumentController', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when project exists that was migrated with downgrades allowed', function () {
|
||||
beforeEach(function () {
|
||||
this.doc = { _id: this.doc_id }
|
||||
this.projectHistoryId = 1234
|
||||
this.projectHistoryDisplay = true
|
||||
this.projectHistoryType = undefined
|
||||
this.project = {
|
||||
_id: this.project_id,
|
||||
overleaf: {
|
||||
history: {
|
||||
id: this.projectHistoryId,
|
||||
display: this.projectHistoryDisplay,
|
||||
allowDowngrade: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
this.ProjectGetter.getProject = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, null, this.project)
|
||||
this.ProjectLocator.findElement = sinon
|
||||
.stub()
|
||||
.callsArgWith(1, null, this.doc, { fileSystem: this.pathname })
|
||||
this.ProjectEntityHandler.getDoc = sinon
|
||||
.stub()
|
||||
.callsArgWith(
|
||||
2,
|
||||
null,
|
||||
this.doc_lines,
|
||||
this.rev,
|
||||
this.version,
|
||||
this.ranges
|
||||
)
|
||||
return this.DocumentController.getDocument(
|
||||
this.req,
|
||||
this.res,
|
||||
this.next
|
||||
)
|
||||
})
|
||||
|
||||
it('should return the history id in the JSON but not history type, sending history to both services', function () {
|
||||
this.res.type.should.equal('application/json')
|
||||
return this.res.body.should.equal(
|
||||
JSON.stringify({
|
||||
lines: this.doc_lines,
|
||||
version: this.version,
|
||||
ranges: this.ranges,
|
||||
pathname: this.pathname,
|
||||
projectHistoryId: this.projectHistoryId,
|
||||
projectHistoryType: this.projectHistoryType,
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the project does not exist', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectGetter.getProject = sinon.stub().callsArgWith(2, null, null)
|
||||
|
|
Loading…
Reference in a new issue