|
|
@@ -87,9 +87,9 @@ describe "CollaboratorsHandler", ->
|
|
|
beforeEach ->
|
|
|
@CollaboratorHandler.getMemberIdsWithPrivilegeLevels = sinon.stub()
|
|
|
@CollaboratorHandler.getMemberIdsWithPrivilegeLevels.withArgs(@project_id).yields(null, [
|
|
|
- { id: "read-only-ref-1", privilegeLevel: "readOnly", source: 'invite' }
|
|
|
+ { id: "read-only-ref-1", privilegeLevel: "readOnly", source: 'token' }
|
|
|
{ id: "read-only-ref-2", privilegeLevel: "readOnly", source: 'invite' }
|
|
|
- { id: "read-write-ref-1", privilegeLevel: "readAndWrite", source: 'invite' }
|
|
|
+ { id: "read-write-ref-1", privilegeLevel: "readAndWrite", source: 'token' }
|
|
|
{ id: "read-write-ref-2", privilegeLevel: "readAndWrite", source: 'invite' }
|
|
|
{ id: "doesnt-exist", privilegeLevel: "readAndWrite", source: 'invite' }
|
|
|
])
|
|
|
@@ -111,6 +111,32 @@ describe "CollaboratorsHandler", ->
|
|
|
])
|
|
|
.should.equal true
|
|
|
|
|
|
+ describe "getInvitedMembersWithPrivilegeLevels", ->
|
|
|
+ beforeEach ->
|
|
|
+ @CollaboratorHandler.getMemberIdsWithPrivilegeLevels = sinon.stub()
|
|
|
+ @CollaboratorHandler.getMemberIdsWithPrivilegeLevels.withArgs(@project_id).yields(null, [
|
|
|
+ { id: "read-only-ref-1", privilegeLevel: "readOnly", source: 'token' }
|
|
|
+ { id: "read-only-ref-2", privilegeLevel: "readOnly", source: 'invite' }
|
|
|
+ { id: "read-write-ref-1", privilegeLevel: "readAndWrite", source: 'token' }
|
|
|
+ { id: "read-write-ref-2", privilegeLevel: "readAndWrite", source: 'invite' }
|
|
|
+ { id: "doesnt-exist", privilegeLevel: "readAndWrite", source: 'invite' }
|
|
|
+ ])
|
|
|
+ @UserGetter.getUserById = sinon.stub()
|
|
|
+ @UserGetter.getUserById.withArgs("read-only-ref-1").yields(null, { _id: "read-only-ref-1" })
|
|
|
+ @UserGetter.getUserById.withArgs("read-only-ref-2").yields(null, { _id: "read-only-ref-2" })
|
|
|
+ @UserGetter.getUserById.withArgs("read-write-ref-1").yields(null, { _id: "read-write-ref-1" })
|
|
|
+ @UserGetter.getUserById.withArgs("read-write-ref-2").yields(null, { _id: "read-write-ref-2" })
|
|
|
+ @UserGetter.getUserById.withArgs("doesnt-exist").yields(null, null)
|
|
|
+ @CollaboratorHandler.getInvitedMembersWithPrivilegeLevels @project_id, @callback
|
|
|
+
|
|
|
+ it "should return an array of invited members with their privilege levels", ->
|
|
|
+ @callback
|
|
|
+ .calledWith(null, [
|
|
|
+ { user: { _id: "read-only-ref-2" }, privilegeLevel: "readOnly" }
|
|
|
+ { user: { _id: "read-write-ref-2" }, privilegeLevel: "readAndWrite" }
|
|
|
+ ])
|
|
|
+ .should.equal true
|
|
|
+
|
|
|
describe "getMemberIdPrivilegeLevel", ->
|
|
|
beforeEach ->
|
|
|
@CollaboratorHandler.getMemberIdsWithPrivilegeLevels = sinon.stub()
|