Merge branch 'master' into node-6.9
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
should = require('chai').should()
|
||||
SandboxedModule = require('sandboxed-module')
|
||||
assert = require('assert')
|
||||
path = require('path')
|
||||
modulePath = path.join __dirname, '../../../../app/js/Features/Analytics/AnalyticsController'
|
||||
sinon = require("sinon")
|
||||
expect = require("chai").expect
|
||||
|
||||
|
||||
describe 'AnalyticsController', ->
|
||||
|
||||
beforeEach ->
|
||||
@AuthenticationController =
|
||||
getLoggedInUserId: sinon.stub()
|
||||
|
||||
@AnalyticsManager =
|
||||
recordEvent: sinon.stub().callsArgWith(3)
|
||||
|
||||
@req =
|
||||
params:
|
||||
event:"i_did_something"
|
||||
body:"stuff"
|
||||
sessionID: "sessionIDHere"
|
||||
|
||||
@res =
|
||||
send:->
|
||||
@controller = SandboxedModule.require modulePath, requires:
|
||||
"./AnalyticsManager":@AnalyticsManager
|
||||
"../Authentication/AuthenticationController":@AuthenticationController
|
||||
"logger-sharelatex":
|
||||
log:->
|
||||
|
||||
describe "recordEvent", ->
|
||||
|
||||
it "should use the user_id", (done)->
|
||||
@AuthenticationController.getLoggedInUserId.returns("1234")
|
||||
@controller.recordEvent @req, @res
|
||||
@AnalyticsManager.recordEvent.calledWith("1234", @req.params["event"], @req.body).should.equal true
|
||||
done()
|
||||
|
||||
it "should use the session id", (done)->
|
||||
@controller.recordEvent @req, @res
|
||||
@AnalyticsManager.recordEvent.calledWith(@req.sessionID, @req.params["event"], @req.body).should.equal true
|
||||
done()
|
||||
+6
-1
@@ -16,7 +16,7 @@ describe "AuthenticationController", ->
|
||||
"./AuthenticationManager": @AuthenticationManager = {}
|
||||
"../User/UserGetter" : @UserGetter = {}
|
||||
"../User/UserUpdater" : @UserUpdater = {}
|
||||
"../../infrastructure/Metrics": @Metrics = { inc: sinon.stub() }
|
||||
"metrics-sharelatex": @Metrics = { inc: sinon.stub() }
|
||||
"../Security/LoginRateLimiter": @LoginRateLimiter = { processLoginRequest:sinon.stub(), recordSuccessfulLogin:sinon.stub() }
|
||||
"../User/UserHandler": @UserHandler = {setupLoginData:sinon.stub()}
|
||||
"../Analytics/AnalyticsManager": @AnalyticsManager = { recordEvent: sinon.stub() }
|
||||
@@ -254,6 +254,8 @@ describe "AuthenticationController", ->
|
||||
@cb = sinon.stub()
|
||||
@LoginRateLimiter.processLoginRequest.callsArgWith(1, null, true)
|
||||
@AuthenticationManager.authenticate = sinon.stub().callsArgWith(2, null, @user)
|
||||
@req.sessionID = Math.random()
|
||||
@AnalyticsManager.identifyUser = sinon.stub()
|
||||
@AuthenticationController.doPassportLogin(@req, @req.body.email, @req.body.password, @cb)
|
||||
|
||||
it "should attempt to authorise the user", ->
|
||||
@@ -261,6 +263,9 @@ describe "AuthenticationController", ->
|
||||
.calledWith(email: @email.toLowerCase(), @password)
|
||||
.should.equal true
|
||||
|
||||
it "should call identifyUser", ->
|
||||
@AnalyticsManager.identifyUser.calledWith(@user._id, @req.sessionID).should.equal true
|
||||
|
||||
it "should setup the user data in the background", ->
|
||||
@UserHandler.setupLoginData.calledWith(@user).should.equal true
|
||||
|
||||
|
||||
@@ -136,7 +136,20 @@ describe "AuthorizationManager", ->
|
||||
it "should return a NotFoundError", ->
|
||||
@AuthorizationManager.getPrivilegeLevelForProject @user_id, @project_id, (error) ->
|
||||
error.should.be.instanceof Errors.NotFoundError
|
||||
|
||||
|
||||
describe "when the project id is not valid", ->
|
||||
beforeEach ->
|
||||
@AuthorizationManager.isUserSiteAdmin.withArgs(@user_id).yields(null, false)
|
||||
@CollaboratorsHandler.getMemberIdPrivilegeLevel
|
||||
.withArgs(@user_id, @project_id)
|
||||
.yields(null, "readOnly")
|
||||
|
||||
it "should return a error", (done)->
|
||||
@AuthorizationManager.getPrivilegeLevelForProject undefined, "not project id", (err) =>
|
||||
@Project.findOne.called.should.equal false
|
||||
expect(err).to.exist
|
||||
done()
|
||||
|
||||
describe "canUserReadProject", ->
|
||||
beforeEach ->
|
||||
@AuthorizationManager.getPrivilegeLevelForProject = sinon.stub()
|
||||
|
||||
@@ -26,7 +26,7 @@ describe 'BetaProgramHandler', ->
|
||||
log: sinon.stub()
|
||||
err: sinon.stub()
|
||||
},
|
||||
"../../infrastructure/Metrics": @logger = {
|
||||
"metrics-sharelatex": @logger = {
|
||||
inc: sinon.stub()
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ describe "ChatController", ->
|
||||
@req.query =
|
||||
limit: @limit = "30"
|
||||
before: @before = "12345"
|
||||
@CommentsController._injectUserInfoIntoThreads = sinon.stub().yields()
|
||||
@ChatController._injectUserInfoIntoThreads = sinon.stub().yields()
|
||||
@ChatApiHandler.getGlobalMessages = sinon.stub().yields(null, @messages = ["mock", "messages"])
|
||||
@ChatController.getMessages @req, @res
|
||||
|
||||
@@ -79,4 +79,78 @@ describe "ChatController", ->
|
||||
.should.equal true
|
||||
|
||||
it "should return the messages", ->
|
||||
@res.json.calledWith(@messages).should.equal true
|
||||
@res.json.calledWith(@messages).should.equal true
|
||||
|
||||
describe "_injectUserInfoIntoThreads", ->
|
||||
beforeEach ->
|
||||
@users = {
|
||||
"user_id_1": {
|
||||
"mock": "user_1"
|
||||
}
|
||||
"user_id_2": {
|
||||
"mock": "user_2"
|
||||
}
|
||||
}
|
||||
@UserInfoManager.getPersonalInfo = (user_id, callback) =>
|
||||
return callback(null, @users[user_id])
|
||||
sinon.spy @UserInfoManager, "getPersonalInfo"
|
||||
@UserInfoController.formatPersonalInfo = (user) ->
|
||||
return { "formatted": user["mock"] }
|
||||
|
||||
it "should inject a user object into messaged and resolved data", (done) ->
|
||||
@ChatController._injectUserInfoIntoThreads {
|
||||
thread1: {
|
||||
resolved: true
|
||||
resolved_by_user_id: "user_id_1"
|
||||
messages: [{
|
||||
user_id: "user_id_1"
|
||||
content: "foo"
|
||||
}, {
|
||||
user_id: "user_id_2"
|
||||
content: "bar"
|
||||
}]
|
||||
},
|
||||
thread2: {
|
||||
messages: [{
|
||||
user_id: "user_id_1"
|
||||
content: "baz"
|
||||
}]
|
||||
}
|
||||
}, (error, threads) ->
|
||||
expect(threads).to.deep.equal {
|
||||
thread1: {
|
||||
resolved: true
|
||||
resolved_by_user_id: "user_id_1"
|
||||
resolved_by_user: { "formatted": "user_1" }
|
||||
messages: [{
|
||||
user_id: "user_id_1"
|
||||
user: { "formatted": "user_1" }
|
||||
content: "foo"
|
||||
}, {
|
||||
user_id: "user_id_2"
|
||||
user: { "formatted": "user_2" }
|
||||
content: "bar"
|
||||
}]
|
||||
},
|
||||
thread2: {
|
||||
messages: [{
|
||||
user_id: "user_id_1"
|
||||
user: { "formatted": "user_1" }
|
||||
content: "baz"
|
||||
}]
|
||||
}
|
||||
}
|
||||
done()
|
||||
|
||||
it "should only need to look up each user once", (done) ->
|
||||
@ChatController._injectUserInfoIntoThreads [{
|
||||
messages: [{
|
||||
user_id: "user_id_1"
|
||||
content: "foo"
|
||||
}, {
|
||||
user_id: "user_id_1"
|
||||
content: "bar"
|
||||
}]
|
||||
}], (error, threads) =>
|
||||
@UserInfoManager.getPersonalInfo.calledOnce.should.equal true
|
||||
done()
|
||||
@@ -1,284 +0,0 @@
|
||||
should = require('chai').should()
|
||||
SandboxedModule = require('sandboxed-module')
|
||||
assert = require('assert')
|
||||
path = require('path')
|
||||
sinon = require('sinon')
|
||||
modulePath = path.join __dirname, "../../../../app/js/Features/Comments/CommentsController"
|
||||
expect = require("chai").expect
|
||||
|
||||
describe "CommentsController", ->
|
||||
beforeEach ->
|
||||
@user_id = 'mock-user-id'
|
||||
@settings = {}
|
||||
@ChatApiHandler = {}
|
||||
@EditorRealTimeController =
|
||||
emitToRoom:sinon.stub()
|
||||
@AuthenticationController =
|
||||
getLoggedInUserId: sinon.stub().returns(@user_id)
|
||||
@CommentsController = SandboxedModule.require modulePath, requires:
|
||||
"settings-sharelatex": @settings
|
||||
"logger-sharelatex": log: ->
|
||||
"../Chat/ChatApiHandler": @ChatApiHandler
|
||||
"../Editor/EditorRealTimeController": @EditorRealTimeController
|
||||
'../Authentication/AuthenticationController': @AuthenticationController
|
||||
'../User/UserInfoManager': @UserInfoManager = {}
|
||||
'../User/UserInfoController': @UserInfoController = {}
|
||||
"../DocumentUpdater/DocumentUpdaterHandler": @DocumentUpdaterHandler = {}
|
||||
@req = {}
|
||||
@res =
|
||||
json: sinon.stub()
|
||||
send: sinon.stub()
|
||||
|
||||
describe "sendComment", ->
|
||||
beforeEach ->
|
||||
@req.params =
|
||||
project_id: @project_id = "mock-project-id"
|
||||
thread_id: @thread_id = "mock-thread-id"
|
||||
@req.body =
|
||||
content: @content = "message-content"
|
||||
@UserInfoManager.getPersonalInfo = sinon.stub().yields(null, @user = {"unformatted": "user"})
|
||||
@UserInfoController.formatPersonalInfo = sinon.stub().returns(@formatted_user = {"formatted": "user"})
|
||||
@ChatApiHandler.sendComment = sinon.stub().yields(null, @message = {"mock": "message", user_id: @user_id})
|
||||
@CommentsController.sendComment @req, @res
|
||||
|
||||
it "should look up the user", ->
|
||||
@UserInfoManager.getPersonalInfo
|
||||
.calledWith(@user_id)
|
||||
.should.equal true
|
||||
|
||||
it "should format and inject the user into the comment", ->
|
||||
@UserInfoController.formatPersonalInfo
|
||||
.calledWith(@user)
|
||||
.should.equal true
|
||||
@message.user.should.deep.equal @formatted_user
|
||||
|
||||
it "should tell the chat handler about the message", ->
|
||||
@ChatApiHandler.sendComment
|
||||
.calledWith(@project_id, @thread_id, @user_id, @content)
|
||||
.should.equal true
|
||||
|
||||
it "should tell the editor real time controller about the update with the data from the chat handler", ->
|
||||
@EditorRealTimeController.emitToRoom
|
||||
.calledWith(@project_id, "new-comment", @thread_id, @message)
|
||||
.should.equal true
|
||||
|
||||
it "should return a 204 status code", ->
|
||||
@res.send.calledWith(204).should.equal true
|
||||
|
||||
describe "getThreads", ->
|
||||
beforeEach ->
|
||||
@req.params =
|
||||
project_id: @project_id = "mock-project-id"
|
||||
@ChatApiHandler.getThreads = sinon.stub().yields(null, @threads = {"mock", "threads"})
|
||||
@CommentsController._injectUserInfoIntoThreads = sinon.stub().yields(null, @threads)
|
||||
@CommentsController.getThreads @req, @res
|
||||
|
||||
it "should ask the chat handler about the request", ->
|
||||
@ChatApiHandler.getThreads
|
||||
.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
it "should inject the user details into the threads", ->
|
||||
@CommentsController._injectUserInfoIntoThreads
|
||||
.calledWith(@threads)
|
||||
.should.equal true
|
||||
|
||||
it "should return the messages", ->
|
||||
@res.json.calledWith(@threads).should.equal true
|
||||
|
||||
describe "resolveThread", ->
|
||||
beforeEach ->
|
||||
@req.params =
|
||||
project_id: @project_id = "mock-project-id"
|
||||
thread_id: @thread_id = "mock-thread-id"
|
||||
@ChatApiHandler.resolveThread = sinon.stub().yields()
|
||||
@UserInfoManager.getPersonalInfo = sinon.stub().yields(null, @user = {"unformatted": "user"})
|
||||
@UserInfoController.formatPersonalInfo = sinon.stub().returns(@formatted_user = {"formatted": "user"})
|
||||
@CommentsController.resolveThread @req, @res
|
||||
|
||||
it "should ask the chat handler to resolve the thread", ->
|
||||
@ChatApiHandler.resolveThread
|
||||
.calledWith(@project_id, @thread_id)
|
||||
.should.equal true
|
||||
|
||||
it "should look up the user", ->
|
||||
@UserInfoManager.getPersonalInfo
|
||||
.calledWith(@user_id)
|
||||
.should.equal true
|
||||
|
||||
it "should tell the client the comment was resolved", ->
|
||||
@EditorRealTimeController.emitToRoom
|
||||
.calledWith(@project_id, "resolve-thread", @thread_id, @formatted_user)
|
||||
.should.equal true
|
||||
|
||||
it "should return a success code", ->
|
||||
@res.send.calledWith(204).should.equal
|
||||
|
||||
describe "reopenThread", ->
|
||||
beforeEach ->
|
||||
@req.params =
|
||||
project_id: @project_id = "mock-project-id"
|
||||
thread_id: @thread_id = "mock-thread-id"
|
||||
@ChatApiHandler.reopenThread = sinon.stub().yields()
|
||||
@CommentsController.reopenThread @req, @res
|
||||
|
||||
it "should ask the chat handler to reopen the thread", ->
|
||||
@ChatApiHandler.reopenThread
|
||||
.calledWith(@project_id, @thread_id)
|
||||
.should.equal true
|
||||
|
||||
it "should tell the client the comment was resolved", ->
|
||||
@EditorRealTimeController.emitToRoom
|
||||
.calledWith(@project_id, "reopen-thread", @thread_id)
|
||||
.should.equal true
|
||||
|
||||
it "should return a success code", ->
|
||||
@res.send.calledWith(204).should.equal
|
||||
|
||||
describe "deleteThread", ->
|
||||
beforeEach ->
|
||||
@req.params =
|
||||
project_id: @project_id = "mock-project-id"
|
||||
doc_id: @doc_id = "mock-doc-id"
|
||||
thread_id: @thread_id = "mock-thread-id"
|
||||
@DocumentUpdaterHandler.deleteThread = sinon.stub().yields()
|
||||
@ChatApiHandler.deleteThread = sinon.stub().yields()
|
||||
@CommentsController.deleteThread @req, @res
|
||||
|
||||
it "should ask the doc udpater to delete the thread", ->
|
||||
@DocumentUpdaterHandler.deleteThread
|
||||
.calledWith(@project_id, @doc_id, @thread_id)
|
||||
.should.equal true
|
||||
|
||||
it "should ask the chat handler to delete the thread", ->
|
||||
@ChatApiHandler.deleteThread
|
||||
.calledWith(@project_id, @thread_id)
|
||||
.should.equal true
|
||||
|
||||
it "should tell the client the thread was deleted", ->
|
||||
@EditorRealTimeController.emitToRoom
|
||||
.calledWith(@project_id, "delete-thread", @thread_id)
|
||||
.should.equal true
|
||||
|
||||
it "should return a success code", ->
|
||||
@res.send.calledWith(204).should.equal
|
||||
|
||||
describe "editMessage", ->
|
||||
beforeEach ->
|
||||
@req.params =
|
||||
project_id: @project_id = "mock-project-id"
|
||||
thread_id: @thread_id = "mock-thread-id"
|
||||
message_id: @message_id = "mock-thread-id"
|
||||
@req.body =
|
||||
content: @content = "mock-content"
|
||||
@ChatApiHandler.editMessage = sinon.stub().yields()
|
||||
@CommentsController.editMessage @req, @res
|
||||
|
||||
it "should ask the chat handler to edit the comment", ->
|
||||
@ChatApiHandler.editMessage
|
||||
.calledWith(@project_id, @thread_id, @message_id, @content)
|
||||
.should.equal true
|
||||
|
||||
it "should tell the client the comment was edited", ->
|
||||
@EditorRealTimeController.emitToRoom
|
||||
.calledWith(@project_id, "edit-message", @thread_id, @message_id, @content)
|
||||
.should.equal true
|
||||
|
||||
it "should return a success code", ->
|
||||
@res.send.calledWith(204).should.equal
|
||||
|
||||
describe "deleteMessage", ->
|
||||
beforeEach ->
|
||||
@req.params =
|
||||
project_id: @project_id = "mock-project-id"
|
||||
thread_id: @thread_id = "mock-thread-id"
|
||||
message_id: @message_id = "mock-thread-id"
|
||||
@ChatApiHandler.deleteMessage = sinon.stub().yields()
|
||||
@CommentsController.deleteMessage @req, @res
|
||||
|
||||
it "should ask the chat handler to deleted the message", ->
|
||||
@ChatApiHandler.deleteMessage
|
||||
.calledWith(@project_id, @thread_id, @message_id)
|
||||
.should.equal true
|
||||
|
||||
it "should tell the client the message was deleted", ->
|
||||
@EditorRealTimeController.emitToRoom
|
||||
.calledWith(@project_id, "delete-message", @thread_id, @message_id)
|
||||
.should.equal true
|
||||
|
||||
it "should return a success code", ->
|
||||
@res.send.calledWith(204).should.equal
|
||||
|
||||
describe "_injectUserInfoIntoThreads", ->
|
||||
beforeEach ->
|
||||
@users = {
|
||||
"user_id_1": {
|
||||
"mock": "user_1"
|
||||
}
|
||||
"user_id_2": {
|
||||
"mock": "user_2"
|
||||
}
|
||||
}
|
||||
@UserInfoManager.getPersonalInfo = (user_id, callback) =>
|
||||
return callback(null, @users[user_id])
|
||||
sinon.spy @UserInfoManager, "getPersonalInfo"
|
||||
@UserInfoController.formatPersonalInfo = (user) ->
|
||||
return { "formatted": user["mock"] }
|
||||
|
||||
it "should inject a user object into messaged and resolved data", (done) ->
|
||||
@CommentsController._injectUserInfoIntoThreads {
|
||||
thread1: {
|
||||
resolved: true
|
||||
resolved_by_user_id: "user_id_1"
|
||||
messages: [{
|
||||
user_id: "user_id_1"
|
||||
content: "foo"
|
||||
}, {
|
||||
user_id: "user_id_2"
|
||||
content: "bar"
|
||||
}]
|
||||
},
|
||||
thread2: {
|
||||
messages: [{
|
||||
user_id: "user_id_1"
|
||||
content: "baz"
|
||||
}]
|
||||
}
|
||||
}, (error, threads) ->
|
||||
expect(threads).to.deep.equal {
|
||||
thread1: {
|
||||
resolved: true
|
||||
resolved_by_user_id: "user_id_1"
|
||||
resolved_by_user: { "formatted": "user_1" }
|
||||
messages: [{
|
||||
user_id: "user_id_1"
|
||||
user: { "formatted": "user_1" }
|
||||
content: "foo"
|
||||
}, {
|
||||
user_id: "user_id_2"
|
||||
user: { "formatted": "user_2" }
|
||||
content: "bar"
|
||||
}]
|
||||
},
|
||||
thread2: {
|
||||
messages: [{
|
||||
user_id: "user_id_1"
|
||||
user: { "formatted": "user_1" }
|
||||
content: "baz"
|
||||
}]
|
||||
}
|
||||
}
|
||||
done()
|
||||
|
||||
it "should only need to look up each user once", (done) ->
|
||||
@CommentsController._injectUserInfoIntoThreads [{
|
||||
messages: [{
|
||||
user_id: "user_id_1"
|
||||
content: "foo"
|
||||
}, {
|
||||
user_id: "user_id_1"
|
||||
content: "bar"
|
||||
}]
|
||||
}], (error, threads) =>
|
||||
@UserInfoManager.getPersonalInfo.calledOnce.should.equal true
|
||||
done()
|
||||
@@ -42,7 +42,7 @@ describe "CompileController", ->
|
||||
"request": @request = sinon.stub()
|
||||
"../../models/Project": Project: @Project = {}
|
||||
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
|
||||
"../../infrastructure/Metrics": @Metrics = { inc: sinon.stub() }
|
||||
"metrics-sharelatex": @Metrics = { inc: sinon.stub() }
|
||||
"./CompileManager":@CompileManager
|
||||
"../User/UserGetter":@UserGetter
|
||||
"./ClsiManager": @ClsiManager
|
||||
|
||||
@@ -23,7 +23,7 @@ describe "CompileManager", ->
|
||||
"../User/UserGetter": @UserGetter = {}
|
||||
"./ClsiManager": @ClsiManager = {}
|
||||
"../../infrastructure/RateLimiter": @ratelimiter
|
||||
"../../infrastructure/Metrics": @Metrics =
|
||||
"metrics-sharelatex": @Metrics =
|
||||
Timer: class Timer
|
||||
done: sinon.stub()
|
||||
inc: sinon.stub()
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ describe 'DocumentUpdaterHandler', ->
|
||||
"../../models/Project": Project: @Project={}
|
||||
'../../Features/Project/ProjectLocator':{}
|
||||
'redis-sharelatex' : createClient: () => @rclient
|
||||
"../../infrastructure/Metrics":
|
||||
"metrics-sharelatex":
|
||||
Timer:->
|
||||
done:->
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ describe "ProjectDownloadsController", ->
|
||||
@ProjectDownloadsController = SandboxedModule.require modulePath, requires:
|
||||
"./ProjectZipStreamManager" : @ProjectZipStreamManager = {}
|
||||
"../../models/Project" : Project: @Project = {}
|
||||
"../../infrastructure/Metrics": @metrics = {}
|
||||
"metrics-sharelatex": @metrics = {}
|
||||
"logger-sharelatex" : @logger = {log: sinon.stub()}
|
||||
"../DocumentUpdater/DocumentUpdaterHandler": @DocumentUpdaterHandler
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ describe "EditorController", ->
|
||||
"settings-sharelatex":@settings
|
||||
'../Dropbox/DropboxProjectLinker':@dropboxProjectLinker
|
||||
'./EditorRealTimeController':@EditorRealTimeController = {}
|
||||
"../../infrastructure/Metrics": @Metrics = { inc: sinon.stub() }
|
||||
"metrics-sharelatex": @Metrics = { inc: sinon.stub() }
|
||||
"../TrackChanges/TrackChangesManager": @TrackChangesManager = {}
|
||||
"../../infrastructure/LockManager":@LockManager
|
||||
'redis-sharelatex':createClient:-> auth:->
|
||||
|
||||
@@ -15,7 +15,7 @@ describe "EditorHttpController", ->
|
||||
"./EditorRealTimeController": @EditorRealTimeController = {}
|
||||
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
|
||||
"./EditorController": @EditorController = {}
|
||||
'../../infrastructure/Metrics': @Metrics = {inc: sinon.stub()}
|
||||
'metrics-sharelatex': @Metrics = {inc: sinon.stub()}
|
||||
"../Collaborators/CollaboratorsHandler": @CollaboratorsHandler = {}
|
||||
"../Collaborators/CollaboratorsInviteHandler": @CollaboratorsInviteHandler = {}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ describe "EmailSender", ->
|
||||
log:->
|
||||
warn:->
|
||||
err:->
|
||||
"../../infrastructure/Metrics": inc:->
|
||||
"metrics-sharelatex": inc:->
|
||||
|
||||
|
||||
|
||||
@@ -51,17 +51,19 @@ describe "EmailSender", ->
|
||||
it "should set the properties on the email to send", (done)->
|
||||
@sesClient.sendMail.callsArgWith(1)
|
||||
|
||||
@sender.sendEmail @opts, =>
|
||||
@sender.sendEmail @opts, (err) =>
|
||||
expect(err).to.not.exist
|
||||
args = @sesClient.sendMail.args[0][0]
|
||||
args.html.should.equal @opts.html
|
||||
args.to.should.equal @opts.to
|
||||
args.subject.should.equal @opts.subject
|
||||
done()
|
||||
|
||||
it "should return the error", (done)->
|
||||
it "should return a non-specific error", (done)->
|
||||
@sesClient.sendMail.callsArgWith(1, "error")
|
||||
@sender.sendEmail {}, (err)=>
|
||||
err.should.equal "error"
|
||||
err.should.exist
|
||||
err.toString().should.equal 'Error: Cannot send email'
|
||||
done()
|
||||
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ describe "FileStoreHandler", ->
|
||||
@writeStream =
|
||||
my:"writeStream"
|
||||
on: (type, cb)->
|
||||
if type == "end"
|
||||
cb()
|
||||
if type == "response"
|
||||
cb({statusCode: 200})
|
||||
@readStream = {my:"readStream", on: sinon.stub()}
|
||||
@request = sinon.stub()
|
||||
@settings = apis:{filestore:{url:"http//filestore.sharelatex.test"}}
|
||||
@@ -79,6 +79,16 @@ describe "FileStoreHandler", ->
|
||||
@handler._buildUrl.calledWith(@project_id, @file_id).should.equal true
|
||||
done()
|
||||
|
||||
it 'should callback with null', (done) ->
|
||||
@fs.createReadStream.returns
|
||||
pipe:->
|
||||
on: (type, cb)->
|
||||
if type == "end"
|
||||
cb()
|
||||
@handler.uploadFileFromDisk @project_id, @file_id, @fsPath, (err) =>
|
||||
expect(err).to.not.exist
|
||||
done()
|
||||
|
||||
describe "symlink", ->
|
||||
it "should not read file if it is symlink", (done)->
|
||||
@isSafeOnFileSystem = false
|
||||
@@ -86,6 +96,30 @@ describe "FileStoreHandler", ->
|
||||
@fs.createReadStream.called.should.equal false
|
||||
done()
|
||||
|
||||
describe "symlink", ->
|
||||
it "should not read file stat returns nothing", (done)->
|
||||
@fs.lstat = sinon.stub().callsArgWith(1, null, null)
|
||||
@handler.uploadFileFromDisk @project_id, @file_id, @fsPath, =>
|
||||
@fs.createReadStream.called.should.equal false
|
||||
done()
|
||||
|
||||
describe "when upload fails", ->
|
||||
beforeEach ->
|
||||
@writeStream.on = (type, cb) ->
|
||||
if type == "response"
|
||||
cb({statusCode: 500})
|
||||
|
||||
it 'should callback with an error', (done) ->
|
||||
@fs.createReadStream.returns
|
||||
pipe:->
|
||||
on: (type, cb)->
|
||||
if type == "end"
|
||||
cb()
|
||||
@handler.uploadFileFromDisk @project_id, @file_id, @fsPath, (err) =>
|
||||
expect(err).to.exist
|
||||
expect(err).to.be.instanceof Error
|
||||
done()
|
||||
|
||||
describe "deleteFile", ->
|
||||
|
||||
it "should send a delete request to filestore api", (done)->
|
||||
|
||||
@@ -20,6 +20,7 @@ describe 'Project api controller', ->
|
||||
session:
|
||||
destroy:sinon.stub()
|
||||
@res = {}
|
||||
@next = sinon.stub()
|
||||
@projDetails = {name:"something"}
|
||||
|
||||
|
||||
@@ -34,9 +35,7 @@ describe 'Project api controller', ->
|
||||
@controller.getProjectDetails @req, @res
|
||||
|
||||
|
||||
it "should send a 500 if there is an error", (done)->
|
||||
it "should send a 500 if there is an error", ()->
|
||||
@ProjectDetailsHandler.getDetails.callsArgWith(1, "error")
|
||||
@res.sendStatus = (resCode)=>
|
||||
resCode.should.equal 500
|
||||
done()
|
||||
@controller.getProjectDetails @req, @res
|
||||
@controller.getProjectDetails @req, @res, @next
|
||||
@next.calledWith("error").should.equal true
|
||||
|
||||
@@ -13,7 +13,7 @@ describe "ProjectController", ->
|
||||
@project_id = "123213jlkj9kdlsaj"
|
||||
|
||||
@user =
|
||||
_id:"!£123213kjljkl"
|
||||
_id:"588f3ddae8ebc1bac07c9fa4"
|
||||
first_name: "bjkdsjfk"
|
||||
@settings =
|
||||
apis:
|
||||
@@ -65,7 +65,7 @@ describe "ProjectController", ->
|
||||
"logger-sharelatex":
|
||||
log:->
|
||||
err:->
|
||||
"../../infrastructure/Metrics":
|
||||
"metrics-sharelatex":
|
||||
Timer:->
|
||||
done:->
|
||||
inc:->
|
||||
@@ -302,7 +302,7 @@ describe "ProjectController", ->
|
||||
name:"my proj"
|
||||
_id:"213123kjlkj"
|
||||
@user =
|
||||
_id:"123kj21k3lj"
|
||||
_id: "588f3ddae8ebc1bac07c9fa4"
|
||||
ace:
|
||||
fontSize:"massive"
|
||||
theme:"sexy"
|
||||
@@ -381,3 +381,11 @@ describe "ProjectController", ->
|
||||
opts.showTrackChangesOnboarding.should.equal false
|
||||
done()
|
||||
@ProjectController.loadEditor @req, @res
|
||||
|
||||
it "should set showTrackChangesOnboarding = false if the user signed up after release", (done) ->
|
||||
@AuthenticationController.getLoggedInUserId.returns("58c11a608ba0d6e49e8ce5d5")
|
||||
@AnalyticsManager.getLastOccurance.yields(null, null)
|
||||
@res.render = (pageName, opts)=>
|
||||
opts.showTrackChangesOnboarding.should.equal false
|
||||
done()
|
||||
@ProjectController.loadEditor @req, @res
|
||||
|
||||
@@ -50,9 +50,10 @@ describe 'ProjectCreationHandler', ->
|
||||
'./ProjectEntityHandler':@ProjectEntityHandler
|
||||
"settings-sharelatex": @Settings = {}
|
||||
'logger-sharelatex': {log:->}
|
||||
"../../infrastructure/Metrics": inc:->
|
||||
|
||||
|
||||
"metrics-sharelatex": {
|
||||
inc: ()->,
|
||||
timeAsyncMethod: ()->
|
||||
}
|
||||
|
||||
describe 'Creating a Blank project', ->
|
||||
beforeEach ->
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
should = require('chai').should()
|
||||
modulePath = "../../../../app/js/Features/Project/ProjectDetailsHandler"
|
||||
Errors = require "../../../../app/js/Features/Errors/Errors"
|
||||
SandboxedModule = require('sandboxed-module')
|
||||
sinon = require('sinon')
|
||||
assert = require("chai").assert
|
||||
@@ -48,6 +49,13 @@ describe 'ProjectDetailsHandler', ->
|
||||
assert.equal(details.something, undefined)
|
||||
done()
|
||||
|
||||
it "should return an error for a non-existent project", (done)->
|
||||
@ProjectGetter.getProject.callsArg(2, null, null)
|
||||
err = new Errors.NotFoundError("project not found")
|
||||
@handler.getDetails "0123456789012345678901234", (error, details) =>
|
||||
err.should.eql error
|
||||
done()
|
||||
|
||||
it "should return the error", (done)->
|
||||
error = "some error"
|
||||
@ProjectGetter.getProject.callsArgWith(2, error)
|
||||
|
||||
@@ -9,7 +9,7 @@ describe 'ProjectDuplicator', ->
|
||||
@level2folder =
|
||||
name: "level2folderName"
|
||||
_id:"level2folderId"
|
||||
docs:[@doc2 = {_id: "doc2_id", name:"level2folderDocName"}]
|
||||
docs:[@doc2 = {_id: "doc2_id", name:"level2folderDocName"}, undefined]
|
||||
folders:[]
|
||||
fileRefs:[{name:"file2", _id:"file2"}]
|
||||
@level1folder =
|
||||
@@ -17,12 +17,12 @@ describe 'ProjectDuplicator', ->
|
||||
_id:"level1folderId"
|
||||
docs:[@doc1 = {_id: "doc1_id", name:"level1folderDocName"}]
|
||||
folders:[@level2folder]
|
||||
fileRefs:[{name:"file1", _id:"file1"}]
|
||||
fileRefs:[{name:"file1", _id:"file1"}, null]
|
||||
@rootFolder =
|
||||
name:"rootFolder"
|
||||
_id:"rootFolderId"
|
||||
docs:[@doc0 = {_id: "doc0_id", name:"rootDocHere"}]
|
||||
folders:[@level1folder]
|
||||
folders:[@level1folder, {}]
|
||||
fileRefs:[{name:"file0", _id:"file0"}]
|
||||
@project =
|
||||
_id: @old_project_id = "this_is_the_old_project_id"
|
||||
@@ -117,7 +117,7 @@ describe 'ProjectDuplicator', ->
|
||||
@projectOptionsHandler.setCompiler.calledWith(@stubbedNewProject._id, @project.compiler).should.equal true
|
||||
done()
|
||||
|
||||
it 'should use the same root docccccccc', (done)->
|
||||
it 'should use the same root doc', (done)->
|
||||
@entityHandler.addDocWithProject.callsArgWith(4, null, @rootFolder.docs[0])
|
||||
@duplicator.duplicate @owner, @old_project_id, "", (err, newProject)=>
|
||||
@entityHandler.setRootDoc.calledWith(@stubbedNewProject._id, @rootFolder.docs[0]._id).should.equal true
|
||||
|
||||
@@ -16,6 +16,7 @@ describe "ProjectGetter", ->
|
||||
projects: {}
|
||||
users: {}
|
||||
ObjectId: ObjectId
|
||||
"metrics-sharelatex": timeAsyncMethod: sinon.stub()
|
||||
"../../models/Project": Project: @Project = {}
|
||||
"../Collaborators/CollaboratorsHandler": @CollaboratorsHandler = {}
|
||||
"logger-sharelatex":
|
||||
|
||||
@@ -17,7 +17,7 @@ file1 = name:"file1", _id:"dsa9lkdsad"
|
||||
subSubFile = name:"subSubFile", _id:"d1d2dk"
|
||||
subSubDoc = name:"subdoc.txt", _id:"321dmdwi"
|
||||
secondSubFolder = name:"secondSubFolder", _id:"dsa3e23", docs:[subSubDoc], fileRefs:[subSubFile], folders:[]
|
||||
subFolder = name:"subFolder", _id:"dsadsa93", folders:[secondSubFolder], docs:[], fileRefs:[]
|
||||
subFolder = name:"subFolder", _id:"dsadsa93", folders:[secondSubFolder, null], docs:[], fileRefs:[]
|
||||
subFolder1 = name:"subFolder1", _id:"123asdjoij"
|
||||
|
||||
rootFolder =
|
||||
|
||||
@@ -1030,3 +1030,35 @@ describe "RecurlyWrapper", ->
|
||||
@call (err, result) =>
|
||||
expect(err).to.be.instanceof Error
|
||||
done()
|
||||
|
||||
describe "listAccountActiveSubscriptions", ->
|
||||
beforeEach ->
|
||||
@user_id = "mock-user-id"
|
||||
@callback = sinon.stub()
|
||||
@RecurlyWrapper.apiRequest = sinon.stub().yields(null, @response = {"mock": "response"}, @body = "<mock body/>")
|
||||
@RecurlyWrapper._parseSubscriptionsXml = sinon.stub().yields(null, @subscriptions = ["mock", "subscriptions"])
|
||||
|
||||
describe "with an account", ->
|
||||
beforeEach ->
|
||||
@RecurlyWrapper.listAccountActiveSubscriptions @user_id, @callback
|
||||
|
||||
it "should send a request to Recurly", ->
|
||||
@RecurlyWrapper.apiRequest
|
||||
.calledWith({
|
||||
url: "accounts/#{@user_id}/subscriptions"
|
||||
qs:
|
||||
state: "active"
|
||||
expect404: true
|
||||
})
|
||||
.should.equal true
|
||||
|
||||
it "should return the subscriptions", ->
|
||||
@callback.calledWith(null, @subscriptions).should.equal true
|
||||
|
||||
describe "without an account", ->
|
||||
beforeEach ->
|
||||
@response.statusCode = 404
|
||||
@RecurlyWrapper.listAccountActiveSubscriptions @user_id, @callback
|
||||
|
||||
it "should return an empty array of subscriptions", ->
|
||||
@callback.calledWith(null, []).should.equal true
|
||||
@@ -17,8 +17,7 @@ mockSubscriptions =
|
||||
account:
|
||||
account_code: "user-123"
|
||||
|
||||
describe "SubscriptionController sanboxed", ->
|
||||
|
||||
describe "SubscriptionController", ->
|
||||
beforeEach ->
|
||||
@user = {email:"tom@yahoo.com", _id: 'one', signUpDate: new Date('2000-10-01')}
|
||||
@activeRecurlySubscription = mockSubscriptions["subscription-123-active"]
|
||||
@@ -150,6 +149,7 @@ describe "SubscriptionController sanboxed", ->
|
||||
describe "paymentPage", ->
|
||||
beforeEach ->
|
||||
@req.headers = {}
|
||||
@SubscriptionHandler.validateNoSubscriptionInRecurly = sinon.stub().yields(null, true)
|
||||
@GeoIpLookup.getCurrencyCode.callsArgWith(1, null, @stubbedCurrencyCode)
|
||||
|
||||
describe "with a user without a subscription", ->
|
||||
@@ -209,6 +209,16 @@ describe "SubscriptionController sanboxed", ->
|
||||
opts.currency.should.equal @stubbedCurrencyCode
|
||||
done()
|
||||
@SubscriptionController.paymentPage @req, @res
|
||||
|
||||
describe "with a recurly subscription already", ->
|
||||
it "should redirect to the subscription dashboard", (done)->
|
||||
@LimitationsManager.userHasSubscription.callsArgWith(1, null, false)
|
||||
@SubscriptionHandler.validateNoSubscriptionInRecurly = sinon.stub().yields(null, false)
|
||||
@res.redirect = (url)=>
|
||||
url.should.equal "/user/subscription"
|
||||
done()
|
||||
@SubscriptionController.paymentPage(@req, @res)
|
||||
|
||||
|
||||
describe "successful_subscription", ->
|
||||
beforeEach (done) ->
|
||||
|
||||
@@ -16,7 +16,7 @@ mockRecurlySubscriptions =
|
||||
account:
|
||||
account_code: "user-123"
|
||||
|
||||
describe "Subscription Handler sanboxed", ->
|
||||
describe "SubscriptionHandler", ->
|
||||
|
||||
beforeEach ->
|
||||
@Settings =
|
||||
@@ -33,7 +33,7 @@ describe "Subscription Handler sanboxed", ->
|
||||
@activeRecurlySubscription = mockRecurlySubscriptions["subscription-123-active"]
|
||||
@User = {}
|
||||
@user =
|
||||
_id: "user_id_here_"
|
||||
_id: @user_id = "user_id_here_"
|
||||
@subscription =
|
||||
recurlySubscription_id: @activeRecurlySubscription.uuid
|
||||
@RecurlyWrapper =
|
||||
@@ -77,23 +77,33 @@ describe "Subscription Handler sanboxed", ->
|
||||
|
||||
|
||||
describe "createSubscription", ->
|
||||
beforeEach (done) ->
|
||||
beforeEach ->
|
||||
@callback = sinon.stub()
|
||||
@subscriptionDetails =
|
||||
cvv:"123"
|
||||
number:"12345"
|
||||
@recurly_token_id = "45555666"
|
||||
@SubscriptionHandler.createSubscription(@user, @subscriptionDetails, @recurly_token_id, done)
|
||||
@SubscriptionHandler.validateNoSubscriptionInRecurly = sinon.stub().yields(null, true)
|
||||
|
||||
it "should create the subscription with the wrapper", (done)->
|
||||
@RecurlyWrapper.createSubscription.calledWith(@user, @subscriptionDetails, @recurly_token_id).should.equal true
|
||||
done()
|
||||
describe "successfully", ->
|
||||
beforeEach ->
|
||||
@SubscriptionHandler.createSubscription(@user, @subscriptionDetails, @recurly_token_id, @callback)
|
||||
|
||||
it "should sync the subscription to the user", (done)->
|
||||
@SubscriptionUpdater.syncSubscription.calledOnce.should.equal true
|
||||
@SubscriptionUpdater.syncSubscription.args[0][0].should.deep.equal @activeRecurlySubscription
|
||||
@SubscriptionUpdater.syncSubscription.args[0][1].should.deep.equal @user._id
|
||||
done()
|
||||
it "should create the subscription with the wrapper", ->
|
||||
@RecurlyWrapper.createSubscription.calledWith(@user, @subscriptionDetails, @recurly_token_id).should.equal true
|
||||
|
||||
it "should sync the subscription to the user", ->
|
||||
@SubscriptionUpdater.syncSubscription.calledOnce.should.equal true
|
||||
@SubscriptionUpdater.syncSubscription.args[0][0].should.deep.equal @activeRecurlySubscription
|
||||
@SubscriptionUpdater.syncSubscription.args[0][1].should.deep.equal @user._id
|
||||
|
||||
describe "when there is already a subscription in Recurly", ->
|
||||
beforeEach ->
|
||||
@SubscriptionHandler.validateNoSubscriptionInRecurly = sinon.stub().yields(null, false)
|
||||
@SubscriptionHandler.createSubscription(@user, @subscriptionDetails, @recurly_token_id, @callback)
|
||||
|
||||
it "should return an error", ->
|
||||
@callback.calledWith(new Error("user already has subscription in recurly"))
|
||||
|
||||
describe "updateSubscription", ->
|
||||
describe "with a user with a subscription", ->
|
||||
@@ -145,8 +155,6 @@ describe "Subscription Handler sanboxed", ->
|
||||
updateOptions = @RecurlyWrapper.updateSubscription.args[0][1]
|
||||
updateOptions.plan_code.should.equal @plan_code
|
||||
|
||||
|
||||
|
||||
describe "cancelSubscription", ->
|
||||
describe "with a user without a subscription", ->
|
||||
beforeEach (done) ->
|
||||
@@ -210,5 +218,39 @@ describe "Subscription Handler sanboxed", ->
|
||||
@SubscriptionUpdater.syncSubscription.args[0][0].should.deep.equal @activeRecurlySubscription
|
||||
@SubscriptionUpdater.syncSubscription.args[0][1].should.deep.equal @user._id
|
||||
|
||||
describe "validateNoSubscriptionInRecurly", ->
|
||||
beforeEach ->
|
||||
@subscriptions = []
|
||||
@RecurlyWrapper.listAccountActiveSubscriptions = sinon.stub().yields(null, @subscriptions)
|
||||
@SubscriptionUpdater.syncSubscription = sinon.stub().yields()
|
||||
@callback = sinon.stub()
|
||||
|
||||
describe "with no subscription in recurly", ->
|
||||
beforeEach ->
|
||||
@subscriptions.push @subscription = { "mock": "subscription" }
|
||||
@SubscriptionHandler.validateNoSubscriptionInRecurly @user_id, @callback
|
||||
|
||||
it "should call RecurlyWrapper.listAccountActiveSubscriptions with the user id", ->
|
||||
@RecurlyWrapper.listAccountActiveSubscriptions
|
||||
.calledWith(@user_id)
|
||||
.should.equal true
|
||||
|
||||
it "should sync the subscription", ->
|
||||
@SubscriptionUpdater.syncSubscription
|
||||
.calledWith(@subscription, @user_id)
|
||||
.should.equal true
|
||||
|
||||
it "should call the callback with valid == false", ->
|
||||
@callback.calledWith(null, false).should.equal true
|
||||
|
||||
describe "with a subscription in recurly", ->
|
||||
beforeEach ->
|
||||
@SubscriptionHandler.validateNoSubscriptionInRecurly @user_id, @callback
|
||||
|
||||
it "should not sync the subscription", ->
|
||||
@SubscriptionUpdater.syncSubscription
|
||||
.called
|
||||
.should.equal false
|
||||
|
||||
it "should call the callback with valid == true", ->
|
||||
@callback.calledWith(null, true).should.equal true
|
||||
|
||||
@@ -14,7 +14,7 @@ describe 'TpdsController', ->
|
||||
'logger-sharelatex':
|
||||
log:->
|
||||
err:->
|
||||
"../../infrastructure/Metrics": inc:->
|
||||
"metrics-sharelatex": inc:->
|
||||
|
||||
@user_id = "dsad29jlkjas"
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ describe 'TpdsUpdateSender', ->
|
||||
'../../models/Project': Project:@Project
|
||||
'request':@request
|
||||
'../Collaborators/CollaboratorsHandler': @CollaboratorsHandler
|
||||
"../../infrastructure/Metrics":
|
||||
"metrics-sharelatex":
|
||||
inc:->
|
||||
|
||||
describe "_enqueue", ->
|
||||
|
||||
@@ -24,7 +24,7 @@ describe 'UpdateMerger :', ->
|
||||
'logger-sharelatex':
|
||||
log: ->
|
||||
err: ->
|
||||
"../../infrastructure/Metrics":
|
||||
"metrics-sharelatex":
|
||||
Timer:->
|
||||
done:->
|
||||
@project_id = "project_id_here"
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
should = require('chai').should()
|
||||
SandboxedModule = require('sandboxed-module')
|
||||
assert = require('assert')
|
||||
sinon = require('sinon')
|
||||
path = require "path"
|
||||
modulePath = path.join __dirname, "../../../../app/js/Features/TrackChanges/RangesManager"
|
||||
expect = require("chai").expect
|
||||
|
||||
describe "RangesManager", ->
|
||||
beforeEach ->
|
||||
@RangesManager = SandboxedModule.require modulePath, requires:
|
||||
"../DocumentUpdater/DocumentUpdaterHandler": @DocumentUpdaterHandler = {}
|
||||
"../Docstore/DocstoreManager": @DocstoreManager = {}
|
||||
"../User/UserInfoManager": @UserInfoManager = {}
|
||||
|
||||
describe "getAllChangesUsers", ->
|
||||
beforeEach ->
|
||||
@project_id = "mock-project-id"
|
||||
@user_id1 = "mock-user-id-1"
|
||||
@user_id1 = "mock-user-id-2"
|
||||
@docs = [{
|
||||
ranges:
|
||||
changes: [{
|
||||
op: { i: "foo", p: 42 }
|
||||
metadata:
|
||||
user_id: @user_id1
|
||||
}, {
|
||||
op: { i: "bar", p: 102 }
|
||||
metadata:
|
||||
user_id: @user_id2
|
||||
}]
|
||||
}, {
|
||||
ranges:
|
||||
changes: [{
|
||||
op: { i: "baz", p: 3 }
|
||||
metadata:
|
||||
user_id: @user_id1
|
||||
}]
|
||||
}]
|
||||
@users = {}
|
||||
@users[@user_id1] = {"mock": "user-1"}
|
||||
@users[@user_id2] = {"mock": "user-2"}
|
||||
@UserInfoManager.getPersonalInfo = (user_id, callback) => callback null, @users[user_id]
|
||||
sinon.spy @UserInfoManager, "getPersonalInfo"
|
||||
@RangesManager.getAllRanges = sinon.stub().yields(null, @docs)
|
||||
|
||||
it "should return an array of unique users", (done) ->
|
||||
@RangesManager.getAllChangesUsers @project_id, (error, users) =>
|
||||
users.should.deep.equal [{"mock": "user-1"}, {"mock": "user-2"}]
|
||||
done()
|
||||
|
||||
it "should only call getPersonalInfo once for each user", (done) ->
|
||||
@RangesManager.getAllChangesUsers @project_id, (error, users) =>
|
||||
@UserInfoManager.getPersonalInfo.calledTwice.should.equal true
|
||||
done()
|
||||
@@ -26,7 +26,7 @@ describe "ArchiveManager", ->
|
||||
@ArchiveManager = SandboxedModule.require modulePath, requires:
|
||||
"child_process": @child
|
||||
"logger-sharelatex": @logger
|
||||
"../../infrastructure/Metrics": @metrics
|
||||
"metrics-sharelatex": @metrics
|
||||
"fs": @fs = {}
|
||||
|
||||
describe "extractZipArchive", ->
|
||||
|
||||
@@ -21,7 +21,7 @@ describe "ProjectUploadController", ->
|
||||
"./ProjectUploadManager" : @ProjectUploadManager = {}
|
||||
"./FileSystemImportManager" : @FileSystemImportManager = {}
|
||||
"logger-sharelatex" : @logger = {log: sinon.stub(), error: sinon.stub(), err:->}
|
||||
"../../infrastructure/Metrics": @metrics
|
||||
"metrics-sharelatex": @metrics
|
||||
'../Authentication/AuthenticationController': @AuthenticationController
|
||||
"fs" : @fs = {}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ describe "UserController", ->
|
||||
"logger-sharelatex":
|
||||
log:->
|
||||
err:->
|
||||
"../../infrastructure/Metrics": inc:->
|
||||
"metrics-sharelatex": inc:->
|
||||
|
||||
@res =
|
||||
send: sinon.stub()
|
||||
|
||||
@@ -21,6 +21,7 @@ describe "UserCreator", ->
|
||||
"../../models/User": User:@UserModel
|
||||
"./UserLocator":@UserLocator
|
||||
"logger-sharelatex":{log:->}
|
||||
'metrics-sharelatex': {timeAsyncMethod: ()->}
|
||||
|
||||
@email = "bob.oswald@gmail.com"
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ describe "UserLocator", ->
|
||||
@user = {_id:"12390i"}
|
||||
@UserLocator = SandboxedModule.require modulePath, requires:
|
||||
"../../infrastructure/mongojs": db: @db = { users: {} }
|
||||
"metrics-sharelatex": timeAsyncMethod: sinon.stub()
|
||||
@db.users =
|
||||
findOne : sinon.stub().callsArgWith(1, null, @user)
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ describe "UserUpdater", ->
|
||||
"logger-sharelatex": log:->
|
||||
"./UserLocator":@UserLocator
|
||||
"../../infrastructure/mongojs":@mongojs
|
||||
"metrics-sharelatex": timeAsyncMethod: sinon.stub()
|
||||
|
||||
@stubbedUser =
|
||||
name:"bob"
|
||||
|
||||
@@ -13,7 +13,7 @@ describe 'LockManager - getting the lock', ->
|
||||
createClient : () =>
|
||||
auth:->
|
||||
"settings-sharelatex":{redis:{}}
|
||||
"./Metrics": inc:->
|
||||
"metrics-sharelatex": inc:->
|
||||
|
||||
@callback = sinon.stub()
|
||||
@doc_id = "doc-id-123"
|
||||
|
||||
@@ -14,7 +14,7 @@ describe 'LockManager - trying the lock', ->
|
||||
auth:->
|
||||
set: @set = sinon.stub()
|
||||
"settings-sharelatex":{redis:{}}
|
||||
"./Metrics": inc:->
|
||||
"metrics-sharelatex": inc:->
|
||||
@callback = sinon.stub()
|
||||
@doc_id = "doc-id-123"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user