Fix stub incorrectly overriding top level beforeEach

This commit is contained in:
Alasdair Smith
2018-02-26 11:46:06 +00:00
parent cfc9dbdbb3
commit 5d017beac5
@@ -11,7 +11,7 @@ describe "FileStoreHandler", ->
@fs =
createReadStream : sinon.stub()
lstat: sinon.stub().callsArgWith(1, null, {
isFile:=> @isSafeOnFileSystem
isFile:=> true
isDirectory:-> return false
})
@writeStream =
@@ -35,7 +35,6 @@ describe "FileStoreHandler", ->
describe "uploadFileFromDisk", ->
beforeEach ->
@request.returns(@writeStream)
@isSafeOnFileSystem = true
it "should create read stream", (done)->
@fs.createReadStream.returns
@@ -91,8 +90,13 @@ describe "FileStoreHandler", ->
done()
describe "symlink", ->
beforeEach ->
@fs.lstat = sinon.stub().callsArgWith(1, null, {
isFile:=> false
isDirectory:-> return false
})
it "should not read file if it is symlink", (done)->
@isSafeOnFileSystem = false
@handler.uploadFileFromDisk @project_id, @file_id, @fsPath, =>
@fs.createReadStream.called.should.equal false
done()