mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
User name slugs can now be unset by emptying their name
This commit is contained in:
parent
a310afc750
commit
6e593b2ec0
2 changed files with 10 additions and 5 deletions
|
@ -41,9 +41,11 @@ module.exports.NamedPlugin = (schema) ->
|
|||
err.response = {message: ' is a reserved name', property: 'name'}
|
||||
err.code = 422
|
||||
return next(err)
|
||||
if newSlug not in [@get('slug'), ""] and not @get 'anonymous'
|
||||
if newSlug not in [@get('slug'), ''] and not @get 'anonymous'
|
||||
@set('slug', newSlug)
|
||||
@checkSlugConflicts(next)
|
||||
else if newSlug is '' and @get 'slug'
|
||||
@set 'slug', undefined
|
||||
else
|
||||
next()
|
||||
)
|
||||
|
|
|
@ -107,7 +107,7 @@ describe 'POST /db/user', ->
|
|||
it 'should allow setting anonymous user name', (done) ->
|
||||
createAnonNameUser('Jim', done)
|
||||
|
||||
it 'should not allow multiple anonymous users with same name anymore', (done) ->
|
||||
it 'should allow multiple anonymous users with same name', (done) ->
|
||||
createAnonNameUser('Jim', done)
|
||||
|
||||
it 'should not allow setting existing user name to anonymous user', (done) ->
|
||||
|
@ -274,9 +274,6 @@ describe 'GET /db/user', ->
|
|||
expect(response.statusCode).toBe(200)
|
||||
done()
|
||||
|
||||
# TODO Ruben should be able to fetch other users but probably with restricted data access
|
||||
# Add to the test case above an extra data check
|
||||
|
||||
it 'can fetch myself by slug completely', (done) ->
|
||||
loginSam (sam) ->
|
||||
request.get {url: getURL(urlUser + '/sam')}, (err, response) ->
|
||||
|
@ -287,6 +284,12 @@ describe 'GET /db/user', ->
|
|||
expect(guy.name).toBe sam.get 'name'
|
||||
done()
|
||||
|
||||
# TODO Ruben should be able to fetch other users but probably with restricted data access
|
||||
# Add to the test case above an extra data check
|
||||
|
||||
xit 'can unset name and undefine slug'
|
||||
|
||||
xit 'can fetch another user with restricted fields'
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue