renamed UserController to UserInfoController

This commit is contained in:
Henry Oswald 2014-04-09 14:45:46 +01:00
parent c55c5032b0
commit 37fb959b00
3 changed files with 20 additions and 22 deletions

View file

@ -23,7 +23,7 @@ TemplatesMiddlewear = require('./Features/Templates/TemplatesMiddlewear')
AuthenticationController = require('./Features/Authentication/AuthenticationController') AuthenticationController = require('./Features/Authentication/AuthenticationController')
TagsController = require("./Features/Tags/TagsController") TagsController = require("./Features/Tags/TagsController")
CollaboratorsController = require('./Features/Collaborators/CollaboratorsController') CollaboratorsController = require('./Features/Collaborators/CollaboratorsController')
PersonalInfoController = require('./Features/User/UserController') UserInfoController = require('./Features/User/UserInfoController')
UserPagesController = require('./Features/User/UserPagesController') UserPagesController = require('./Features/User/UserPagesController')
DocumentController = require('./Features/Documents/DocumentController') DocumentController = require('./Features/Documents/DocumentController')
CompileManager = require("./Features/Compile/CompileManager") CompileManager = require("./Features/Compile/CompileManager")
@ -36,8 +36,6 @@ DropboxUserController = require("./Features/Dropbox/DropboxUserController")
logger = require("logger-sharelatex") logger = require("logger-sharelatex")
_ = require("underscore") _ = require("underscore")
console.log PersonalInfoController
httpAuth = require('express').basicAuth (user, pass)-> httpAuth = require('express').basicAuth (user, pass)->
isValid = Settings.httpAuthUsers[user] == pass isValid = Settings.httpAuthUsers[user] == pass
if !isValid if !isValid
@ -82,15 +80,15 @@ module.exports = class Router
app.get '/user/passwordreset', UserPagesController.passwordResetPage app.get '/user/passwordreset', UserPagesController.passwordResetPage
app.post '/user/passwordReset', UserController.doRequestPasswordReset app.post '/user/passwordReset', UserController.doRequestPasswordReset
app.del '/user/newsletter/unsubscribe', AuthenticationController.requireLogin(), UserController.unsubscribe app.del '/user/newsletter/unsubscribe', AuthenticationController.requireLogin(), UserController.unsubscribe
app.del '/user', AuthenticationController.requireLogin(), PersonalInfoController.deleteUser app.del '/user', AuthenticationController.requireLogin(), UserInfoController.deleteUser
app.get '/dropbox/beginAuth', DropboxUserController.redirectUserToDropboxAuth app.get '/dropbox/beginAuth', DropboxUserController.redirectUserToDropboxAuth
app.get '/dropbox/completeRegistration', DropboxUserController.completeDropboxRegistration app.get '/dropbox/completeRegistration', DropboxUserController.completeDropboxRegistration
app.get '/dropbox/unlink', DropboxUserController.unlinkDropbox app.get '/dropbox/unlink', DropboxUserController.unlinkDropbox
app.get '/user/auth_token', AuthenticationController.requireLogin(), AuthenticationController.getAuthToken app.get '/user/auth_token', AuthenticationController.requireLogin(), AuthenticationController.getAuthToken
app.get '/user/personal_info', AuthenticationController.requireLogin(allow_auth_token: true), PersonalInfoController.getLoggedInUsersPersonalInfo app.get '/user/personal_info', AuthenticationController.requireLogin(allow_auth_token: true), UserInfoController.getLoggedInUsersPersonalInfo
app.get '/user/:user_id/personal_info', httpAuth, PersonalInfoController.getPersonalInfo app.get '/user/:user_id/personal_info', httpAuth, UserInfoController.getPersonalInfo
app.get '/project', AuthenticationController.requireLogin(), ProjectController.projectListPage app.get '/project', AuthenticationController.requireLogin(), ProjectController.projectListPage
app.post '/project/new', AuthenticationController.requireLogin(), ProjectController.newProject app.post '/project/new', AuthenticationController.requireLogin(), ProjectController.newProject

View file

@ -2,18 +2,18 @@ sinon = require('sinon')
chai = require('chai') chai = require('chai')
should = chai.should() should = chai.should()
expect = chai.expect expect = chai.expect
modulePath = "../../../../app/js/Features/User/UserController.js" modulePath = "../../../../app/js/Features/User/UserInfoController.js"
SandboxedModule = require('sandboxed-module') SandboxedModule = require('sandboxed-module')
events = require "events" events = require "events"
MockResponse = require "../helpers/MockResponse" MockResponse = require "../helpers/MockResponse"
MockRequest = require "../helpers/MockRequest" MockRequest = require "../helpers/MockRequest"
ObjectId = require("mongojs").ObjectId ObjectId = require("mongojs").ObjectId
describe "UserController", -> describe "UserInfoController", ->
beforeEach -> beforeEach ->
@UserDeleter = @UserDeleter =
deleteUser: sinon.stub().callsArgWith(1) deleteUser: sinon.stub().callsArgWith(1)
@UserController = SandboxedModule.require modulePath, requires: @UserInfoController = SandboxedModule.require modulePath, requires:
"./UserGetter": @UserGetter = {} "./UserGetter": @UserGetter = {}
"./UserDeleter": @UserDeleter "./UserDeleter": @UserDeleter
@ -26,11 +26,11 @@ describe "UserController", ->
@user = @user =
_id: ObjectId() _id: ObjectId()
@req.user = @user @req.user = @user
@UserController.sendFormattedPersonalInfo = sinon.stub() @UserInfoController.sendFormattedPersonalInfo = sinon.stub()
@UserController.getLoggedInUsersPersonalInfo(@req, @res, @next) @UserInfoController.getLoggedInUsersPersonalInfo(@req, @res, @next)
it "should call sendFormattedPersonalInfo", -> it "should call sendFormattedPersonalInfo", ->
@UserController.sendFormattedPersonalInfo @UserInfoController.sendFormattedPersonalInfo
.calledWith(@user, @res, @next) .calledWith(@user, @res, @next)
.should.equal true .should.equal true
@ -44,8 +44,8 @@ describe "UserController", ->
describe "when the user exists", -> describe "when the user exists", ->
beforeEach -> beforeEach ->
@UserGetter.getUser = sinon.stub().callsArgWith(2, null, @user) @UserGetter.getUser = sinon.stub().callsArgWith(2, null, @user)
@UserController.sendFormattedPersonalInfo = sinon.stub() @UserInfoController.sendFormattedPersonalInfo = sinon.stub()
@UserController.getPersonalInfo(@req, @res, @next) @UserInfoController.getPersonalInfo(@req, @res, @next)
it "should look up the user in the database", -> it "should look up the user in the database", ->
@UserGetter.getUser @UserGetter.getUser
@ -53,15 +53,15 @@ describe "UserController", ->
.should.equal true .should.equal true
it "should send the formatted details back to the client", -> it "should send the formatted details back to the client", ->
@UserController.sendFormattedPersonalInfo @UserInfoController.sendFormattedPersonalInfo
.calledWith(@user, @res, @next) .calledWith(@user, @res, @next)
.should.equal true .should.equal true
describe "when the user does not exist", -> describe "when the user does not exist", ->
beforeEach -> beforeEach ->
@UserGetter.getUser = sinon.stub().callsArgWith(2, null, null) @UserGetter.getUser = sinon.stub().callsArgWith(2, null, null)
@UserController.sendFormattedPersonalInfo = sinon.stub() @UserInfoController.sendFormattedPersonalInfo = sinon.stub()
@UserController.getPersonalInfo(@req, @res, @next) @UserInfoController.getPersonalInfo(@req, @res, @next)
it "should return 404 to the client", -> it "should return 404 to the client", ->
@res.statusCode.should.equal 404 @res.statusCode.should.equal 404
@ -78,11 +78,11 @@ describe "UserController", ->
first_name: @user.first_name first_name: @user.first_name
last_name: @user.last_name last_name: @user.last_name
email: @user.email email: @user.email
@UserController._formatPersonalInfo = sinon.stub().callsArgWith(1, null, @formattedInfo) @UserInfoController._formatPersonalInfo = sinon.stub().callsArgWith(1, null, @formattedInfo)
@UserController.sendFormattedPersonalInfo @user, @res @UserInfoController.sendFormattedPersonalInfo @user, @res
it "should format the user details for the response", -> it "should format the user details for the response", ->
@UserController._formatPersonalInfo @UserInfoController._formatPersonalInfo
.calledWith(@user) .calledWith(@user)
.should.equal true .should.equal true
@ -98,7 +98,7 @@ describe "UserController", ->
email: "doug@sharelatex.com" email: "doug@sharelatex.com"
password: "should-not-get-included" password: "should-not-get-included"
signUpDate: new Date() signUpDate: new Date()
@UserController._formatPersonalInfo @user, (error, info) => @UserInfoController._formatPersonalInfo @user, (error, info) =>
expect(info).to.deep.equal { expect(info).to.deep.equal {
id: @user._id.toString() id: @user._id.toString()
first_name: @user.first_name first_name: @user.first_name
@ -118,7 +118,7 @@ describe "UserController", ->
@UserDeleter.deleteUser.calledWith(user_id) @UserDeleter.deleteUser.calledWith(user_id)
code.should.equal 200 code.should.equal 200
done() done()
@UserController.deleteUser @req, @res @UserInfoController.deleteUser @req, @res