From b4d9a787f0fffafd99dcc88d46580cbb32e0e3e5 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Fri, 29 Aug 2014 16:28:07 -0700 Subject: [PATCH] Fixed the rest of the server tests. --- app/schemas/models/achievement.coffee | 2 +- test/server/functional/article.spec.coffee | 2 +- test/server/functional/level_component.spec.coffee | 8 +++----- test/server/functional/level_system.spec.coffee | 6 ++---- test/server/functional/patch.spec.coffee | 4 ++-- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/schemas/models/achievement.coffee b/app/schemas/models/achievement.coffee index 4f5181f92..fe45e03b5 100644 --- a/app/schemas/models/achievement.coffee +++ b/app/schemas/models/achievement.coffee @@ -73,7 +73,7 @@ _.extend AchievementSchema.properties, kind: {enum: ['linear', 'logarithmic', 'quadratic'] } parameters: type: 'object' - default: { a: 1, b: 1, c: 1 } + default: { a: 1, b: 0, c: 0 } properties: a: {type: 'number' } b: {type: 'number' } diff --git a/test/server/functional/article.spec.coffee b/test/server/functional/article.spec.coffee index e17f241ea..acc7aab2b 100644 --- a/test/server/functional/article.spec.coffee +++ b/test/server/functional/article.spec.coffee @@ -117,7 +117,7 @@ describe '/db/article', -> request.get {uri: url + '?project=true', json: {}}, (err, res, body) -> expect(res.statusCode).toBe(200) expect(body.length).toBe(2) - expect(body[0].created).toBeUndefined() + expect(body[0].body).toBeUndefined() expect(body[0].version).toBeDefined() # custom projection diff --git a/test/server/functional/level_component.spec.coffee b/test/server/functional/level_component.spec.coffee index 697c14df7..a0c3b33e8 100644 --- a/test/server/functional/level_component.spec.coffee +++ b/test/server/functional/level_component.spec.coffee @@ -65,11 +65,9 @@ describe 'LevelComponent', -> expect(body.code).toBe(components[0].code) expect(body.codeLanguage).toBe(components[0].codeLanguage) expect(body.__v).toBe(0) - expect(body.official).toBeDefined() expect(body.creator).toBeDefined() expect(body.original).toBeDefined() expect(body.created).toBeDefined() - expect(body.configSchema).toBeDefined() expect(body.dependencies).toBeDefined() expect(body.propertyDocumentation).toBeDefined() expect(body.version.isLatestMajor).toBe(true) @@ -83,7 +81,7 @@ describe 'LevelComponent', -> expect(res.statusCode).toBe(200) body = JSON.parse(body) expect(body._id).toBe(components[0]._id) - expect(body.official).toBe(false) + expect(body.official).toBeUndefined() done() it 'has system ai by default', (done) -> @@ -100,7 +98,7 @@ describe 'LevelComponent', -> loginJoe -> request.post {uri: url, json: components[0]}, (err, res, body) -> expect(res.statusCode).toBe(200) - expect(body.official).toBe(false) + expect(body.official).toBeUndefined() done() it 'official property is editable by an admin.', (done) -> @@ -118,7 +116,7 @@ describe 'LevelComponent', -> expect(res.statusCode).toBe(200) body = JSON.parse(body) expect(body._id).toBe(components[0]._id) - expect(body.official).toBe(false) + expect(body.official).toBeUndefined() expect(body.version.isLatestMinor).toBe(false) expect(body.version.isLatestMajor).toBe(false) done() diff --git a/test/server/functional/level_system.spec.coffee b/test/server/functional/level_system.spec.coffee index 7d5c1e488..669fe5c4c 100644 --- a/test/server/functional/level_system.spec.coffee +++ b/test/server/functional/level_system.spec.coffee @@ -73,11 +73,9 @@ describe 'LevelSystem', -> expect(body.code).toBe(systems[0].code) expect(body.codeLanguage).toBe(systems[0].codeLanguage) expect(body.__v).toBe(0) - expect(body.official).toBeDefined() expect(body.creator).toBeDefined() expect(body.original).toBeDefined() expect(body.created).toBeDefined() - expect(body.configSchema).toBeDefined() expect(body.dependencies).toBeDefined() expect(body.propertyDocumentation).toBeDefined() expect(body.version.isLatestMajor).toBe(true) @@ -91,7 +89,7 @@ describe 'LevelSystem', -> expect(res.statusCode).toBe(200) body = JSON.parse(body) expect(body._id).toBe(systems[0]._id) - expect(body.official).toBe(false) + expect(body.official).toBeUndefined() done() it 'official property isn\'t editable by an ordinary user.', (done) -> @@ -116,7 +114,7 @@ describe 'LevelSystem', -> expect(res.statusCode).toBe(200) body = JSON.parse(body) expect(body._id).toBe(systems[0]._id) - expect(body.official).toBe(false) + expect(body.official).toBeUndefined() expect(body.version.isLatestMinor).toBe(false) expect(body.version.isLatestMajor).toBe(false) done() diff --git a/test/server/functional/patch.spec.coffee b/test/server/functional/patch.spec.coffee index 08eaac60c..c17a81774 100644 --- a/test/server/functional/patch.spec.coffee +++ b/test/server/functional/patch.spec.coffee @@ -71,13 +71,13 @@ describe '/db/patch', -> it 'does not add duplicate watchers', (done) -> watchingURL = getURL("/db/article/#{articles[0]._id}/watch") request.put {uri: watchingURL, json: {on: true}}, (err, res, body) -> - expect(body.watchers.length).toBe(2) + expect(body.watchers.length).toBe(4) done() it 'allows removing yourself', (done) -> watchingURL = getURL("/db/article/#{articles[0]._id}/watch") request.put {uri: watchingURL, json: {on: false}}, (err, res, body) -> - expect(body.watchers.length).toBe(1) + expect(body.watchers.length).toBe(3) done() it 'allows the submitter to withdraw the pull request', (done) ->