Merge pull request #244 from sharelatex/hof-lock-file-upload

Project Locking: ProjectUploadController
This commit is contained in:
James Allen
2018-01-11 08:42:36 +00:00
committed by GitHub
3 changed files with 33 additions and 15 deletions
@@ -17,12 +17,16 @@ describe "ProjectUploadController", ->
done: sinon.stub()
@AuthenticationController =
getLoggedInUserId: sinon.stub().returns(@user_id)
@LockManager =
runWithLock : sinon.spy((key, runner, callback) -> runner(callback))
@ProjectUploadController = SandboxedModule.require modulePath, requires:
"./ProjectUploadManager" : @ProjectUploadManager = {}
"./FileSystemImportManager" : @FileSystemImportManager = {}
"logger-sharelatex" : @logger = {log: sinon.stub(), error: sinon.stub(), err:->}
"metrics-sharelatex": @metrics
'../Authentication/AuthenticationController': @AuthenticationController
"../../infrastructure/LockManager": @LockManager
"fs" : @fs = {}
describe "uploadProject", ->
@@ -125,6 +129,9 @@ describe "ProjectUploadController", ->
@FileSystemImportManager.addEntity = sinon.stub().callsArgWith(6, null, @entity)
@ProjectUploadController.uploadFile @req, @res
it "should take the lock", ->
@LockManager.runWithLock.calledWith(@project_id).should.equal true
it "should insert the file", ->
@FileSystemImportManager.addEntity
.calledWith(@user_id, @project_id, @folder_id, @name, @path)