From 026f7eebcd64b2699471ab8fce55424ec6d92c74 Mon Sep 17 00:00:00 2001 From: hugh-obrien Date: Sat, 6 Oct 2018 15:57:25 +0100 Subject: [PATCH 1/5] Setting up hostname field and institution domain confirmation endpoint --- .../coffee/Features/Institutions/InstitutionsController.coffee | 2 ++ services/web/app/coffee/Features/User/UserUpdater.coffee | 3 ++- services/web/app/coffee/models/User.coffee | 1 + services/web/app/coffee/router.coffee | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 services/web/app/coffee/Features/Institutions/InstitutionsController.coffee diff --git a/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee b/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee new file mode 100644 index 0000000000..0c6d0b164a --- /dev/null +++ b/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee @@ -0,0 +1,2 @@ +module.exports = InstitutionsController = + confirmDomain: (req, res, next = (error) ->) -> diff --git a/services/web/app/coffee/Features/User/UserUpdater.coffee b/services/web/app/coffee/Features/User/UserUpdater.coffee index c8f35eba10..3d6f8544cf 100644 --- a/services/web/app/coffee/Features/User/UserUpdater.coffee +++ b/services/web/app/coffee/Features/User/UserUpdater.coffee @@ -66,7 +66,8 @@ module.exports = UserUpdater = logger.err error: error, 'problem adding affiliation while adding email' return callback(error) - update = $push: emails: email: newEmail, createdAt: new Date() + hostname = newEmail.split('@')[1] + update = $push: emails: email: newEmail, createdAt: new Date(), hostname: hostname @updateUser userId, update, (error) -> if error? logger.err error: error, 'problem updating users emails' diff --git a/services/web/app/coffee/models/User.coffee b/services/web/app/coffee/models/User.coffee index 23b59375f4..e2935f0744 100644 --- a/services/web/app/coffee/models/User.coffee +++ b/services/web/app/coffee/models/User.coffee @@ -10,6 +10,7 @@ UserSchema = new Schema email : {type : String, default : ''} emails: [{ email: { type : String, default : '' }, + hostname: { type : String, default : '' }, createdAt: { type : Date, default: () -> new Date() }, confirmedAt: { type: Date } }], diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index 954356c4a0..050ab32b92 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -50,6 +50,7 @@ TokenAccessController = require('./Features/TokenAccess/TokenAccessController') Features = require('./infrastructure/Features') LinkedFilesRouter = require './Features/LinkedFiles/LinkedFilesRouter' TemplatesRouter = require './Features/Templates/TemplatesRouter' +InstitutionsController = require './Features/Institutions/InstitutionsController' logger = require("logger-sharelatex") _ = require("underscore") @@ -330,6 +331,7 @@ module.exports = class Router ), AuthenticationController.httpAuth, CompileController.getFileFromClsiWithoutUser + publicApiRouter.post '/api/institutions/confirm_affiliation_domain', AuthenticationController.httpAuth, InstitutionsController.confirmDomain webRouter.get '/teams', (req, res, next) -> # Match v1 behaviour - if the user is signed in, show their teams list From af3cc01496557e023d90f60c7515b590d7c5e0a2 Mon Sep 17 00:00:00 2001 From: hugh-obrien Date: Sat, 6 Oct 2018 17:22:39 +0100 Subject: [PATCH 2/5] Lookup users by email hostname using new field --- .../Features/Institutions/InstitutionsController.coffee | 7 ++++++- services/web/app/coffee/Features/User/UserGetter.coffee | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee b/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee index 0c6d0b164a..d6a681ca88 100644 --- a/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee +++ b/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee @@ -1,2 +1,7 @@ +UserGetter = require("../User/UserGetter") + module.exports = InstitutionsController = - confirmDomain: (req, res, next = (error) ->) -> + confirmDomain: (req, res, next) -> + hostname = req.body.hostname + UserGetter.getUsersByHostname hostname, {_id:1, emails:1}, (error, users) -> + res.json {hostname: hostname, wub: users} diff --git a/services/web/app/coffee/Features/User/UserGetter.coffee b/services/web/app/coffee/Features/User/UserGetter.coffee index 4291cda6b7..5615f48b61 100644 --- a/services/web/app/coffee/Features/User/UserGetter.coffee +++ b/services/web/app/coffee/Features/User/UserGetter.coffee @@ -58,6 +58,11 @@ module.exports = UserGetter = # well @getUserByMainEmail email, projection, callback + getUsersByHostname: (hostname, projection, callback = (error, users) ->) -> + hostname = hostname.trim() + query = emails: { $exists: true }, 'emails.hostname': hostname + db.users.find query, projection, callback + getUsers: (user_ids, projection, callback = (error, users) ->) -> try user_ids = user_ids.map (u) -> ObjectId(u.toString()) From 65ecdf84f4bd38c1954c3cc955532807c9dc51c7 Mon Sep 17 00:00:00 2001 From: hugh-obrien Date: Sun, 7 Oct 2018 16:40:26 +0100 Subject: [PATCH 3/5] cleanup and tests for v2 affiliations confirmation --- .../InstitutionsController.coffee | 11 +++- .../InstitutionsControllerTests.coffee | 54 +++++++++++++++++++ .../unit/coffee/User/UserUpdaterTests.coffee | 3 +- 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee diff --git a/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee b/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee index d6a681ca88..de562530b9 100644 --- a/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee +++ b/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee @@ -1,7 +1,16 @@ +logger = require("logger-sharelatex") UserGetter = require("../User/UserGetter") +{ addAffiliation } = require("../Institutions/InstitutionsAPI") +async = require('async') module.exports = InstitutionsController = confirmDomain: (req, res, next) -> hostname = req.body.hostname UserGetter.getUsersByHostname hostname, {_id:1, emails:1}, (error, users) -> - res.json {hostname: hostname, wub: users} + async.map users, (user, error) -> + email = user.emails.filter (email) -> email.hostname == hostname + addAffiliation user._id, email[0].email, {}, (error) => + if error? + logger.err error: error, 'problem adding affiliation while confirming hostname' + return next(error) + res.sendStatus 200 diff --git a/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee b/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee new file mode 100644 index 0000000000..8355dceea4 --- /dev/null +++ b/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee @@ -0,0 +1,54 @@ +should = require('chai').should() +SandboxedModule = require('sandboxed-module') +assert = require('assert') +path = require('path') +sinon = require('sinon') +modulePath = path.join __dirname, "../../../../app/js/Features/Institutions/InstitutionsController" +expect = require("chai").expect + +describe "InstitutionsController", -> + + beforeEach -> + @logger = err: sinon.stub(), log: -> + @stubbedUser1 = + _id: "3131231" + name:"bob" + email:"hello@world.com" + emails: [ + {"email":"stubb1@mit.edu","hostname":"mit.edu"}, + {"email":"test@test.com","hostname":"test.com"} + ] + @stubbedUser2 = + _id: "3131232" + name:"test" + email:"hello2@world.com" + emails: [ + {"email":"subb2@mit.edu","hostname":"mit.edu"} + ] + + @getUsersByHostname = sinon.stub().callsArgWith(2, null, [ @stubbedUser1, @stubbedUser2 ]) + @addAffiliation = sinon.stub().callsArgWith(3, null) + @InstitutionsController = SandboxedModule.require modulePath, requires: + 'logger-sharelatex': @logger + '../User/UserGetter': + getUsersByHostname: @getUsersByHostname + '../Institutions/InstitutionsAPI': + addAffiliation: @addAffiliation + + @req = + body:{} + + @res = + send: sinon.stub() + json: sinon.stub() + @next = sinon.stub() + + describe 'confirmDomain', -> + it 'should add affiliations for matching users', (done)-> + @req.body.hostname = "mit.edu" + @res.sendStatus = (code) => + @getUsersByHostname.calledOnce.should.equal true + @addAffiliation.calledTwice.should.equal true + @addAffiliation.calledWith(@stubbedUser1._id, @stubbedUser1.emails[0].email).should.equal true + done() + @InstitutionsController.confirmDomain @req, @res, @next diff --git a/services/web/test/unit/coffee/User/UserUpdaterTests.coffee b/services/web/test/unit/coffee/User/UserUpdaterTests.coffee index 3be7733153..aaf2c032bc 100644 --- a/services/web/test/unit/coffee/User/UserUpdaterTests.coffee +++ b/services/web/test/unit/coffee/User/UserUpdaterTests.coffee @@ -90,9 +90,10 @@ describe "UserUpdater", -> @UserUpdater.addEmailAddress @stubbedUser._id, @newEmail, (err)=> @UserGetter.ensureUniqueEmailAddress.called.should.equal true should.not.exist(err) + hostname = @newEmail.split('@')[1] @UserUpdater.updateUser.calledWith( @stubbedUser._id, - $push: { emails: { email: @newEmail, createdAt: sinon.match.date } } + $push: { emails: { email: @newEmail, createdAt: sinon.match.date, hostname: hostname } } ).should.equal true done() From 3919acad46564a4bdc8c26cf6b994d4ab911348b Mon Sep 17 00:00:00 2001 From: hugh-obrien Date: Mon, 8 Oct 2018 12:08:29 +0100 Subject: [PATCH 4/5] store reversed hostname and review fixes for v2 university domain confirmation --- .../Institutions/InstitutionsController.coffee | 17 ++++++++++++----- .../app/coffee/Features/User/UserUpdater.coffee | 2 +- services/web/app/coffee/router.coffee | 2 +- .../InstitutionsControllerTests.coffee | 11 +++++++---- .../unit/coffee/User/UserUpdaterTests.coffee | 2 +- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee b/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee index de562530b9..6325d9336d 100644 --- a/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee +++ b/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee @@ -5,12 +5,19 @@ async = require('async') module.exports = InstitutionsController = confirmDomain: (req, res, next) -> - hostname = req.body.hostname + hostname = req.body.hostname.split('').reverse().join('') UserGetter.getUsersByHostname hostname, {_id:1, emails:1}, (error, users) -> - async.map users, (user, error) -> - email = user.emails.filter (email) -> email.hostname == hostname - addAffiliation user._id, email[0].email, {}, (error) => + if error? + logger.err error: error, 'problem fetching users by hostname' + return next(error) + async.map users, ((user) -> + matchingEmails = user.emails.filter (email) -> email.hostname == hostname + for email in matchingEmails + addAffiliation user._id, email.email, {confirmedAt: email.confirmedAt}, (error) => + if error? + logger.err error: error, 'problem adding affiliation while confirming hostname' + return next(error) + ), (error) -> if error? - logger.err error: error, 'problem adding affiliation while confirming hostname' return next(error) res.sendStatus 200 diff --git a/services/web/app/coffee/Features/User/UserUpdater.coffee b/services/web/app/coffee/Features/User/UserUpdater.coffee index 3d6f8544cf..832943fbf0 100644 --- a/services/web/app/coffee/Features/User/UserUpdater.coffee +++ b/services/web/app/coffee/Features/User/UserUpdater.coffee @@ -66,7 +66,7 @@ module.exports = UserUpdater = logger.err error: error, 'problem adding affiliation while adding email' return callback(error) - hostname = newEmail.split('@')[1] + hostname = newEmail.split('@')[1].split('').reverse().join('') update = $push: emails: email: newEmail, createdAt: new Date(), hostname: hostname @updateUser userId, update, (error) -> if error? diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index 050ab32b92..e072d6d0f9 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -331,7 +331,7 @@ module.exports = class Router ), AuthenticationController.httpAuth, CompileController.getFileFromClsiWithoutUser - publicApiRouter.post '/api/institutions/confirm_affiliation_domain', AuthenticationController.httpAuth, InstitutionsController.confirmDomain + publicApiRouter.post '/api/institutions/confirm_university_domain', AuthenticationController.httpAuth, InstitutionsController.confirmDomain webRouter.get '/teams', (req, res, next) -> # Match v1 behaviour - if the user is signed in, show their teams list diff --git a/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee b/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee index 8355dceea4..1d59dc6633 100644 --- a/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee +++ b/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee @@ -10,20 +10,22 @@ describe "InstitutionsController", -> beforeEach -> @logger = err: sinon.stub(), log: -> + @host = "mit.edu".split('').reverse().join('') @stubbedUser1 = _id: "3131231" name:"bob" email:"hello@world.com" emails: [ - {"email":"stubb1@mit.edu","hostname":"mit.edu"}, - {"email":"test@test.com","hostname":"test.com"} + {"email":"stubb1@mit.edu","hostname":@host}, + {"email":"test@test.com","hostname":"test.com"}, + {"email":"another@mit.edu","hostname":@host} ] @stubbedUser2 = _id: "3131232" name:"test" email:"hello2@world.com" emails: [ - {"email":"subb2@mit.edu","hostname":"mit.edu"} + {"email":"subb2@mit.edu","hostname":@host} ] @getUsersByHostname = sinon.stub().callsArgWith(2, null, [ @stubbedUser1, @stubbedUser2 ]) @@ -48,7 +50,8 @@ describe "InstitutionsController", -> @req.body.hostname = "mit.edu" @res.sendStatus = (code) => @getUsersByHostname.calledOnce.should.equal true - @addAffiliation.calledTwice.should.equal true + @addAffiliation.calledThrice.should.equal true @addAffiliation.calledWith(@stubbedUser1._id, @stubbedUser1.emails[0].email).should.equal true + @addAffiliation.calledWith(@stubbedUser1._id, @stubbedUser1.emails[2].email).should.equal true done() @InstitutionsController.confirmDomain @req, @res, @next diff --git a/services/web/test/unit/coffee/User/UserUpdaterTests.coffee b/services/web/test/unit/coffee/User/UserUpdaterTests.coffee index aaf2c032bc..16d98e1db5 100644 --- a/services/web/test/unit/coffee/User/UserUpdaterTests.coffee +++ b/services/web/test/unit/coffee/User/UserUpdaterTests.coffee @@ -90,7 +90,7 @@ describe "UserUpdater", -> @UserUpdater.addEmailAddress @stubbedUser._id, @newEmail, (err)=> @UserGetter.ensureUniqueEmailAddress.called.should.equal true should.not.exist(err) - hostname = @newEmail.split('@')[1] + hostname = @newEmail.split('@')[1].split('').reverse().join('') @UserUpdater.updateUser.calledWith( @stubbedUser._id, $push: { emails: { email: @newEmail, createdAt: sinon.match.date, hostname: hostname } } From f6307f90862d6804082dea07ef9c3806a398928a Mon Sep 17 00:00:00 2001 From: hugh-obrien Date: Mon, 8 Oct 2018 13:37:12 +0100 Subject: [PATCH 5/5] store reversedHostname property and update test accordingly --- .../InstitutionsController.coffee | 5 ++-- .../coffee/Features/User/UserGetter.coffee | 4 +-- .../coffee/Features/User/UserUpdater.coffee | 4 +-- services/web/app/coffee/models/User.coffee | 2 +- .../InstitutionsControllerTests.coffee | 8 ++--- .../unit/coffee/User/UserGetterTests.coffee | 30 ++++++++++++++----- .../unit/coffee/User/UserUpdaterTests.coffee | 4 +-- 7 files changed, 37 insertions(+), 20 deletions(-) diff --git a/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee b/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee index 6325d9336d..af8c7c5644 100644 --- a/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee +++ b/services/web/app/coffee/Features/Institutions/InstitutionsController.coffee @@ -5,13 +5,14 @@ async = require('async') module.exports = InstitutionsController = confirmDomain: (req, res, next) -> - hostname = req.body.hostname.split('').reverse().join('') + hostname = req.body.hostname + reversedHostname = hostname.trim().split('').reverse().join('') UserGetter.getUsersByHostname hostname, {_id:1, emails:1}, (error, users) -> if error? logger.err error: error, 'problem fetching users by hostname' return next(error) async.map users, ((user) -> - matchingEmails = user.emails.filter (email) -> email.hostname == hostname + matchingEmails = user.emails.filter (email) -> email.reversedHostname == reversedHostname for email in matchingEmails addAffiliation user._id, email.email, {confirmedAt: email.confirmedAt}, (error) => if error? diff --git a/services/web/app/coffee/Features/User/UserGetter.coffee b/services/web/app/coffee/Features/User/UserGetter.coffee index 5615f48b61..f6d16f5c75 100644 --- a/services/web/app/coffee/Features/User/UserGetter.coffee +++ b/services/web/app/coffee/Features/User/UserGetter.coffee @@ -59,8 +59,8 @@ module.exports = UserGetter = @getUserByMainEmail email, projection, callback getUsersByHostname: (hostname, projection, callback = (error, users) ->) -> - hostname = hostname.trim() - query = emails: { $exists: true }, 'emails.hostname': hostname + reversedHostname = hostname.trim().split('').reverse().join('') + query = emails: { $exists: true }, 'emails.reversedHostname': reversedHostname db.users.find query, projection, callback getUsers: (user_ids, projection, callback = (error, users) ->) -> diff --git a/services/web/app/coffee/Features/User/UserUpdater.coffee b/services/web/app/coffee/Features/User/UserUpdater.coffee index 832943fbf0..b640aae3c3 100644 --- a/services/web/app/coffee/Features/User/UserUpdater.coffee +++ b/services/web/app/coffee/Features/User/UserUpdater.coffee @@ -66,8 +66,8 @@ module.exports = UserUpdater = logger.err error: error, 'problem adding affiliation while adding email' return callback(error) - hostname = newEmail.split('@')[1].split('').reverse().join('') - update = $push: emails: email: newEmail, createdAt: new Date(), hostname: hostname + reversedHostname = newEmail.split('@')[1].split('').reverse().join('') + update = $push: emails: email: newEmail, createdAt: new Date(), reversedHostname: reversedHostname @updateUser userId, update, (error) -> if error? logger.err error: error, 'problem updating users emails' diff --git a/services/web/app/coffee/models/User.coffee b/services/web/app/coffee/models/User.coffee index e2935f0744..2efb45370a 100644 --- a/services/web/app/coffee/models/User.coffee +++ b/services/web/app/coffee/models/User.coffee @@ -10,7 +10,7 @@ UserSchema = new Schema email : {type : String, default : ''} emails: [{ email: { type : String, default : '' }, - hostname: { type : String, default : '' }, + reversedHostname: { type : String, default : '' }, createdAt: { type : Date, default: () -> new Date() }, confirmedAt: { type: Date } }], diff --git a/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee b/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee index 1d59dc6633..4e269b1f6f 100644 --- a/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee +++ b/services/web/test/unit/coffee/Institutions/InstitutionsControllerTests.coffee @@ -16,16 +16,16 @@ describe "InstitutionsController", -> name:"bob" email:"hello@world.com" emails: [ - {"email":"stubb1@mit.edu","hostname":@host}, - {"email":"test@test.com","hostname":"test.com"}, - {"email":"another@mit.edu","hostname":@host} + {"email":"stubb1@mit.edu","reversedHostname":@host}, + {"email":"test@test.com","reversedHostname":"test.com"}, + {"email":"another@mit.edu","reversedHostname":@host} ] @stubbedUser2 = _id: "3131232" name:"test" email:"hello2@world.com" emails: [ - {"email":"subb2@mit.edu","hostname":@host} + {"email":"subb2@mit.edu","reversedHostname":@host} ] @getUsersByHostname = sinon.stub().callsArgWith(2, null, [ @stubbedUser1, @stubbedUser2 ]) diff --git a/services/web/test/unit/coffee/User/UserGetterTests.coffee b/services/web/test/unit/coffee/User/UserGetterTests.coffee index 7d4641c404..0691ed0cdb 100644 --- a/services/web/test/unit/coffee/User/UserGetterTests.coffee +++ b/services/web/test/unit/coffee/User/UserGetterTests.coffee @@ -14,12 +14,15 @@ describe "UserGetter", -> _id: '12390i' email: 'email2@foo.bar' emails: [ - { email: 'email1@foo.bar' } - { email: 'email2@foo.bar' } + { email: 'email1@foo.bar', reversedHostname: 'rab.oof' } + { email: 'email2@foo.bar', reversedHostname: 'rab.oof' } ] @findOne = sinon.stub().callsArgWith(2, null, @fakeUser) + @find = sinon.stub().callsArgWith(2, null, [ @fakeUser ]) @Mongo = - db: users: findOne: @findOne + db: users: + findOne: @findOne + find: @find ObjectId: (id) -> return id settings = apis: { v1: { url: 'v1.url', user: '', pass: '' } } @getUserAffiliations = sinon.stub().callsArgWith(1, null, []) @@ -66,8 +69,8 @@ describe "UserGetter", -> @UserGetter.getUser = sinon.stub().callsArgWith(2, null, @fakeUser) @UserGetter.getUserFullEmails @fakeUser._id, (error, fullEmails) => assert.deepEqual fullEmails, [ - { email: 'email1@foo.bar', default: false } - { email: 'email2@foo.bar', default: true } + { email: 'email1@foo.bar', reversedHostname: 'rab.oof', default: false } + { email: 'email2@foo.bar', reversedHostname: 'rab.oof', default: true } ] done() @@ -86,7 +89,8 @@ describe "UserGetter", -> @UserGetter.getUserFullEmails @fakeUser._id, (error, fullEmails) => assert.deepEqual fullEmails, [ { - email: 'email1@foo.bar' + email: 'email1@foo.bar', + reversedHostname: 'rab.oof' default: false affiliation: institution: affiliationsData[0].institution @@ -94,7 +98,7 @@ describe "UserGetter", -> department: affiliationsData[0].department role: affiliationsData[0].role } - { email: 'email2@foo.bar', default: true } + { email: 'email2@foo.bar', reversedHostname: 'rab.oof', default: true } ] done() @@ -161,6 +165,18 @@ describe "UserGetter", -> @findOne.calledWith(email: email, projection).should.equal true done() + describe "getUsersByHostname", -> + it "should find user by hostname", (done)-> + hostname = "bar.foo" + expectedQuery = + emails: {$exists: true }, + 'emails.reversedHostname': hostname.split('').reverse().join('') + projection = emails: 1 + @UserGetter.getUsersByHostname hostname, projection, (error, users) => + @find.calledOnce.should.equal true + @find.calledWith(expectedQuery, projection).should.equal true + done() + describe 'ensureUniqueEmailAddress', -> beforeEach -> @UserGetter.getUserByAnyEmail = sinon.stub() diff --git a/services/web/test/unit/coffee/User/UserUpdaterTests.coffee b/services/web/test/unit/coffee/User/UserUpdaterTests.coffee index 16d98e1db5..034c8b68ab 100644 --- a/services/web/test/unit/coffee/User/UserUpdaterTests.coffee +++ b/services/web/test/unit/coffee/User/UserUpdaterTests.coffee @@ -90,10 +90,10 @@ describe "UserUpdater", -> @UserUpdater.addEmailAddress @stubbedUser._id, @newEmail, (err)=> @UserGetter.ensureUniqueEmailAddress.called.should.equal true should.not.exist(err) - hostname = @newEmail.split('@')[1].split('').reverse().join('') + reversedHostname = @newEmail.split('@')[1].split('').reverse().join('') @UserUpdater.updateUser.calledWith( @stubbedUser._id, - $push: { emails: { email: @newEmail, createdAt: sinon.match.date, hostname: hostname } } + $push: { emails: { email: @newEmail, createdAt: sinon.match.date, reversedHostname: reversedHostname } } ).should.equal true done()