From e20408c248839a7544ab074741b542883a24ab09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Moratinos?= Date: Thu, 9 Jan 2014 22:36:06 +0100 Subject: [PATCH] We can now run all test on the server. 99 tests, 220 assertions, 13 failures 2 tests are disabled in file.spec.coffee because they cause a fatal error. --- test/server/file.spec.coffee | 39 ++++++++++++++----- test/server/handlers/level_system.spec.coffee | 2 +- test/server/handlers/user.spec.coffee | 3 +- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/test/server/file.spec.coffee b/test/server/file.spec.coffee index eebf36af0..59fb69a30 100644 --- a/test/server/file.spec.coffee +++ b/test/server/file.spec.coffee @@ -7,8 +7,9 @@ describe '/file', -> it 'deletes all the files first', (done) -> dropGridFS -> done() - - it 'posts good', (done) -> + + + it 'no admin users can\'t post files', (done) -> options = { uri:url json: { @@ -18,12 +19,31 @@ describe '/file', -> description: 'None!' } } - + + func = (err, res, body) -> + expect(res.statusCode).toBe(403) + expect(body.metadata).toBeUndefined() + done() + + request.post(options, func) + +# FIXME fatal error + xit 'posts good', (done) -> + options = { + uri:url + json: { + url: 'http://scotterickson.info/images/where-are-you.jpg' + filename: 'where-are-you.jpg' + mimetype: 'image/jpeg' + description: 'None!' + } + } + func = (err, res, body) -> expect(res.statusCode).toBe(200) expect(body.metadata.description).toBe('None!') files.push(body) - + collection = mongoose.connection.db.collection('media.files') collection.findOne {}, (err, result) -> expect(result.metadata.name).toBe('Where are you') @@ -49,17 +69,18 @@ describe '/file', -> request.get {uri:url+'/thiswillnotwork'}, (err, res) -> expect(res.statusCode).toBe(404) done() - - it 'posts data directly', (done) -> + +# FIXME fatal error + xit 'posts data directly', (done) -> options = { uri:url } - + func = (err, res, body) -> expect(res.statusCode).toBe(200) body = JSON.parse(body) - + expect(body.metadata.description).toBe('rando-info') files.push(body) @@ -67,7 +88,7 @@ describe '/file', -> collection.find({_id:mongoose.Types.ObjectId(body._id)}).toArray (err, results) -> expect(results[0].metadata.name).toBe('Ittybitty') done() - + # the only way I could figure out how to get request to do what I wanted... r = request.post(options, func) form = r.form() diff --git a/test/server/handlers/level_system.spec.coffee b/test/server/handlers/level_system.spec.coffee index 19fc29725..f24accceb 100644 --- a/test/server/handlers/level_system.spec.coffee +++ b/test/server/handlers/level_system.spec.coffee @@ -24,7 +24,7 @@ describe 'LevelSystem', -> it 'can make a LevelSystem, without setting official.', (done) -> loginJoe (joe) -> - request.post {uri:url, json:system}, (err, res, body) -> + request.post {uri:url, json:systems}, (err, res, body) -> expect(res.statusCode).toBe(200) expect(body.official).toBeUndefined() systems[0] = body diff --git a/test/server/handlers/user.spec.coffee b/test/server/handlers/user.spec.coffee index 6d1e126b8..676fffe9c 100644 --- a/test/server/handlers/user.spec.coffee +++ b/test/server/handlers/user.spec.coffee @@ -81,7 +81,8 @@ describe 'PUT /db/user', -> done() form = req.form() form.append('_id', joe.id) - form.append('email', "farghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghl") + form.append('email', "farghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlar +ghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghlfarghlarghl") it 'logs in as admin', (done) -> loginAdmin -> done()