Fixed a couple bugs and tests.

This commit is contained in:
Scott Erickson 2014-04-23 09:19:07 -07:00
parent f7035d4220
commit b390b38054
2 changed files with 10 additions and 3 deletions

View file

@ -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) ->

View file

@ -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) ->