mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2378 from overleaf/bg-return-history-display-type-to-docupdater
return history display type to docupdater GitOrigin-RevId: bc90317677937c4f0698c2045958b79820ec3b3f
This commit is contained in:
parent
78f6148ca1
commit
fb0f8ec65f
2 changed files with 20 additions and 10 deletions
|
@ -17,6 +17,7 @@ const ProjectLocator = require('../Project/ProjectLocator')
|
|||
const ProjectEntityHandler = require('../Project/ProjectEntityHandler')
|
||||
const ProjectEntityUpdateHandler = require('../Project/ProjectEntityUpdateHandler')
|
||||
const logger = require('logger-sharelatex')
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = {
|
||||
getDocument(req, res, next) {
|
||||
|
@ -69,19 +70,20 @@ module.exports = {
|
|||
res.type('text/plain')
|
||||
return res.send(lines.join('\n'))
|
||||
} else {
|
||||
const projectHistoryId = __guard__(
|
||||
__guard__(
|
||||
project != null ? project.overleaf : undefined,
|
||||
x2 => x2.history
|
||||
),
|
||||
x1 => x1.id
|
||||
const projectHistoryId = _.get(project, 'overleaf.history.id')
|
||||
const projectHistoryType = _.get(
|
||||
project,
|
||||
'overleaf.history.display'
|
||||
)
|
||||
? 'project-history'
|
||||
: undefined // for backwards compatibility, don't send anything if the project is still on track-changes
|
||||
return res.json({
|
||||
lines,
|
||||
version,
|
||||
ranges,
|
||||
pathname: path.fileSystem,
|
||||
projectHistoryId
|
||||
projectHistoryId,
|
||||
projectHistoryType
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -153,9 +153,16 @@ describe('DocumentController', function() {
|
|||
beforeEach(function() {
|
||||
this.doc = { _id: this.doc_id }
|
||||
this.projectHistoryId = 1234
|
||||
this.projectHistoryDisplay = true
|
||||
this.projectHistoryType = 'project-history'
|
||||
this.project = {
|
||||
_id: this.project_id,
|
||||
overleaf: { history: { id: this.projectHistoryId } }
|
||||
overleaf: {
|
||||
history: {
|
||||
id: this.projectHistoryId,
|
||||
display: this.projectHistoryDisplay
|
||||
}
|
||||
}
|
||||
}
|
||||
this.ProjectGetter.getProject = sinon
|
||||
.stub()
|
||||
|
@ -180,7 +187,7 @@ describe('DocumentController', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should return the history id to the client as JSON', function() {
|
||||
it('should return the history id and display setting to the client as JSON', function() {
|
||||
this.res.type.should.equal('application/json')
|
||||
return this.res.body.should.equal(
|
||||
JSON.stringify({
|
||||
|
@ -188,7 +195,8 @@ describe('DocumentController', function() {
|
|||
version: this.version,
|
||||
ranges: this.ranges,
|
||||
pathname: this.pathname,
|
||||
projectHistoryId: this.projectHistoryId
|
||||
projectHistoryId: this.projectHistoryId,
|
||||
projectHistoryType: this.projectHistoryType
|
||||
})
|
||||
)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue