Просмотр исходного кода

Use ProjectGetter, not Project, in ProjectController.loadEditor

James Allen 10 лет назад
Родитель
Сommit
fe1f71413e

+ 1 - 2
services/web/app/coffee/Features/Project/ProjectController.coffee

@@ -5,7 +5,6 @@ projectDuplicator = require("./ProjectDuplicator")
 projectCreationHandler = require("./ProjectCreationHandler")
 editorController = require("../Editor/EditorController")
 metrics = require('../../infrastructure/Metrics')
-Project = require('../../models/Project').Project
 User = require('../../models/User').User
 TagsHandler = require("../Tags/TagsHandler")
 SubscriptionLocator = require("../Subscription/SubscriptionLocator")
@@ -195,7 +194,7 @@ module.exports = ProjectController =
 
 		async.parallel {
 			project: (cb)->
-				Project.findOne { _id: project_id }, cb
+				ProjectGetter.getProject project_id, { name: 1, lastUpdated: 1}, cb
 			user: (cb)->
 				if user_id == 'openUser'
 					cb null, defaultSettingsForAnonymousUser(user_id)

+ 2 - 4
services/web/test/UnitTests/coffee/Project/ProjectControllerTests.coffee

@@ -35,8 +35,6 @@ describe "ProjectController", ->
 			getAllTags: sinon.stub()
 		@NotificationsHandler =
 			getUserNotifications: sinon.stub()
-		@ProjectModel =
-			findOne: sinon.stub()
 		@UserModel =
 			findById: sinon.stub()
 		@AuthorizationManager =
@@ -51,6 +49,7 @@ describe "ProjectController", ->
 			indexProjectReferences: sinon.stub()
 		@ProjectGetter =
 			findAllUsersProjects: sinon.stub()
+			getProject: sinon.stub()
 		@ProjectController = SandboxedModule.require modulePath, requires:
 			"settings-sharelatex":@settings
 			"logger-sharelatex": 
@@ -64,7 +63,6 @@ describe "ProjectController", ->
 			"../Subscription/LimitationsManager": @LimitationsManager
 			"../Tags/TagsHandler":@TagsHandler
 			"../Notifications/NotificationsHandler":@NotificationsHandler
-			'../../models/Project': Project:@ProjectModel
 			"../../models/User":User:@UserModel
 			"../Authorization/AuthorizationManager":@AuthorizationManager
 			"../InactiveData/InactiveProjectManager":@InactiveProjectManager
@@ -296,7 +294,7 @@ describe "ProjectController", ->
 					fontSize:"massive"
 					theme:"sexy"
 				email: "bob@bob.com"
-			@ProjectModel.findOne.callsArgWith 1, null, @project
+			@ProjectGetter.getProject.callsArgWith 2, null, @project
 			@UserModel.findById.callsArgWith(1, null, @user)
 			@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, {})
 			@AuthorizationManager.getPrivilegeLevelForProject.callsArgWith 2, null, "owner"