Merge pull request #249 from sharelatex/ja-enable-history-display-on-create

Enable project history for new projects if enabled in settings
This commit is contained in:
James Allen 2018-01-04 15:21:19 +00:00 committed by GitHub
commit e2f27becac
3 changed files with 19 additions and 1 deletions

View file

@ -37,6 +37,8 @@ module.exports = ProjectCreationHandler =
owner_ref : new ObjectId(owner_id)
name : projectName
project.overleaf.history.id = projectHistoryId
if Settings.apis?.project_history?.displayHistoryForNewProjects
project.overleaf.history.display = true
if Settings.currentImageName?
project.imageName = Settings.currentImageName
project.rootFolder[0] = rootFolder

View file

@ -113,6 +113,7 @@ module.exports = settings =
project_history:
sendProjectStructureOps: process.env.PROJECT_HISTORY_ENABLED == 'true' or false
initializeHistoryForNewProjects: process.env.PROJECT_HISTORY_ENABLED == 'true' or false
displayHistoryForNewProjects: process.env.PROJECT_HISTORY_ENABLED == 'true' or false
url : "http://localhost:3054"
docstore:
url : "http://#{process.env['DOCSTORE_HOST'] or 'localhost'}:3016"

View file

@ -49,6 +49,9 @@ describe 'ProjectCreationHandler', ->
@User = findById:sinon.stub().callsArgWith(2, null, @user)
@callback = sinon.stub()
@Settings = apis: { project_history: {} }
@handler = SandboxedModule.require modulePath, requires:
'../../models/User': User:@User
'../../models/Project':{Project:@ProjectModel}
@ -56,7 +59,7 @@ describe 'ProjectCreationHandler', ->
'../History/HistoryManager': @HistoryManager
'./ProjectEntityHandler':@ProjectEntityHandler
"./ProjectDetailsHandler":@ProjectDetailsHandler
"settings-sharelatex": @Settings = {}
"settings-sharelatex": @Settings
'logger-sharelatex': {log:->}
"metrics-sharelatex": {
inc: ()->,
@ -113,6 +116,18 @@ describe 'ProjectCreationHandler', ->
expect(project.imageName).to.not.exist
done()
it "should not set the overleaf.history.display if not configured in settings", (done) ->
@Settings.apis.project_history.displayHistoryForNewProjects = false
@handler.createBlankProject ownerId, projectName, (err, project)=>
expect(project.overleaf.history.display).to.not.exist
done()
it "should set the overleaf.history.display if configured in settings", (done) ->
@Settings.apis.project_history.displayHistoryForNewProjects = true
@handler.createBlankProject ownerId, projectName, (err, project)=>
expect(project.overleaf.history.display).to.equal true
done()
describe "with an error", ->
beforeEach ->
@ProjectModel::save = sinon.stub().callsArgWith(0, new Error("something went wrong"))