mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 10:56:53 -05:00
Fixed a couple bugs and tests.
This commit is contained in:
parent
f7035d4220
commit
b390b38054
2 changed files with 10 additions and 3 deletions
|
@ -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) ->
|
||||
|
|
|
@ -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) ->
|
||||
|
|
Loading…
Reference in a new issue