ProjectEntityMongoUpdateHandlerTests.coffee 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. chai = require('chai')
  2. expect = chai.expect
  3. assert = require('chai').assert
  4. should = chai.should()
  5. sinon = require 'sinon'
  6. tk = require("timekeeper")
  7. modulePath = "../../../../app/js/Features/Project/ProjectEntityMongoUpdateHandler"
  8. Errors = require "../../../../app/js/Features/Errors/Errors"
  9. ObjectId = require("mongoose").Types.ObjectId
  10. SandboxedModule = require('sandboxed-module')
  11. describe 'ProjectEntityMongoUpdateHandler', ->
  12. project_id = '4eecb1c1bffa66588e0000a1'
  13. doc_id = '4eecb1c1bffa66588e0000a2'
  14. file_id = '4eecb1c1bffa66588e0000a3'
  15. folder_id = "4eecaffcbffa66588e000008"
  16. beforeEach ->
  17. @FolderModel = class Folder
  18. constructor:(options)->
  19. {@name} = options
  20. @._id = "folder_id"
  21. @docName = "doc-name"
  22. @fileName = "something.jpg"
  23. @project = _id: project_id, name: 'project name'
  24. @callback = sinon.stub()
  25. tk.freeze(Date.now())
  26. @subject = SandboxedModule.require modulePath, requires:
  27. 'logger-sharelatex': @logger = {log:sinon.stub(), error: sinon.stub(), err:->}
  28. "settings-sharelatex":@settings = {
  29. maxEntitiesPerProject: 100
  30. }
  31. "../Cooldown/CooldownManager": @CooldownManager = {}
  32. '../../models/Folder': Folder:@FolderModel
  33. '../../models/Project': Project:@ProjectModel = {}
  34. './ProjectEntityHandler': @ProjectEntityHandler = {}
  35. './ProjectLocator': @ProjectLocator = {}
  36. "./ProjectGetter": @ProjectGetter =
  37. getProject: sinon.stub().yields(null, @project)
  38. afterEach ->
  39. tk.reset()
  40. describe 'addDoc', ->
  41. beforeEach ->
  42. @subject._confirmFolder = sinon.stub().yields(folder_id)
  43. @subject._putElement = sinon.stub()
  44. @doc = _id: doc_id
  45. @subject.addDoc project_id, folder_id, @doc, @callback
  46. it 'gets the project', ->
  47. @ProjectGetter.getProject
  48. .calledWith(project_id, {rootFolder:true, name: true})
  49. .should.equal true
  50. it 'checks the folder exists', ->
  51. @subject._confirmFolder
  52. .calledWith(@project, folder_id)
  53. .should.equal true
  54. it 'puts the element in mongo', ->
  55. @subject._putElement
  56. .calledWith(@project, folder_id, @doc, 'doc', @callback)
  57. .should.equal true
  58. describe 'addFile', ->
  59. beforeEach ->
  60. @subject._confirmFolder = sinon.stub().yields(folder_id)
  61. @subject._putElement = sinon.stub()
  62. @file = _id: file_id
  63. @subject.addFile project_id, folder_id, @file, @callback
  64. it 'gets the project', ->
  65. @ProjectGetter.getProject
  66. .calledWith(project_id, {rootFolder:true, name: true})
  67. .should.equal true
  68. it 'checks the folder exists', ->
  69. @subject._confirmFolder
  70. .calledWith(@project, folder_id)
  71. .should.equal true
  72. it 'puts the element in mongo', ->
  73. @subject._putElement
  74. .calledWith(@project, folder_id, @file, 'file', @callback)
  75. .should.equal true
  76. describe 'replaceFile', ->
  77. beforeEach ->
  78. @file = _id: file_id
  79. @path = mongo: 'file.png'
  80. @ProjectLocator.findElement = sinon.stub().yields(null, @file, @path)
  81. @ProjectModel.update = sinon.stub().yields()
  82. @subject.replaceFile project_id, file_id, @callback
  83. it 'gets the project', ->
  84. @ProjectGetter.getProject
  85. .calledWith(project_id, {rootFolder:true, name: true})
  86. .should.equal true
  87. it 'finds the element', ->
  88. @ProjectLocator.findElement
  89. .calledWith({ @project, element_id: file_id, type: 'file' })
  90. .should.equal true
  91. it 'increments the rev and sets the created_at', ->
  92. @ProjectModel.update
  93. .calledWith(
  94. { _id: project_id },
  95. {
  96. '$inc': { 'file.png.rev': 1 }
  97. '$set': { 'file.png.created': new Date() }
  98. }
  99. {}
  100. )
  101. .should.equal true
  102. it 'calls the callback', ->
  103. @callback.calledWith(null, @file, @project, @path).should.equal true
  104. describe 'mkdirp', ->
  105. beforeEach ->
  106. @parentFolder_id = "1jnjknjk"
  107. @newFolder = {_id:"newFolder_id_here"}
  108. @lastFolder = {_id:"123das", folders:[]}
  109. @rootFolder = {_id: "rootFolderId" }
  110. @project = _id: project_id, rootFolder: [@rootFolder]
  111. @ProjectGetter.getProjectWithOnlyFolders = sinon.stub().yields(null, @project)
  112. @ProjectLocator.findElementByPath = (project_id, path, cb) =>
  113. @parentFolder = {_id:"parentFolder_id_here"}
  114. lastFolder = path.substring(path.lastIndexOf("/"))
  115. if lastFolder.indexOf("level1") == -1
  116. cb "level1 is not the last foler "
  117. else
  118. cb null, @parentFolder
  119. @subject.addFolder = (project_id, parentFolder_id, folderName, callback) =>
  120. callback null, {name:folderName}, @parentFolder_id
  121. it 'should return the root folder if the path is just a slash', (done)->
  122. path = "/"
  123. @subject.mkdirp project_id, path, (err, folders, lastFolder)=>
  124. lastFolder.should.deep.equal @rootFolder
  125. assert.equal lastFolder.parentFolder_id, undefined
  126. done()
  127. it 'should make just one folder', (done)->
  128. path = "/differentFolder/"
  129. @subject.mkdirp project_id, path, (err, folders, lastFolder)=>
  130. folders.length.should.equal 1
  131. lastFolder.name.should.equal "differentFolder"
  132. lastFolder.parentFolder_id.should.equal @parentFolder_id
  133. done()
  134. it 'should make the final folder in path if it doesnt exist with one level', (done)->
  135. path = "level1/level2"
  136. @subject.mkdirp project_id, path, (err, folders, lastFolder)=>
  137. folders.length.should.equal 1
  138. lastFolder.name.should.equal "level2"
  139. lastFolder.parentFolder_id.should.equal @parentFolder_id
  140. done()
  141. it 'should make the final folder in path if it doesnt exist with mutliple levels', (done)->
  142. path = "level1/level2/level3"
  143. @subject.mkdirp project_id, path,(err, folders, lastFolder) =>
  144. folders.length.should.equal 2
  145. folders[0].name.should.equal "level2"
  146. folders[0].parentFolder_id.should.equal @parentFolder_id
  147. lastFolder.name.should.equal "level3"
  148. lastFolder.parentFolder_id.should.equal @parentFolder_id
  149. done()
  150. it 'should work with slashes either side', (done)->
  151. path = "/level1/level2/level3/"
  152. @subject.mkdirp project_id, path, (err, folders, lastFolder)=>
  153. folders.length.should.equal 2
  154. folders[0].name.should.equal "level2"
  155. folders[0].parentFolder_id.should.equal @parentFolder_id
  156. lastFolder.name.should.equal "level3"
  157. lastFolder.parentFolder_id.should.equal @parentFolder_id
  158. done()
  159. describe 'moveEntity', ->
  160. beforeEach ->
  161. @pathAfterMove = {
  162. fileSystem: "/somewhere/else.txt"
  163. }
  164. @ProjectEntityHandler.getAllEntitiesFromProject = sinon.stub()
  165. @ProjectEntityHandler.getAllEntitiesFromProject
  166. .onFirstCall()
  167. .yields(null, @oldDocs = ['old-doc'], @oldFiles = ['old-file'])
  168. @ProjectEntityHandler.getAllEntitiesFromProject
  169. .onSecondCall()
  170. .yields(null, @newDocs = ['new-doc'], @newFiles = ['new-file'])
  171. @doc = {lines:["1234","312343d"], rev: "1234"}
  172. @path = { mongo:"folders[0]", fileSystem:"/old_folder/somewhere.txt" }
  173. @ProjectLocator.findElement = sinon.stub()
  174. .withArgs({@project, element_id: @docId, type: 'docs'})
  175. .yields(null, @doc, @path)
  176. @subject._checkValidMove = sinon.stub().yields()
  177. @subject._removeElementFromMongoArray = sinon.stub().yields(null, @project)
  178. @subject._putElement = sinon.stub().yields(null, path: @pathAfterMove)
  179. @subject.moveEntity project_id, doc_id, folder_id, "docs", @callback
  180. it 'should get the project', ->
  181. @ProjectGetter.getProject
  182. .calledWith(project_id, {rootFolder:true, name:true})
  183. .should.equal true
  184. it 'should find the doc to move', ->
  185. @ProjectLocator.findElement
  186. .calledWith({element_id: doc_id, type: "docs", project: @project })
  187. .should.equal true
  188. it 'should check this is a valid move', ->
  189. @subject._checkValidMove
  190. .calledWith(@project, 'docs', @doc, @path, folder_id)
  191. .should.equal true
  192. it 'should remove the element from its current position', ->
  193. @subject._removeElementFromMongoArray
  194. .calledWith(@ProjectModel, project_id, @path.mongo)
  195. .should.equal true
  196. it "should put the element back in the new folder", ->
  197. @subject._putElement
  198. .calledWith(@project, folder_id, @doc, "docs")
  199. .should.equal true
  200. it "calls the callback", ->
  201. changes = { @oldDocs, @newDocs, @oldFiles, @newFiles }
  202. @callback.calledWith(
  203. null, @project.name, @path.fileSystem, @pathAfterMove.fileSystem, @doc.rev, changes
  204. ).should.equal true
  205. describe 'deleteEntity', ->
  206. beforeEach ->
  207. @path = mongo: "mongo.path", fileSystem: "/file/system/path"
  208. @doc = _id: doc_id
  209. @ProjectLocator.findElement = sinon.stub().callsArgWith(1, null, @doc, @path)
  210. @subject._removeElementFromMongoArray = sinon.stub().yields()
  211. @subject.deleteEntity project_id, doc_id, 'doc', @callback
  212. it "should get the project", ->
  213. @ProjectGetter.getProject
  214. .calledWith(project_id, {name:true, rootFolder:true})
  215. .should.equal true
  216. it "should find the element", ->
  217. @ProjectLocator.findElement
  218. .calledWith({@project, element_id: @doc._id, type: 'doc'})
  219. .should.equal true
  220. it "should remove the element from the database", ->
  221. @subject._removeElementFromMongoArray
  222. .calledWith(@ProjectModel, project_id, @path.mongo)
  223. .should.equal true
  224. it "calls the callbck", ->
  225. @callback.calledWith(null, @doc, @path, @project).should.equal true
  226. describe "renameEntity", ->
  227. beforeEach ->
  228. @newName = "new.tex"
  229. @path = mongo: "mongo.path", fileSystem: "/old.tex"
  230. @project =
  231. _id: ObjectId(project_id)
  232. rootFolder: [_id:ObjectId()]
  233. @doc = _id: doc_id, name: "old.tex", rev: 1
  234. @folder = _id: folder_id
  235. @ProjectGetter.getProject = sinon.stub().yields(null, @project)
  236. @ProjectEntityHandler.getAllEntitiesFromProject = sinon.stub()
  237. @ProjectEntityHandler.getAllEntitiesFromProject
  238. .onFirstCall()
  239. .yields( null, @oldDocs = ['old-doc'], @oldFiles = ['old-file'])
  240. @ProjectEntityHandler.getAllEntitiesFromProject
  241. .onSecondCall()
  242. .yields( null, @newDocs = ['new-doc'], @newFiles = ['new-file'])
  243. @ProjectLocator.findElement = sinon.stub().yields(null, @doc, @path, @folder)
  244. @subject._checkValidElementName = sinon.stub().yields()
  245. @ProjectModel.findOneAndUpdate = sinon.stub().callsArgWith(3, null, @project)
  246. @subject.renameEntity project_id, doc_id, 'doc', @newName, @callback
  247. it 'should get the project', ->
  248. @ProjectGetter.getProject
  249. .calledWith(project_id, {rootFolder:true, name:true})
  250. .should.equal true
  251. it 'should find the doc', ->
  252. @ProjectLocator.findElement
  253. .calledWith({element_id: doc_id, type: 'doc', project: @project })
  254. .should.equal true
  255. it 'should check the new name is valid', ->
  256. @subject._checkValidElementName
  257. .calledWith(@folder, @newName)
  258. .should.equal true
  259. it 'should update the doc name', ->
  260. @ProjectModel.findOneAndUpdate
  261. .calledWith(
  262. { _id: project_id },
  263. { $set: { "mongo.path.name": @newName } },
  264. { new: true }
  265. ).should.equal true
  266. it 'calls the callback', ->
  267. changes = { @oldDocs, @newDocs, @oldFiles, @newFiles }
  268. @callback.calledWith(
  269. null, @project.name, '/old.tex', '/new.tex', @doc.rev, changes
  270. ).should.equal true
  271. describe 'addFolder', ->
  272. beforeEach ->
  273. @folderName = "folder1234"
  274. @ProjectGetter.getProjectWithOnlyFolders = sinon.stub().callsArgWith(1, null, @project)
  275. @subject._confirmFolder = sinon.stub().yields(folder_id)
  276. @subject._putElement = sinon.stub().yields()
  277. @subject.addFolder project_id, folder_id, @folderName, @callback
  278. it 'gets the project', ->
  279. @ProjectGetter.getProject
  280. .calledWith(project_id, {rootFolder:true, name: true})
  281. .should.equal true
  282. it 'checks the parent folder exists', ->
  283. @subject._confirmFolder
  284. .calledWith(@project, folder_id)
  285. .should.equal true
  286. it 'puts the element in mongo', ->
  287. folderMatcher = sinon.match (folder) =>
  288. folder.name == @folderName
  289. @subject._putElement
  290. .calledWithMatch(@project, folder_id, folderMatcher, 'folder')
  291. .should.equal true
  292. it 'calls the callback', ->
  293. folderMatcher = sinon.match (folder) =>
  294. folder.name == @folderName
  295. @callback.calledWithMatch(null, folderMatcher, folder_id).should.equal true
  296. describe '_removeElementFromMongoArray ', ->
  297. beforeEach ->
  298. @mongoPath = "folders[0].folders[5]"
  299. @id = "12344"
  300. @ProjectModel.update = sinon.stub().yields()
  301. @ProjectModel.findOneAndUpdate = sinon.stub().yields(null, @project)
  302. @subject._removeElementFromMongoArray @ProjectModel, @id, @mongoPath, @callback
  303. it 'should unset', ->
  304. update = { '$unset': { } }
  305. update['$unset'][@mongoPath] = 1
  306. @ProjectModel.update
  307. .calledWith({ _id: @id }, update, {})
  308. .should.equal true
  309. it 'should pull', ->
  310. @ProjectModel.findOneAndUpdate
  311. .calledWith({ _id: @id }, { '$pull': { 'folders[0]': null } }, {'new': true})
  312. .should.equal true
  313. it 'should call the callback', ->
  314. @callback.calledWith(null, @project).should.equal true
  315. describe "_countElements", ->
  316. beforeEach ->
  317. @project =
  318. _id: project_id,
  319. rootFolder: [
  320. docs: [{_id:123}, {_id:345}]
  321. fileRefs: [{_id:123}, {_id:345}, {_id:456}]
  322. folders: [
  323. {
  324. docs: [{_id:123}, {_id:345}, {_id:456}]
  325. fileRefs:{}
  326. folders: [
  327. {
  328. docs:[_id:1234],
  329. fileRefs:[{_id:23123}, {_id:123213}, {_id:2312}]
  330. folders:[
  331. {
  332. docs:[{_id:321321}, {_id:123213}]
  333. fileRefs:[{_id:312321}]
  334. folders:[]
  335. }
  336. ]
  337. }
  338. ]
  339. },{
  340. docs:[{_id:123}, {_id:32131}]
  341. fileRefs:[]
  342. folders:[
  343. {
  344. docs:[{_id:3123}]
  345. fileRefs:[{_id:321321}, {_id:321321}, {_id:313122}]
  346. folders:0
  347. }
  348. ]
  349. }
  350. ]
  351. ]
  352. it "should return the correct number", ->
  353. expect(@subject._countElements @project).to.equal(26)
  354. it "should deal with null folders", ->
  355. @project.rootFolder[0].folders[0].folders = undefined
  356. expect(@subject._countElements @project).to.equal(17)
  357. it "should deal with null docs", ->
  358. @project.rootFolder[0].folders[0].docs = undefined
  359. expect(@subject._countElements @project).to.equal(23)
  360. it "should deal with null fileRefs", ->
  361. @project.rootFolder[0].folders[0].folders[0].fileRefs = undefined
  362. expect(@subject._countElements @project).to.equal(23)
  363. describe "_putElement", ->
  364. beforeEach ->
  365. @project =
  366. _id: project_id
  367. rootFolder: [_id:ObjectId()]
  368. @folder =
  369. _id: ObjectId()
  370. name: "someFolder"
  371. docs: [ {name: "another-doc.tex"} ]
  372. fileRefs: [ {name: "another-file.tex"} ]
  373. folders: [ {name: "another-folder"} ]
  374. @doc =
  375. _id: ObjectId()
  376. name: "new.tex"
  377. @path = mongo: "mongo.path", fileSystem: "/file/system/old.tex"
  378. @ProjectLocator.findElement = sinon.stub().yields(null, @folder, @path)
  379. @ProjectModel.findOneAndUpdate = sinon.stub().yields(null, @project)
  380. describe "updating the project", ->
  381. it "should use the correct mongo path", (done)->
  382. @subject._putElement @project, @folder._id, @doc, "docs", (err)=>
  383. @ProjectModel.findOneAndUpdate.args[0][0]._id.should.equal @project._id
  384. assert.deepEqual @ProjectModel.findOneAndUpdate.args[0][1].$push[@path.mongo+".docs"], @doc
  385. done()
  386. it "should return the project in the callback", (done)->
  387. @subject._putElement @project, @folder._id, @doc, "docs", (err, path, project)=>
  388. assert.equal project, @project
  389. done()
  390. it "should add an s onto the type if not included", (done)->
  391. @subject._putElement @project, @folder._id, @doc, "doc", (err)=>
  392. assert.deepEqual @ProjectModel.findOneAndUpdate.args[0][1].$push[@path.mongo+".docs"], @doc
  393. done()
  394. it "should not call update if element is null", (done)->
  395. @subject._putElement @project, @folder._id, null, "doc", (err)=>
  396. @ProjectModel.findOneAndUpdate.called.should.equal false
  397. done()
  398. it "should default to root folder insert", (done)->
  399. @subject._putElement @project, null, @doc, "doc", (err)=>
  400. @ProjectLocator.findElement.args[0][0].element_id.should.equal @project.rootFolder[0]._id
  401. done()
  402. it "should error if the element has no _id", (done)->
  403. doc =
  404. name:"something"
  405. @subject._putElement @project, @folder._id, doc, "doc", (err)=>
  406. @ProjectModel.findOneAndUpdate.called.should.equal false
  407. done()
  408. it "should error if element name contains invalid characters", (done)->
  409. doc =
  410. _id: ObjectId()
  411. name: "something*bad"
  412. @subject._putElement @project, @folder._id, doc, "doc", (err)=>
  413. @ProjectModel.findOneAndUpdate.called.should.equal false
  414. err.should.deep.equal new Errors.InvalidNameError("invalid element name")
  415. done()
  416. it "should error if element name is too long", (done)->
  417. doc =
  418. _id: ObjectId()
  419. name: new Array(200).join("long-") + "something"
  420. @subject._putElement @project, @folder._id, doc, "doc", (err)=>
  421. @ProjectModel.findOneAndUpdate.called.should.equal false
  422. err.should.deep.equal new Errors.InvalidNameError("invalid element name")
  423. done()
  424. it "should error if the folder name is too long", (done)->
  425. @path =
  426. mongo: "mongo.path",
  427. fileSystem: new Array(200).join("subdir/") + "foo"
  428. @ProjectLocator.findElement.callsArgWith(1, null, @folder, @path)
  429. doc =
  430. _id: ObjectId()
  431. name: "something"
  432. @subject._putElement @project, @folder._id, doc, "doc", (err)=>
  433. @ProjectModel.findOneAndUpdate.called.should.equal false
  434. err.should.deep.equal new Errors.InvalidNameError("path too long")
  435. done()
  436. it "should error if a document already exists with the same name", (done)->
  437. doc =
  438. _id: ObjectId()
  439. name: "another-doc.tex"
  440. @subject._putElement @project, @folder, doc, "doc", (err)=>
  441. @ProjectModel.findOneAndUpdate.called.should.equal false
  442. err.should.deep.equal new Errors.InvalidNameError("file already exists")
  443. done()
  444. it "should error if a file already exists with the same name", (done)->
  445. doc =
  446. _id: ObjectId()
  447. name: "another-file.tex"
  448. @subject._putElement @project, @folder, doc, "doc", (err)=>
  449. @ProjectModel.findOneAndUpdate.called.should.equal false
  450. err.should.deep.equal new Errors.InvalidNameError("file already exists")
  451. done()
  452. it "should error if a folder already exists with the same name", (done)->
  453. doc =
  454. _id: ObjectId()
  455. name: "another-folder"
  456. @subject._putElement @project, @folder, doc, "doc", (err)=>
  457. @ProjectModel.findOneAndUpdate.called.should.equal false
  458. err.should.deep.equal new Errors.InvalidNameError("file already exists")
  459. done()
  460. describe '_checkValidElementName', ->
  461. beforeEach ->
  462. @folder =
  463. docs: [ name: 'doc_name' ]
  464. fileRefs: [ name: 'file_name' ]
  465. folders: [ name: 'folder_name' ]
  466. it 'returns an error if name matches any doc name', ->
  467. @subject._checkValidElementName @folder, 'doc_name', (err) ->
  468. expect(err).to.deep.equal new Errors.InvalidNameError("file already exists")
  469. it 'returns an error if name matches any file name', ->
  470. @subject._checkValidElementName @folder, 'file_name', (err) ->
  471. expect(err).to.deep.equal new Errors.InvalidNameError("file already exists")
  472. it 'returns an error if name matches any folder name', ->
  473. @subject._checkValidElementName @folder, 'folder_name', (err) ->
  474. expect(err).to.deep.equal new Errors.InvalidNameError("file already exists")
  475. it 'returns nothing if name is valid', ->
  476. @subject._checkValidElementName @folder, 'unique_name', (err) ->
  477. expect(err).to.be.undefined
  478. describe '_checkValidMove', ->
  479. beforeEach ->
  480. @destFolder = _id: folder_id
  481. @destFolderPath = fileSystem: '/foo/bar'
  482. @ProjectLocator.findElement = sinon.stub().yields(null, @destFolder, @destFolderPath)
  483. @subject._checkValidElementName = sinon.stub().yields()
  484. it 'checks the element name is valid', ->
  485. @doc = _id: doc_id, name: 'doc_name'
  486. @subject._checkValidMove @project, 'doc', @doc, fileSystem: '/main.tex', @destFolder._id, (err) =>
  487. expect(err).to.be.undefined
  488. @subject._checkValidElementName
  489. .calledWith(@destFolder, @doc.name)
  490. .should.equal true
  491. it 'returns an error if trying to move a folder inside itself', ->
  492. folder = name: 'folder_name'
  493. @subject._checkValidMove @project, 'folder', folder, fileSystem: '/foo', @destFolder._id, (err) =>
  494. expect(err).to.deep.equal new Errors.InvalidNameError("destination folder is a child folder of me")