|
|
@@ -155,7 +155,8 @@ describe 'ProjectEntityMongoUpdateHandler', ->
|
|
|
@project = _id: project_id, rootFolder: [@rootFolder]
|
|
|
|
|
|
@ProjectGetter.getProjectWithOnlyFolders = sinon.stub().yields(null, @project)
|
|
|
- @ProjectLocator.findElementByPath = (options, cb) =>
|
|
|
+ @ProjectLocator.findElementByPath = ->
|
|
|
+ sinon.stub @ProjectLocator, "findElementByPath", (options, cb) =>
|
|
|
{path} = options
|
|
|
@parentFolder = {_id:"parentFolder_id_here"}
|
|
|
lastFolder = path.substring(path.lastIndexOf("/"))
|
|
|
@@ -169,14 +170,14 @@ describe 'ProjectEntityMongoUpdateHandler', ->
|
|
|
|
|
|
it 'should return the root folder if the path is just a slash', (done)->
|
|
|
path = "/"
|
|
|
- @subject.mkdirp project_id, path, (err, folders, lastFolder)=>
|
|
|
+ @subject.mkdirp project_id, path, {}, (err, folders, lastFolder)=>
|
|
|
lastFolder.should.deep.equal @rootFolder
|
|
|
assert.equal lastFolder.parentFolder_id, undefined
|
|
|
done()
|
|
|
|
|
|
it 'should make just one folder', (done)->
|
|
|
path = "/differentFolder/"
|
|
|
- @subject.mkdirp project_id, path, (err, folders, lastFolder)=>
|
|
|
+ @subject.mkdirp project_id, path, {}, (err, folders, lastFolder)=>
|
|
|
folders.length.should.equal 1
|
|
|
lastFolder.name.should.equal "differentFolder"
|
|
|
lastFolder.parentFolder_id.should.equal @parentFolder_id
|
|
|
@@ -184,7 +185,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
|
|
|
|
|
|
it 'should make the final folder in path if it doesnt exist with one level', (done)->
|
|
|
path = "level1/level2"
|
|
|
- @subject.mkdirp project_id, path, (err, folders, lastFolder)=>
|
|
|
+ @subject.mkdirp project_id, path, {}, (err, folders, lastFolder)=>
|
|
|
folders.length.should.equal 1
|
|
|
lastFolder.name.should.equal "level2"
|
|
|
lastFolder.parentFolder_id.should.equal @parentFolder_id
|
|
|
@@ -193,7 +194,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
|
|
|
it 'should make the final folder in path if it doesnt exist with mutliple levels', (done)->
|
|
|
path = "level1/level2/level3"
|
|
|
|
|
|
- @subject.mkdirp project_id, path,(err, folders, lastFolder) =>
|
|
|
+ @subject.mkdirp project_id, path, {}, (err, folders, lastFolder) =>
|
|
|
folders.length.should.equal 2
|
|
|
folders[0].name.should.equal "level2"
|
|
|
folders[0].parentFolder_id.should.equal @parentFolder_id
|
|
|
@@ -204,7 +205,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
|
|
|
it 'should work with slashes either side', (done)->
|
|
|
path = "/level1/level2/level3/"
|
|
|
|
|
|
- @subject.mkdirp project_id, path, (err, folders, lastFolder)=>
|
|
|
+ @subject.mkdirp project_id, path, {}, (err, folders, lastFolder)=>
|
|
|
folders.length.should.equal 2
|
|
|
folders[0].name.should.equal "level2"
|
|
|
folders[0].parentFolder_id.should.equal @parentFolder_id
|
|
|
@@ -212,6 +213,20 @@ describe 'ProjectEntityMongoUpdateHandler', ->
|
|
|
lastFolder.parentFolder_id.should.equal @parentFolder_id
|
|
|
done()
|
|
|
|
|
|
+ it 'should use a case-insensitive match by default', (done)->
|
|
|
+ path = "/differentFolder/"
|
|
|
+ @subject.mkdirp project_id, path, {}, (err, folders, lastFolder)=>
|
|
|
+ @ProjectLocator.findElementByPath.calledWithMatch({exactCaseMatch:undefined})
|
|
|
+ .should.equal true
|
|
|
+ done()
|
|
|
+
|
|
|
+ it 'should use a case-sensitive match if exactCaseMatch option is set', (done)->
|
|
|
+ path = "/differentFolder/"
|
|
|
+ @subject.mkdirp project_id, path, {exactCaseMatch:true}, (err, folders, lastFolder)=>
|
|
|
+ @ProjectLocator.findElementByPath.calledWithMatch({exactCaseMatch:true})
|
|
|
+ .should.equal true
|
|
|
+ done()
|
|
|
+
|
|
|
describe 'moveEntity', ->
|
|
|
beforeEach ->
|
|
|
@pathAfterMove = {
|