|
@@ -19,6 +19,7 @@ describe "CollaboratorsController", ->
|
|
|
"../Editor/EditorRealTimeController": @EditorRealTimeController = {}
|
|
"../Editor/EditorRealTimeController": @EditorRealTimeController = {}
|
|
|
'../Subscription/LimitationsManager' : @LimitationsManager = {}
|
|
'../Subscription/LimitationsManager' : @LimitationsManager = {}
|
|
|
'../Project/ProjectEditorHandler' : @ProjectEditorHandler = {}
|
|
'../Project/ProjectEditorHandler' : @ProjectEditorHandler = {}
|
|
|
|
|
+ "../Contacts/ContactManager": @ContactManager = {}
|
|
|
@res = new MockResponse()
|
|
@res = new MockResponse()
|
|
|
@req = new MockRequest()
|
|
@req = new MockRequest()
|
|
|
|
|
|
|
@@ -61,6 +62,8 @@ describe "CollaboratorsController", ->
|
|
|
@req.body =
|
|
@req.body =
|
|
|
email: @email = "Joe@example.com"
|
|
email: @email = "Joe@example.com"
|
|
|
privileges: @privileges = "readOnly"
|
|
privileges: @privileges = "readOnly"
|
|
|
|
|
+ @req.session =
|
|
|
|
|
+ user: _id: @adding_user_id = "adding-user-id"
|
|
|
@res.json = sinon.stub()
|
|
@res.json = sinon.stub()
|
|
|
@user_id = "mock-user-id"
|
|
@user_id = "mock-user-id"
|
|
|
@raw_user = {
|
|
@raw_user = {
|
|
@@ -75,6 +78,7 @@ describe "CollaboratorsController", ->
|
|
|
@UserGetter.getUser = sinon.stub().callsArgWith(1, null, @user)
|
|
@UserGetter.getUser = sinon.stub().callsArgWith(1, null, @user)
|
|
|
@CollaboratorsEmailHandler.notifyUserOfProjectShare = sinon.stub()
|
|
@CollaboratorsEmailHandler.notifyUserOfProjectShare = sinon.stub()
|
|
|
@EditorRealTimeController.emitToRoom = sinon.stub()
|
|
@EditorRealTimeController.emitToRoom = sinon.stub()
|
|
|
|
|
+ @ContactManager.addContact = sinon.stub()
|
|
|
@callback = sinon.stub()
|
|
@callback = sinon.stub()
|
|
|
|
|
|
|
|
describe "when the project can accept more collaborators", ->
|
|
describe "when the project can accept more collaborators", ->
|
|
@@ -95,6 +99,11 @@ describe "CollaboratorsController", ->
|
|
|
@CollaboratorsEmailHandler.notifyUserOfProjectShare
|
|
@CollaboratorsEmailHandler.notifyUserOfProjectShare
|
|
|
.calledWith(@project_id, @email.toLowerCase())
|
|
.calledWith(@project_id, @email.toLowerCase())
|
|
|
.should.equal true
|
|
.should.equal true
|
|
|
|
|
+
|
|
|
|
|
+ it "should add the user as a contact for the adding user", ->
|
|
|
|
|
+ @ContactManager.addContact
|
|
|
|
|
+ .calledWith(@adding_user_id, @user_id)
|
|
|
|
|
+ .should.equal true
|
|
|
|
|
|
|
|
it "should send the user as the response body", ->
|
|
it "should send the user as the response body", ->
|
|
|
@res.json
|
|
@res.json
|