mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-17 19:12:33 -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'
|
earned: c.RewardSchema 'earned by achievements'
|
||||||
purchased: c.RewardSchema 'purchased with gems or money'
|
purchased: c.RewardSchema 'purchased with gems or money'
|
||||||
deleted: {type: 'boolean'}
|
deleted: {type: 'boolean'}
|
||||||
|
dateDeleted: c.date()
|
||||||
spent: {type: 'number'}
|
spent: {type: 'number'}
|
||||||
stripeCustomerID: { type: 'string' } # TODO: Migrate away from this property
|
stripeCustomerID: { type: 'string' } # TODO: Migrate away from this property
|
||||||
|
|
||||||
|
|
|
@ -279,6 +279,7 @@ UserHandler = class UserHandler extends Handler
|
||||||
obj = user.toObject()
|
obj = user.toObject()
|
||||||
for prop, val of obj
|
for prop, val of obj
|
||||||
user.set(prop, undefined) unless prop is '_id'
|
user.set(prop, undefined) unless prop is '_id'
|
||||||
|
user.set('dateDeleted', new Date())
|
||||||
user.set('deleted', true)
|
user.set('deleted', true)
|
||||||
|
|
||||||
# Hack to get saving of Users to work. Probably should replace these props with strings
|
# 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', ->
|
describe 'DELETE /db/user', ->
|
||||||
it 'can delete a user', (done) ->
|
it 'can delete a user', (done) ->
|
||||||
loginNewUser (user1) ->
|
loginNewUser (user1) ->
|
||||||
|
beforeDeleted = new Date()
|
||||||
request.del {uri: "#{getURL(urlUser)}/#{user1.id}"}, (err, res) ->
|
request.del {uri: "#{getURL(urlUser)}/#{user1.id}"}, (err, res) ->
|
||||||
expect(err).toBeNull()
|
expect(err).toBeNull()
|
||||||
return done() if err
|
return done() if err
|
||||||
|
@ -338,10 +339,10 @@ describe 'DELETE /db/user', ->
|
||||||
expect(err).toBeNull()
|
expect(err).toBeNull()
|
||||||
return done() if err
|
return done() if err
|
||||||
expect(user1.get('deleted')).toBe(true)
|
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()
|
for key, value of user1.toObject()
|
||||||
if key is 'deleted'
|
continue if key in ['_id', 'deleted', 'dateDeleted']
|
||||||
expect(value).toEqual(true)
|
|
||||||
else if key isnt '_id'
|
|
||||||
expect(_.isEmpty(value)).toEqual(true)
|
expect(_.isEmpty(value)).toEqual(true)
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue