mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 00:40:56 -05:00
Added a test case for unsetting slugs (and fixed related bug)
This commit is contained in:
parent
94210fc461
commit
9e296b7c3d
2 changed files with 17 additions and 2 deletions
|
@ -46,6 +46,7 @@ module.exports.NamedPlugin = (schema) ->
|
|||
@checkSlugConflicts(next)
|
||||
else if newSlug is '' and @get 'slug'
|
||||
@set 'slug', undefined
|
||||
next()
|
||||
else
|
||||
next()
|
||||
)
|
||||
|
|
|
@ -209,6 +209,7 @@ ghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghl
|
|||
expect(err).toBeNull()
|
||||
expect(response.statusCode).toBe 409
|
||||
|
||||
# Restore Sam
|
||||
sam.set 'name', samsName
|
||||
done()
|
||||
|
||||
|
@ -234,6 +235,21 @@ ghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghl
|
|||
form = req.form()
|
||||
form.append('name', 'admin')
|
||||
|
||||
it 'should be able to unset a slug by setting an empty name', (done) ->
|
||||
loginSam (sam) ->
|
||||
samsName = sam.get 'name'
|
||||
sam.set 'name', ''
|
||||
request.put {uri:getURL(urlUser + '/' + sam.id), json: sam.toObject()}, (err, response) ->
|
||||
expect(err).toBeNull()
|
||||
expect(response.statusCode).toBe 200
|
||||
newSam = response.body
|
||||
|
||||
# Restore Sam
|
||||
sam.set 'name', samsName
|
||||
request.put {uri:getURL(urlUser + '/' + sam.id), json: sam.toObject()}, (err, response) ->
|
||||
expect(err).toBeNull()
|
||||
done()
|
||||
|
||||
describe 'GET /db/user', ->
|
||||
|
||||
it 'logs in as admin', (done) ->
|
||||
|
@ -309,8 +325,6 @@ describe 'GET /db/user', ->
|
|||
# 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