Add user deletion date

Fixes #2734
This commit is contained in:
Matt Lott 2015-06-18 15:17:56 -07:00
parent 72e458cc80
commit b12b7e8ca4
3 changed files with 7 additions and 4 deletions

View file

@ -284,6 +284,7 @@ _.extend UserSchema.properties,
earned: c.RewardSchema 'earned by achievements'
purchased: c.RewardSchema 'purchased with gems or money'
deleted: {type: 'boolean'}
dateDeleted: c.date()
spent: {type: 'number'}
stripeCustomerID: { type: 'string' } # TODO: Migrate away from this property

View file

@ -279,6 +279,7 @@ UserHandler = class UserHandler extends Handler
obj = user.toObject()
for prop, val of obj
user.set(prop, undefined) unless prop is '_id'
user.set('dateDeleted', new Date())
user.set('deleted', true)
# Hack to get saving of Users to work. Probably should replace these props with strings

View file

@ -331,6 +331,7 @@ describe 'GET /db/user', ->
describe 'DELETE /db/user', ->
it 'can delete a user', (done) ->
loginNewUser (user1) ->
beforeDeleted = new Date()
request.del {uri: "#{getURL(urlUser)}/#{user1.id}"}, (err, res) ->
expect(err).toBeNull()
return done() if err
@ -338,11 +339,11 @@ describe 'DELETE /db/user', ->
expect(err).toBeNull()
return done() if err
expect(user1.get('deleted')).toBe(true)
expect(user1.get('dateDeleted')).toBeGreaterThan(beforeDeleted)
expect(user1.get('dateDeleted')).toBeLessThan(new Date())
for key, value of user1.toObject()
if key is 'deleted'
expect(value).toEqual(true)
else if key isnt '_id'
expect(_.isEmpty(value)).toEqual(true)
continue if key in ['_id', 'deleted', 'dateDeleted']
expect(_.isEmpty(value)).toEqual(true)
done()
describe 'Statistics', ->