mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
moved setPublicAccessLevel to project details handler
This commit is contained in:
parent
d229269a69
commit
fa78db5c59
5 changed files with 22 additions and 11 deletions
|
@ -267,7 +267,7 @@ module.exports = EditorController =
|
|||
callback?()
|
||||
|
||||
setPublicAccessLevel : (project_id, newAccessLevel, callback)->
|
||||
ProjectHandler.setPublicAccessLevel project_id, newAccessLevel, =>
|
||||
ProjectDetailsHandler.setPublicAccessLevel project_id, newAccessLevel, =>
|
||||
EditorRealTimeController.emitToRoom project_id, 'publicAccessLevelUpdated', newAccessLevel
|
||||
callback?()
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ UserGetter = require("../User/UserGetter")
|
|||
Project = require('../../models/Project').Project
|
||||
logger = require("logger-sharelatex")
|
||||
tpdsUpdateSender = require '../ThirdPartyDataStore/TpdsUpdateSender'
|
||||
|
||||
_ = require("underscore")
|
||||
|
||||
module.exports =
|
||||
|
||||
|
@ -42,3 +42,9 @@ module.exports =
|
|||
if err?
|
||||
return callback(err)
|
||||
tpdsUpdateSender.moveEntity {project_id:project_id, project_name:oldProjectName, newProjectName:newName}, callback
|
||||
|
||||
setPublicAccessLevel : (project_id, newAccessLevel, callback = ->)->
|
||||
logger.log project_id: project_id, level: newAccessLevel, "set public access level"
|
||||
if project_id? && newAccessLevel? and _.include ['readOnly', 'readAndWrite', 'private'], newAccessLevel
|
||||
Project.update {_id:project_id},{publicAccesLevel:newAccessLevel}, (err)->
|
||||
callback()
|
|
@ -20,13 +20,7 @@ tagsHandler = require('../Features/Tags/TagsHandler')
|
|||
module.exports = class ProjectHandler
|
||||
|
||||
|
||||
setPublicAccessLevel : (project_id, newAccessLevel, callback)->
|
||||
logger.log project_id: project_id, level: newAccessLevel, "set public access level"
|
||||
if project_id? && newAccessLevel?
|
||||
if _.include ['readOnly', 'readAndWrite', 'private'], newAccessLevel
|
||||
Project.update {_id:project_id},{publicAccesLevel:newAccessLevel},{}, (err)->
|
||||
if callback?
|
||||
callback()
|
||||
|
||||
|
||||
addUserToProject: (project_id, email, privlages, callback)->
|
||||
if email != ''
|
||||
|
|
|
@ -690,12 +690,12 @@ describe "EditorController", ->
|
|||
beforeEach ->
|
||||
@err = "errro"
|
||||
@newAccessLevel = "public"
|
||||
@ProjectHandler::setPublicAccessLevel = sinon.stub().callsArgWith(2, @err)
|
||||
@ProjectDetailsHandler.setPublicAccessLevel = sinon.stub().callsArgWith(2, @err)
|
||||
@EditorRealTimeController.emitToRoom = sinon.stub()
|
||||
|
||||
it "should call the ProjectHandler", (done)->
|
||||
@EditorController.setPublicAccessLevel @project_id, @newAccessLevel, =>
|
||||
@ProjectHandler::setPublicAccessLevel.calledWith(@project_id, @newAccessLevel).should.equal true
|
||||
@ProjectDetailsHandler.setPublicAccessLevel.calledWith(@project_id, @newAccessLevel).should.equal true
|
||||
done()
|
||||
|
||||
it "should emit the update to the room", (done)->
|
||||
|
|
|
@ -81,3 +81,14 @@ describe 'Project details handler', ->
|
|||
@tpdsUpdateSender.moveEntity.calledWith({project_id:@project_id, project_name:@project.name, newProjectName:@newName}).should.equal true
|
||||
done()
|
||||
|
||||
|
||||
describe "setPublicAccessLevel", ->
|
||||
beforeEach ->
|
||||
@ProjectModel.update.callsArgWith(2)
|
||||
@accessLevel = "readOnly"
|
||||
|
||||
it "should update the project with the new level", (done)->
|
||||
@handler.setPublicAccessLevel @project_id, @accessLevel, =>
|
||||
@ProjectModel.update.calledWith({_id: @project_id}, {publicAccesLevel: @accessLevel}).should.equal true
|
||||
done()
|
||||
|
||||
|
|
Loading…
Reference in a new issue