From b390b3805449443ba2a55c3ce5cb6109763efc89 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Wed, 23 Apr 2014 09:19:07 -0700 Subject: [PATCH] Fixed a couple bugs and tests. --- server/users/User.coffee | 4 ++-- test/server/functional/auth.spec.coffee | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/server/users/User.coffee b/server/users/User.coffee index b62cf9b3c..1b591a304 100644 --- a/server/users/User.coffee +++ b/server/users/User.coffee @@ -47,7 +47,7 @@ UserSchema.methods.setEmailSubscription = (newName, enabled) -> oldSubs.push(oldName) if enabled @set('emailSubscriptions', oldSubs) - newSubs = _.clone(@get('emails') or jsonschema.properties.emails.default) + newSubs = _.clone(@get('emails') or _.cloneDeep(jsonschema.properties.emails.default)) newSubs[newName] ?= {} newSubs[newName].enabled = enabled @set('emails', newSubs) @@ -60,7 +60,7 @@ UserSchema.methods.isEmailSubscriptionEnabled = (newName) -> oldName = emailNameMap[newName] return oldName and oldName in oldSubs if oldSubs emails ?= {} - _.defaults emails, jsonschema.properties.emails.default + _.defaults emails, _.cloneDeep(jsonschema.properties.emails.default) return emails[newName]?.enabled UserSchema.statics.updateMailChimp = (doc, callback) -> diff --git a/test/server/functional/auth.spec.coffee b/test/server/functional/auth.spec.coffee index 6e5f5f07e..ce470288f 100644 --- a/test/server/functional/auth.spec.coffee +++ b/test/server/functional/auth.spec.coffee @@ -17,7 +17,8 @@ describe '/auth/whoami', -> describe '/auth/login', -> it 'clears Users first', (done) -> - User.remove {}, (err) -> + clearModels [User], (err) -> + throw err if err request.get getURL('/auth/whoami'), -> throw err if err done() @@ -137,6 +138,12 @@ describe '/auth/reset', -> form.append('password', 'nada') describe '/auth/unsubscribe', -> + it 'clears Users first', (done) -> + clearModels [User], (err) -> + throw err if err + request.get getURL('/auth/whoami'), -> + throw err if err + done() it 'removes just recruitment emails if you include ?recruitNotes=1', (done) -> loginJoe (joe) ->