From 6e593b2ec0efe7fc16460981e74ea645d0ccb53b Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Thu, 10 Jul 2014 10:46:34 +0200 Subject: [PATCH] User name slugs can now be unset by emptying their name --- server/plugins/plugins.coffee | 4 +++- test/server/functional/user.spec.coffee | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/server/plugins/plugins.coffee b/server/plugins/plugins.coffee index 872df064a..7716f0d98 100644 --- a/server/plugins/plugins.coffee +++ b/server/plugins/plugins.coffee @@ -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() ) diff --git a/test/server/functional/user.spec.coffee b/test/server/functional/user.spec.coffee index 4b0e4ffca..b60b944f4 100644 --- a/test/server/functional/user.spec.coffee +++ b/test/server/functional/user.spec.coffee @@ -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'