|
@@ -18,8 +18,8 @@ describe "ProjectUploadController", ->
|
|
|
@AuthenticationController =
|
|
@AuthenticationController =
|
|
|
getLoggedInUserId: sinon.stub().returns(@user_id)
|
|
getLoggedInUserId: sinon.stub().returns(@user_id)
|
|
|
@LockManager =
|
|
@LockManager =
|
|
|
- getLock : sinon.stub().yields()
|
|
|
|
|
- releaseLock : sinon.stub().yields()
|
|
|
|
|
|
|
+ runWithLock : sinon.spy((key, runner, callback) -> runner(callback))
|
|
|
|
|
+
|
|
|
@ProjectUploadController = SandboxedModule.require modulePath, requires:
|
|
@ProjectUploadController = SandboxedModule.require modulePath, requires:
|
|
|
"./ProjectUploadManager" : @ProjectUploadManager = {}
|
|
"./ProjectUploadManager" : @ProjectUploadManager = {}
|
|
|
"./FileSystemImportManager" : @FileSystemImportManager = {}
|
|
"./FileSystemImportManager" : @FileSystemImportManager = {}
|
|
@@ -130,16 +130,13 @@ describe "ProjectUploadController", ->
|
|
|
@ProjectUploadController.uploadFile @req, @res
|
|
@ProjectUploadController.uploadFile @req, @res
|
|
|
|
|
|
|
|
it "should take the lock", ->
|
|
it "should take the lock", ->
|
|
|
- @LockManager.getLock.calledWith(@project_id).should.equal true
|
|
|
|
|
|
|
+ @LockManager.runWithLock.calledWith(@project_id).should.equal true
|
|
|
|
|
|
|
|
it "should insert the file", ->
|
|
it "should insert the file", ->
|
|
|
@FileSystemImportManager.addEntity
|
|
@FileSystemImportManager.addEntity
|
|
|
.calledWith(@user_id, @project_id, @folder_id, @name, @path)
|
|
.calledWith(@user_id, @project_id, @folder_id, @name, @path)
|
|
|
.should.equal true
|
|
.should.equal true
|
|
|
|
|
|
|
|
- it "should release the lock", ->
|
|
|
|
|
- @LockManager.releaseLock.calledWith(@project_id).should.equal true
|
|
|
|
|
-
|
|
|
|
|
it "should return a successful response to the FileUploader client", ->
|
|
it "should return a successful response to the FileUploader client", ->
|
|
|
expect(@res.body).to.deep.equal
|
|
expect(@res.body).to.deep.equal
|
|
|
success: true
|
|
success: true
|