`, and ``.
@font-family-monospace: Menlo, Monaco, Consolas, "Courier New", monospace;
@font-family-base: @font-family-sans-serif;
@@ -78,7 +80,7 @@
@headings-font-family: @font-family-serif;
@headings-font-weight: 500;
@headings-line-height: 1.1;
-@headings-color: @gray-darker;
+@headings-color: @gray-dark;
//-- Iconography
diff --git a/services/web/public/stylesheets/style.less b/services/web/public/stylesheets/style.less
index 61d5199773..b3e0c15294 100755
--- a/services/web/public/stylesheets/style.less
+++ b/services/web/public/stylesheets/style.less
@@ -78,6 +78,8 @@
@import "app/subscription.less";
@import "app/sprites.less";
@import "app/invite.less";
+@import "app/review-features-page.less";
+@import "app/error-pages.less";
@import "../js/libs/pdfListView/TextLayer.css";
@import "../js/libs/pdfListView/AnnotationsLayer.css";
diff --git a/services/web/public/touch-icon-192x192.png b/services/web/public/touch-icon-192x192.png
new file mode 100644
index 0000000000..df869be62c
Binary files /dev/null and b/services/web/public/touch-icon-192x192.png differ
diff --git a/services/web/test/UnitTests/coffee/Analytics/AnalyticsControllerTests.coffee b/services/web/test/UnitTests/coffee/Analytics/AnalyticsControllerTests.coffee
new file mode 100644
index 0000000000..2c52b8b5f0
--- /dev/null
+++ b/services/web/test/UnitTests/coffee/Analytics/AnalyticsControllerTests.coffee
@@ -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()
diff --git a/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee b/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee
index 94e930c7b1..f99e8543b1 100644
--- a/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee
@@ -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
diff --git a/services/web/test/UnitTests/coffee/Authorization/AuthorizationManagerTests.coffee b/services/web/test/UnitTests/coffee/Authorization/AuthorizationManagerTests.coffee
index fcacce5164..d779934055 100644
--- a/services/web/test/UnitTests/coffee/Authorization/AuthorizationManagerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Authorization/AuthorizationManagerTests.coffee
@@ -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()
diff --git a/services/web/test/UnitTests/coffee/BetaProgram/BetaProgramHandlerTests.coffee b/services/web/test/UnitTests/coffee/BetaProgram/BetaProgramHandlerTests.coffee
index affa9f38a5..2a1a1b1629 100644
--- a/services/web/test/UnitTests/coffee/BetaProgram/BetaProgramHandlerTests.coffee
+++ b/services/web/test/UnitTests/coffee/BetaProgram/BetaProgramHandlerTests.coffee
@@ -26,7 +26,7 @@ describe 'BetaProgramHandler', ->
log: sinon.stub()
err: sinon.stub()
},
- "../../infrastructure/Metrics": @logger = {
+ "metrics-sharelatex": @logger = {
inc: sinon.stub()
}
diff --git a/services/web/test/UnitTests/coffee/Chat/ChatControllerTests.coffee b/services/web/test/UnitTests/coffee/Chat/ChatControllerTests.coffee
index 851eb47f09..8a7fd757ea 100644
--- a/services/web/test/UnitTests/coffee/Chat/ChatControllerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Chat/ChatControllerTests.coffee
@@ -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
\ No newline at end of file
+ @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()
\ No newline at end of file
diff --git a/services/web/test/UnitTests/coffee/Comments/CommentsControllerTests.coffee b/services/web/test/UnitTests/coffee/Comments/CommentsControllerTests.coffee
deleted file mode 100644
index e55f0d04da..0000000000
--- a/services/web/test/UnitTests/coffee/Comments/CommentsControllerTests.coffee
+++ /dev/null
@@ -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()
\ No newline at end of file
diff --git a/services/web/test/UnitTests/coffee/Compile/CompileControllerTests.coffee b/services/web/test/UnitTests/coffee/Compile/CompileControllerTests.coffee
index 9874b77265..53c713ac42 100644
--- a/services/web/test/UnitTests/coffee/Compile/CompileControllerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Compile/CompileControllerTests.coffee
@@ -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
diff --git a/services/web/test/UnitTests/coffee/Compile/CompileManagerTests.coffee b/services/web/test/UnitTests/coffee/Compile/CompileManagerTests.coffee
index 849e9e8ccc..de56443707 100644
--- a/services/web/test/UnitTests/coffee/Compile/CompileManagerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Compile/CompileManagerTests.coffee
@@ -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()
diff --git a/services/web/test/UnitTests/coffee/DocumentUpdater/DocumentUpdaterHandlerTests.coffee b/services/web/test/UnitTests/coffee/DocumentUpdater/DocumentUpdaterHandlerTests.coffee
index 681915abc6..f5519ffa68 100644
--- a/services/web/test/UnitTests/coffee/DocumentUpdater/DocumentUpdaterHandlerTests.coffee
+++ b/services/web/test/UnitTests/coffee/DocumentUpdater/DocumentUpdaterHandlerTests.coffee
@@ -32,7 +32,7 @@ describe 'DocumentUpdaterHandler', ->
"../../models/Project": Project: @Project={}
'../../Features/Project/ProjectLocator':{}
'redis-sharelatex' : createClient: () => @rclient
- "../../infrastructure/Metrics":
+ "metrics-sharelatex":
Timer:->
done:->
diff --git a/services/web/test/UnitTests/coffee/Downloads/ProjectDownloadsControllerTests.coffee b/services/web/test/UnitTests/coffee/Downloads/ProjectDownloadsControllerTests.coffee
index 135ff8bfa8..7fd0b81ec8 100644
--- a/services/web/test/UnitTests/coffee/Downloads/ProjectDownloadsControllerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Downloads/ProjectDownloadsControllerTests.coffee
@@ -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
diff --git a/services/web/test/UnitTests/coffee/Editor/EditorControllerTests.coffee b/services/web/test/UnitTests/coffee/Editor/EditorControllerTests.coffee
index fd56fbb021..72285a1f44 100644
--- a/services/web/test/UnitTests/coffee/Editor/EditorControllerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Editor/EditorControllerTests.coffee
@@ -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:->
diff --git a/services/web/test/UnitTests/coffee/Editor/EditorHttpControllerTests.coffee b/services/web/test/UnitTests/coffee/Editor/EditorHttpControllerTests.coffee
index 3134cea34b..76079e07ab 100644
--- a/services/web/test/UnitTests/coffee/Editor/EditorHttpControllerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Editor/EditorHttpControllerTests.coffee
@@ -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 = {}
diff --git a/services/web/test/UnitTests/coffee/Email/EmailSenderTests.coffee b/services/web/test/UnitTests/coffee/Email/EmailSenderTests.coffee
index beba91fcb3..84efd2c0ca 100644
--- a/services/web/test/UnitTests/coffee/Email/EmailSenderTests.coffee
+++ b/services/web/test/UnitTests/coffee/Email/EmailSenderTests.coffee
@@ -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()
diff --git a/services/web/test/UnitTests/coffee/FileStore/FileStoreHandlerTests.coffee b/services/web/test/UnitTests/coffee/FileStore/FileStoreHandlerTests.coffee
index caae9c0ae8..01990787e1 100644
--- a/services/web/test/UnitTests/coffee/FileStore/FileStoreHandlerTests.coffee
+++ b/services/web/test/UnitTests/coffee/FileStore/FileStoreHandlerTests.coffee
@@ -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)->
diff --git a/services/web/test/UnitTests/coffee/Project/ProjectApiControllerTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectApiControllerTests.coffee
index 9476a80019..ddf23c0bac 100644
--- a/services/web/test/UnitTests/coffee/Project/ProjectApiControllerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Project/ProjectApiControllerTests.coffee
@@ -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
diff --git a/services/web/test/UnitTests/coffee/Project/ProjectControllerTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectControllerTests.coffee
index ba92046c28..87120deced 100644
--- a/services/web/test/UnitTests/coffee/Project/ProjectControllerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Project/ProjectControllerTests.coffee
@@ -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
diff --git a/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee
index 38a86d1eff..f88d1700fd 100644
--- a/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee
@@ -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 ->
diff --git a/services/web/test/UnitTests/coffee/Project/ProjectDetailsHandlerTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectDetailsHandlerTests.coffee
index b9e8ca27c6..501e48f1a5 100644
--- a/services/web/test/UnitTests/coffee/Project/ProjectDetailsHandlerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Project/ProjectDetailsHandlerTests.coffee
@@ -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)
diff --git a/services/web/test/UnitTests/coffee/Project/ProjectDuplicatorTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectDuplicatorTests.coffee
index 7897ae47c8..a1101cfbe0 100644
--- a/services/web/test/UnitTests/coffee/Project/ProjectDuplicatorTests.coffee
+++ b/services/web/test/UnitTests/coffee/Project/ProjectDuplicatorTests.coffee
@@ -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
diff --git a/services/web/test/UnitTests/coffee/Project/ProjectGetterTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectGetterTests.coffee
index d526929952..601cb78908 100644
--- a/services/web/test/UnitTests/coffee/Project/ProjectGetterTests.coffee
+++ b/services/web/test/UnitTests/coffee/Project/ProjectGetterTests.coffee
@@ -16,6 +16,7 @@ describe "ProjectGetter", ->
projects: {}
users: {}
ObjectId: ObjectId
+ "metrics-sharelatex": timeAsyncMethod: sinon.stub()
"../../models/Project": Project: @Project = {}
"../Collaborators/CollaboratorsHandler": @CollaboratorsHandler = {}
"logger-sharelatex":
diff --git a/services/web/test/UnitTests/coffee/Project/ProjectLocatorTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectLocatorTests.coffee
index 1d982d90af..9257c2e83e 100644
--- a/services/web/test/UnitTests/coffee/Project/ProjectLocatorTests.coffee
+++ b/services/web/test/UnitTests/coffee/Project/ProjectLocatorTests.coffee
@@ -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 =
diff --git a/services/web/test/UnitTests/coffee/Subscription/RecurlyWrapperTests.coffee b/services/web/test/UnitTests/coffee/Subscription/RecurlyWrapperTests.coffee
index c55efdb3c5..d951653310 100644
--- a/services/web/test/UnitTests/coffee/Subscription/RecurlyWrapperTests.coffee
+++ b/services/web/test/UnitTests/coffee/Subscription/RecurlyWrapperTests.coffee
@@ -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 = "")
+ @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
\ No newline at end of file
diff --git a/services/web/test/UnitTests/coffee/Subscription/SubscriptionControllerTests.coffee b/services/web/test/UnitTests/coffee/Subscription/SubscriptionControllerTests.coffee
index 3a43c8988e..b95fba1cdd 100644
--- a/services/web/test/UnitTests/coffee/Subscription/SubscriptionControllerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Subscription/SubscriptionControllerTests.coffee
@@ -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) ->
diff --git a/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee b/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee
index 935ed6d025..1e2cec4bfa 100644
--- a/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee
@@ -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
diff --git a/services/web/test/UnitTests/coffee/ThirdPartyDataStore/TpdsControllerTests.coffee b/services/web/test/UnitTests/coffee/ThirdPartyDataStore/TpdsControllerTests.coffee
index fef915423e..974b2e9329 100644
--- a/services/web/test/UnitTests/coffee/ThirdPartyDataStore/TpdsControllerTests.coffee
+++ b/services/web/test/UnitTests/coffee/ThirdPartyDataStore/TpdsControllerTests.coffee
@@ -14,7 +14,7 @@ describe 'TpdsController', ->
'logger-sharelatex':
log:->
err:->
- "../../infrastructure/Metrics": inc:->
+ "metrics-sharelatex": inc:->
@user_id = "dsad29jlkjas"
diff --git a/services/web/test/UnitTests/coffee/ThirdPartyDataStore/TpdsUpdateSenderTests.coffee b/services/web/test/UnitTests/coffee/ThirdPartyDataStore/TpdsUpdateSenderTests.coffee
index 6e95e4e100..75ca01b88f 100644
--- a/services/web/test/UnitTests/coffee/ThirdPartyDataStore/TpdsUpdateSenderTests.coffee
+++ b/services/web/test/UnitTests/coffee/ThirdPartyDataStore/TpdsUpdateSenderTests.coffee
@@ -42,7 +42,7 @@ describe 'TpdsUpdateSender', ->
'../../models/Project': Project:@Project
'request':@request
'../Collaborators/CollaboratorsHandler': @CollaboratorsHandler
- "../../infrastructure/Metrics":
+ "metrics-sharelatex":
inc:->
describe "_enqueue", ->
diff --git a/services/web/test/UnitTests/coffee/ThirdPartyDataStore/UpdateMergerTests.coffee b/services/web/test/UnitTests/coffee/ThirdPartyDataStore/UpdateMergerTests.coffee
index f1fced4625..1b00f20bde 100644
--- a/services/web/test/UnitTests/coffee/ThirdPartyDataStore/UpdateMergerTests.coffee
+++ b/services/web/test/UnitTests/coffee/ThirdPartyDataStore/UpdateMergerTests.coffee
@@ -24,7 +24,7 @@ describe 'UpdateMerger :', ->
'logger-sharelatex':
log: ->
err: ->
- "../../infrastructure/Metrics":
+ "metrics-sharelatex":
Timer:->
done:->
@project_id = "project_id_here"
diff --git a/services/web/test/UnitTests/coffee/TrackChanges/RangesManagerTests.coffee b/services/web/test/UnitTests/coffee/TrackChanges/RangesManagerTests.coffee
deleted file mode 100644
index b9c95040c1..0000000000
--- a/services/web/test/UnitTests/coffee/TrackChanges/RangesManagerTests.coffee
+++ /dev/null
@@ -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()
\ No newline at end of file
diff --git a/services/web/test/UnitTests/coffee/Uploads/ArchiveManagerTests.coffee b/services/web/test/UnitTests/coffee/Uploads/ArchiveManagerTests.coffee
index eab3d2fcbd..fd6153efae 100644
--- a/services/web/test/UnitTests/coffee/Uploads/ArchiveManagerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Uploads/ArchiveManagerTests.coffee
@@ -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", ->
diff --git a/services/web/test/UnitTests/coffee/Uploads/ProjectUploadControllerTests.coffee b/services/web/test/UnitTests/coffee/Uploads/ProjectUploadControllerTests.coffee
index 764265424c..3049f60fb8 100644
--- a/services/web/test/UnitTests/coffee/Uploads/ProjectUploadControllerTests.coffee
+++ b/services/web/test/UnitTests/coffee/Uploads/ProjectUploadControllerTests.coffee
@@ -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 = {}
diff --git a/services/web/test/UnitTests/coffee/User/UserControllerTests.coffee b/services/web/test/UnitTests/coffee/User/UserControllerTests.coffee
index f2f886a4a6..ecb33495c4 100644
--- a/services/web/test/UnitTests/coffee/User/UserControllerTests.coffee
+++ b/services/web/test/UnitTests/coffee/User/UserControllerTests.coffee
@@ -77,7 +77,7 @@ describe "UserController", ->
"logger-sharelatex":
log:->
err:->
- "../../infrastructure/Metrics": inc:->
+ "metrics-sharelatex": inc:->
@res =
send: sinon.stub()
diff --git a/services/web/test/UnitTests/coffee/User/UserCreatorTests.coffee b/services/web/test/UnitTests/coffee/User/UserCreatorTests.coffee
index 1f04d2ef3c..8470e5621f 100644
--- a/services/web/test/UnitTests/coffee/User/UserCreatorTests.coffee
+++ b/services/web/test/UnitTests/coffee/User/UserCreatorTests.coffee
@@ -21,6 +21,7 @@ describe "UserCreator", ->
"../../models/User": User:@UserModel
"./UserLocator":@UserLocator
"logger-sharelatex":{log:->}
+ 'metrics-sharelatex': {timeAsyncMethod: ()->}
@email = "bob.oswald@gmail.com"
diff --git a/services/web/test/UnitTests/coffee/User/UserLocatorTests.coffee b/services/web/test/UnitTests/coffee/User/UserLocatorTests.coffee
index 33ac702e6f..73c178f934 100644
--- a/services/web/test/UnitTests/coffee/User/UserLocatorTests.coffee
+++ b/services/web/test/UnitTests/coffee/User/UserLocatorTests.coffee
@@ -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)
diff --git a/services/web/test/UnitTests/coffee/User/UserUpdaterTests.coffee b/services/web/test/UnitTests/coffee/User/UserUpdaterTests.coffee
index 7dc67dc661..a6239e2e65 100644
--- a/services/web/test/UnitTests/coffee/User/UserUpdaterTests.coffee
+++ b/services/web/test/UnitTests/coffee/User/UserUpdaterTests.coffee
@@ -21,6 +21,7 @@ describe "UserUpdater", ->
"logger-sharelatex": log:->
"./UserLocator":@UserLocator
"../../infrastructure/mongojs":@mongojs
+ "metrics-sharelatex": timeAsyncMethod: sinon.stub()
@stubbedUser =
name:"bob"
diff --git a/services/web/test/UnitTests/coffee/infrastructure/LockManager/getLockTests.coffee b/services/web/test/UnitTests/coffee/infrastructure/LockManager/getLockTests.coffee
index a7271a59f6..ec0d0d4950 100644
--- a/services/web/test/UnitTests/coffee/infrastructure/LockManager/getLockTests.coffee
+++ b/services/web/test/UnitTests/coffee/infrastructure/LockManager/getLockTests.coffee
@@ -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"
diff --git a/services/web/test/UnitTests/coffee/infrastructure/LockManager/tryLockTests.coffee b/services/web/test/UnitTests/coffee/infrastructure/LockManager/tryLockTests.coffee
index 9f8d680b2d..98f624c70b 100644
--- a/services/web/test/UnitTests/coffee/infrastructure/LockManager/tryLockTests.coffee
+++ b/services/web/test/UnitTests/coffee/infrastructure/LockManager/tryLockTests.coffee
@@ -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"