mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
parent
72e458cc80
commit
b12b7e8ca4
3 changed files with 7 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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', ->
|
||||
|
|
Loading…
Reference in a new issue