|
@@ -109,46 +109,95 @@ describe "ProjectGetter", ->
|
|
|
_id: @project_id = "56d46b0a1d3422b87c5ebcb1"
|
|
_id: @project_id = "56d46b0a1d3422b87c5ebcb1"
|
|
|
@db.projects.find = sinon.stub().callsArgWith(2, null, [@project])
|
|
@db.projects.find = sinon.stub().callsArgWith(2, null, [@project])
|
|
|
|
|
|
|
|
- describe "passing an id", ->
|
|
|
|
|
|
|
+ describe "without projection", ->
|
|
|
|
|
+ describe "with project id", ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @ProjectGetter.getProject @project_id, @callback
|
|
|
|
|
+
|
|
|
|
|
+ it "should call find with the project id", ->
|
|
|
|
|
+ expect(@db.projects.find.callCount).to.equal 1
|
|
|
|
|
+ expect(@db.projects.find.lastCall.args[0]).to.deep.equal {
|
|
|
|
|
+ _id: ObjectId(@project_id)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ describe "without project id", ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @ProjectGetter.getProject null, @callback
|
|
|
|
|
+
|
|
|
|
|
+ it "should callback with error", ->
|
|
|
|
|
+ expect(@db.projects.find.callCount).to.equal 0
|
|
|
|
|
+ expect(@callback.lastCall.args[0]).to.be.instanceOf Error
|
|
|
|
|
+
|
|
|
|
|
+ describe "with projection", ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
- @ProjectGetter.getProjectWithOnlyFolders @project_id, @callback
|
|
|
|
|
-
|
|
|
|
|
- it "should call find with the project id", ->
|
|
|
|
|
- expect(@db.projects.find.lastCall.args[0]).to.deep.equal {
|
|
|
|
|
- _id: ObjectId(@project_id)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ @projection = {_id: 1}
|
|
|
|
|
|
|
|
- it "should exclude the docs and files linesaaaa", ->
|
|
|
|
|
- excludes =
|
|
|
|
|
- "rootFolder.docs": 0
|
|
|
|
|
- "rootFolder.fileRefs": 0
|
|
|
|
|
- "rootFolder.folders.docs": 0
|
|
|
|
|
- "rootFolder.folders.fileRefs": 0
|
|
|
|
|
- "rootFolder.folders.folders.docs": 0
|
|
|
|
|
- "rootFolder.folders.folders.fileRefs": 0
|
|
|
|
|
- "rootFolder.folders.folders.folders.docs": 0
|
|
|
|
|
- "rootFolder.folders.folders.folders.fileRefs": 0
|
|
|
|
|
- "rootFolder.folders.folders.folders.folders.docs": 0
|
|
|
|
|
- "rootFolder.folders.folders.folders.folders.fileRefs": 0
|
|
|
|
|
- "rootFolder.folders.folders.folders.folders.folders.docs": 0
|
|
|
|
|
- "rootFolder.folders.folders.folders.folders.folders.fileRefs": 0
|
|
|
|
|
- "rootFolder.folders.folders.folders.folders.folders.folders.docs": 0
|
|
|
|
|
- "rootFolder.folders.folders.folders.folders.folders.folders.fileRefs": 0
|
|
|
|
|
- "rootFolder.folders.folders.folders.folders.folders.folders.folders.docs": 0
|
|
|
|
|
- "rootFolder.folders.folders.folders.folders.folders.folders.folders.fileRefs": 0
|
|
|
|
|
- @db.projects.find.calledWith(sinon.match.any, excludes).should.equal true
|
|
|
|
|
|
|
+ describe "with project id", ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @ProjectGetter.getProject @project_id, @projection, @callback
|
|
|
|
|
|
|
|
- it "should call the callback with the project", ->
|
|
|
|
|
- @callback.calledWith(null, @project).should.equal true
|
|
|
|
|
|
|
+ it "should call find with the project id", ->
|
|
|
|
|
+ expect(@db.projects.find.callCount).to.equal 1
|
|
|
|
|
+ expect(@db.projects.find.lastCall.args[0]).to.deep.equal {
|
|
|
|
|
+ _id: ObjectId(@project_id)
|
|
|
|
|
+ }
|
|
|
|
|
+ expect(@db.projects.find.lastCall.args[1]).to.deep.equal @projection
|
|
|
|
|
|
|
|
|
|
+ describe "without project id", ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @ProjectGetter.getProject null, @callback
|
|
|
|
|
|
|
|
|
|
+ it "should callback with error", ->
|
|
|
|
|
+ expect(@db.projects.find.callCount).to.equal 0
|
|
|
|
|
+ expect(@callback.lastCall.args[0]).to.be.instanceOf Error
|
|
|
|
|
|
|
|
- describe "getProject", ->
|
|
|
|
|
|
|
+ describe "getProjectWithoutLock", ->
|
|
|
beforeEach ()->
|
|
beforeEach ()->
|
|
|
@project =
|
|
@project =
|
|
|
_id: @project_id = "56d46b0a1d3422b87c5ebcb1"
|
|
_id: @project_id = "56d46b0a1d3422b87c5ebcb1"
|
|
|
@db.projects.find = sinon.stub().callsArgWith(2, null, [@project])
|
|
@db.projects.find = sinon.stub().callsArgWith(2, null, [@project])
|
|
|
|
|
|
|
|
|
|
+ describe "without projection", ->
|
|
|
|
|
+ describe "with project id", ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @ProjectGetter.getProjectWithoutLock @project_id, @callback
|
|
|
|
|
+
|
|
|
|
|
+ it "should call find with the project id", ->
|
|
|
|
|
+ expect(@db.projects.find.callCount).to.equal 1
|
|
|
|
|
+ expect(@db.projects.find.lastCall.args[0]).to.deep.equal {
|
|
|
|
|
+ _id: ObjectId(@project_id)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ describe "without project id", ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @ProjectGetter.getProjectWithoutLock null, @callback
|
|
|
|
|
+
|
|
|
|
|
+ it "should callback with error", ->
|
|
|
|
|
+ expect(@db.projects.find.callCount).to.equal 0
|
|
|
|
|
+ expect(@callback.lastCall.args[0]).to.be.instanceOf Error
|
|
|
|
|
+
|
|
|
|
|
+ describe "with projection", ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @projection = {_id: 1}
|
|
|
|
|
+
|
|
|
|
|
+ describe "with project id", ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @ProjectGetter.getProjectWithoutLock @project_id, @projection, @callback
|
|
|
|
|
+
|
|
|
|
|
+ it "should call find with the project id", ->
|
|
|
|
|
+ expect(@db.projects.find.callCount).to.equal 1
|
|
|
|
|
+ expect(@db.projects.find.lastCall.args[0]).to.deep.equal {
|
|
|
|
|
+ _id: ObjectId(@project_id)
|
|
|
|
|
+ }
|
|
|
|
|
+ expect(@db.projects.find.lastCall.args[1]).to.deep.equal @projection
|
|
|
|
|
+
|
|
|
|
|
+ describe "without project id", ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @ProjectGetter.getProjectWithoutLock null, @callback
|
|
|
|
|
+
|
|
|
|
|
+ it "should callback with error", ->
|
|
|
|
|
+ expect(@db.projects.find.callCount).to.equal 0
|
|
|
|
|
+ expect(@callback.lastCall.args[0]).to.be.instanceOf Error
|
|
|
|
|
|
|
|
describe "findAllUsersProjects", ->
|
|
describe "findAllUsersProjects", ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|