{"action":"created","comment":{"url":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls/comments/36029236","id":36029236,"diff_hunk":"@@ -0,0 +1,242 @@\n+var should = require('should');\n+var assert = require('assert');\n+var request = require('supertest');\n+var mongoose = require('mongoose');\n+if(!mongoose.connection.readyState) {\n+  mongoose.connect('localhost:27017'); //Connect to our database\n+}\n+\n+var User = require('../../app/models/user');\n+\n+var url = 'localhost:8080';\n+/*\n+  Create : \n+    missing field\n+    wrong email\n+    good\n+  Read :\n+    wrong\n+    good\n+  Update :\n+    wrong email\n+    wrong id\n+    good\n+  Delete\n+    good\n+    wrong\n+*/\n+describe('User', function() {\n+  describe('Create', function() {\n+    beforeEach(function() {\n+      User.find({name:'testUser'}).remove().exec();\n+    });\n+    afterEach(function() {\n+      User.find({name:'testUser'}).remove().exec();\n+    });\n+    \n+    it('should return error trying to create a user missing an attribute', function(done) {\n+      var profile = {\n+        \"name\" : \"testUser\",\n+        \"password\" : \"wow\",\n+        \"email\" : \"legit@legit.com\",\n+        \"characters\" : []\n+      };\n+      request(url)\n+        .post('/user')\n+        .send(profile)\n+        .expect(400) //Status code\n+        .end(function(err, res) {\n+          should.not.exist(err);\n+          res.body.should.have.property('message', 'User validation failed');\n+          res.body.should.have.property('name', 'ValidationError');\n+          done();\n+      });\n+    });\n+    \n+    it('should return error trying to create a user with wrong email', function(done) {\n+      \n+      var profile = {\n+        \"name\" : \"testUser\",\n+        \"phone\" : \"514 \",\n+        \"password\" : \"wow\",\n+        \"email\" : \"legit@com\",\n+        \"characters\" : []\n+      };\n+      request(url)\n+        .post('/user')\n+        .send(profile)\n+        .expect(400) //Status code\n+        .end(function(err, res) {\n+          should.not.exist(err);\n+          res.body.should.have.property('message', 'User validation failed');\n+          res.body.should.have.property('name', 'ValidationError');\n+          done();\n+      });\n+    });\n+    \n+    it('should succeed user creation', function(done) {\n+      var profile = {\n+        \"name\" : \"testUser\",\n+        \"phone\" : \"514 \",\n+        \"password\" : \"wow\",\n+        \"email\" : \"legit@legit.com\",\n+        \"characters\" : []\n+      };\n+      request(url)\n+        .post('/user')\n+        .send(profile)\n+        .expect(200) //Status code\n+        .end(function(err, res) {\n+          should.not.exist(err);\n+          res.body.should.have.property('message', 'User created!');\n+          done();\n+      });\n+    });\n+    \n+  });\n+  \n+  describe('Read', function() {\n+    var userId = null;\n+    before(function(done) {\n+      var user = new User();\n+      user.name = 'testUser';\n+      user.phone = 'Testland';\n+      user.email = 'something@something.com';\n+      user.hashPassword = 'password';\n+        user.save(\n+          function(err, res){\n+            userId = res._id;\n+            should.not.exist(err);\n+            done();\n+          });\n+    });\n+    after(function() {\n+      User.find({name:'testUser'}).remove().exec();\n+    });\n+    \n+    it('should return error trying to read wrong id', function(done) {\n+      request(url)\n+        .get('/user/lol')\n+        .expect(404) //Status code\n+        .end(function(err, res) {\n+          should.not.exist(err);\n+          res.body.should.have.property('message', 'User not found');\n+          done();\n+      });\n+    });\n+    \n+    it('should succeed user read', function(done) {\n+      request(url)\n+        .get('/user/' + userId)\n+        .expect(200) //Status code\n+        .end(function(err, res) {\n+          should.not.exist(err);\n+          should.exist(res);\n+          done();\n+      });\n+    });\n+  });\n+  \n+  describe('Patch', function() {\n+    var userId = null;\n+    before(function(done) {\n+      var user = new User();\n+      user.name = 'testUser';\n+      user.phone = 'Testland';\n+      user.email = 'something@something.com';\n+      user.hashPassword = 'password';\n+        user.save(\n+          function(err, res){\n+            userId = res._id;\n+            should.not.exist(err);\n+            done();\n+          });\n+    });\n+    after(function() {\n+      User.find({name:'testUser'}).remove().exec();\n+    });\n+\n+    it('should be able to patch the user', function(done) {\n+      request(url)\n+        .patch('/user/')\n+        .send({\"email\" : \"yolo@yolo.com\", \"_id\" : userId})\n+        .expect(200) //Status code\n+        .end(function(err, res) {\n+          should.not.exist(err);\n+          should.exist(res);\n+          res.body.user.should.have.property('email', 'yolo@yolo.com');\n+          done();\n+      });\n+    });\n+    \n+     it('should not be able to patch the user with a wrong email', function(done) {\n+      request(url)\n+        .patch('/user/')\n+        .send({\"email\" : \"yoloyolo.com\", \"_id\" : userId})\n+        .expect(400) //Status code\n+        .end(function(err, res) {\n+          should.not.exist(err);\n+          should.exist(res);\n+          res.body.should.have.property('message', 'User validation failed');\n+          res.body.should.have.property('name', 'ValidationError');\n+          done();\n+      });\n+    });\n+     it('should not be able to patch the user with a wrong email', function(done) {","path":"backend/test/integration/user.js","position":185,"original_position":185,"commit_id":"d637c7833389c73d89158d6dde3826f7c0ccc748","original_commit_id":"d637c7833389c73d89158d6dde3826f7c0ccc748","user":{"login":"MicLamb","id":6540007,"avatar_url":"https://avatars.githubusercontent.com/u/6540007?v=3","gravatar_id":"","url":"https://api.github.com/users/MicLamb","html_url":"https://github.com/MicLamb","followers_url":"https://api.github.com/users/MicLamb/followers","following_url":"https://api.github.com/users/MicLamb/following{/other_user}","gists_url":"https://api.github.com/users/MicLamb/gists{/gist_id}","starred_url":"https://api.github.com/users/MicLamb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MicLamb/subscriptions","organizations_url":"https://api.github.com/users/MicLamb/orgs","repos_url":"https://api.github.com/users/MicLamb/repos","events_url":"https://api.github.com/users/MicLamb/events{/privacy}","received_events_url":"https://api.github.com/users/MicLamb/received_events","type":"User","site_admin":false},"body":"It is the test for the wrong id?","created_at":"2015-08-01T01:55:38Z","updated_at":"2015-08-01T01:55:38Z","html_url":"https://github.com/DrPandemic/mcoo-gn/pull/44#discussion_r36029236","pull_request_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls/44","_links":{"self":{"href":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls/comments/36029236"},"html":{"href":"https://github.com/DrPandemic/mcoo-gn/pull/44#discussion_r36029236"},"pull_request":{"href":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls/44"}}},"pull_request":{"url":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls/44","id":41347520,"html_url":"https://github.com/DrPandemic/mcoo-gn/pull/44","diff_url":"https://github.com/DrPandemic/mcoo-gn/pull/44.diff","patch_url":"https://github.com/DrPandemic/mcoo-gn/pull/44.patch","issue_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/issues/44","number":44,"state":"open","locked":false,"title":"User CRUD","user":{"login":"Erikad94","id":8824239,"avatar_url":"https://avatars.githubusercontent.com/u/8824239?v=3","gravatar_id":"","url":"https://api.github.com/users/Erikad94","html_url":"https://github.com/Erikad94","followers_url":"https://api.github.com/users/Erikad94/followers","following_url":"https://api.github.com/users/Erikad94/following{/other_user}","gists_url":"https://api.github.com/users/Erikad94/gists{/gist_id}","starred_url":"https://api.github.com/users/Erikad94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Erikad94/subscriptions","organizations_url":"https://api.github.com/users/Erikad94/orgs","repos_url":"https://api.github.com/users/Erikad94/repos","events_url":"https://api.github.com/users/Erikad94/events{/privacy}","received_events_url":"https://api.github.com/users/Erikad94/received_events","type":"User","site_admin":false},"body":"Nous avons ajouté le CRUD user et les tests d'intégrations","created_at":"2015-07-31T14:56:23Z","updated_at":"2015-08-01T01:55:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0e64194ac55569524f7d486b1221a24d1dc7354","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls/44/commits","review_comments_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls/44/comments","review_comment_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/issues/44/comments","statuses_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/statuses/d637c7833389c73d89158d6dde3826f7c0ccc748","head":{"label":"Erikad94:master","ref":"master","sha":"d637c7833389c73d89158d6dde3826f7c0ccc748","user":{"login":"Erikad94","id":8824239,"avatar_url":"https://avatars.githubusercontent.com/u/8824239?v=3","gravatar_id":"","url":"https://api.github.com/users/Erikad94","html_url":"https://github.com/Erikad94","followers_url":"https://api.github.com/users/Erikad94/followers","following_url":"https://api.github.com/users/Erikad94/following{/other_user}","gists_url":"https://api.github.com/users/Erikad94/gists{/gist_id}","starred_url":"https://api.github.com/users/Erikad94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Erikad94/subscriptions","organizations_url":"https://api.github.com/users/Erikad94/orgs","repos_url":"https://api.github.com/users/Erikad94/repos","events_url":"https://api.github.com/users/Erikad94/events{/privacy}","received_events_url":"https://api.github.com/users/Erikad94/received_events","type":"User","site_admin":false},"repo":{"id":38577610,"name":"mcoo-gn","full_name":"Erikad94/mcoo-gn","owner":{"login":"Erikad94","id":8824239,"avatar_url":"https://avatars.githubusercontent.com/u/8824239?v=3","gravatar_id":"","url":"https://api.github.com/users/Erikad94","html_url":"https://github.com/Erikad94","followers_url":"https://api.github.com/users/Erikad94/followers","following_url":"https://api.github.com/users/Erikad94/following{/other_user}","gists_url":"https://api.github.com/users/Erikad94/gists{/gist_id}","starred_url":"https://api.github.com/users/Erikad94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Erikad94/subscriptions","organizations_url":"https://api.github.com/users/Erikad94/orgs","repos_url":"https://api.github.com/users/Erikad94/repos","events_url":"https://api.github.com/users/Erikad94/events{/privacy}","received_events_url":"https://api.github.com/users/Erikad94/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Erikad94/mcoo-gn","description":"","fork":true,"url":"https://api.github.com/repos/Erikad94/mcoo-gn","forks_url":"https://api.github.com/repos/Erikad94/mcoo-gn/forks","keys_url":"https://api.github.com/repos/Erikad94/mcoo-gn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Erikad94/mcoo-gn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Erikad94/mcoo-gn/teams","hooks_url":"https://api.github.com/repos/Erikad94/mcoo-gn/hooks","issue_events_url":"https://api.github.com/repos/Erikad94/mcoo-gn/issues/events{/number}","events_url":"https://api.github.com/repos/Erikad94/mcoo-gn/events","assignees_url":"https://api.github.com/repos/Erikad94/mcoo-gn/assignees{/user}","branches_url":"https://api.github.com/repos/Erikad94/mcoo-gn/branches{/branch}","tags_url":"https://api.github.com/repos/Erikad94/mcoo-gn/tags","blobs_url":"https://api.github.com/repos/Erikad94/mcoo-gn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Erikad94/mcoo-gn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Erikad94/mcoo-gn/git/refs{/sha}","trees_url":"https://api.github.com/repos/Erikad94/mcoo-gn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Erikad94/mcoo-gn/statuses/{sha}","languages_url":"https://api.github.com/repos/Erikad94/mcoo-gn/languages","stargazers_url":"https://api.github.com/repos/Erikad94/mcoo-gn/stargazers","contributors_url":"https://api.github.com/repos/Erikad94/mcoo-gn/contributors","subscribers_url":"https://api.github.com/repos/Erikad94/mcoo-gn/subscribers","subscription_url":"https://api.github.com/repos/Erikad94/mcoo-gn/subscription","commits_url":"https://api.github.com/repos/Erikad94/mcoo-gn/commits{/sha}","git_commits_url":"https://api.github.com/repos/Erikad94/mcoo-gn/git/commits{/sha}","comments_url":"https://api.github.com/repos/Erikad94/mcoo-gn/comments{/number}","issue_comment_url":"https://api.github.com/repos/Erikad94/mcoo-gn/issues/comments{/number}","contents_url":"https://api.github.com/repos/Erikad94/mcoo-gn/contents/{+path}","compare_url":"https://api.github.com/repos/Erikad94/mcoo-gn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Erikad94/mcoo-gn/merges","archive_url":"https://api.github.com/repos/Erikad94/mcoo-gn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Erikad94/mcoo-gn/downloads","issues_url":"https://api.github.com/repos/Erikad94/mcoo-gn/issues{/number}","pulls_url":"https://api.github.com/repos/Erikad94/mcoo-gn/pulls{/number}","milestones_url":"https://api.github.com/repos/Erikad94/mcoo-gn/milestones{/number}","notifications_url":"https://api.github.com/repos/Erikad94/mcoo-gn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Erikad94/mcoo-gn/labels{/name}","releases_url":"https://api.github.com/repos/Erikad94/mcoo-gn/releases{/id}","created_at":"2015-07-05T17:29:59Z","updated_at":"2015-07-15T17:55:25Z","pushed_at":"2015-07-31T14:52:41Z","git_url":"git://github.com/Erikad94/mcoo-gn.git","ssh_url":"git@github.com:Erikad94/mcoo-gn.git","clone_url":"https://github.com/Erikad94/mcoo-gn.git","svn_url":"https://github.com/Erikad94/mcoo-gn","homepage":null,"size":215,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"DrPandemic:master","ref":"master","sha":"5e8b7502b2a219a3cb2a9c958c29295579b83027","user":{"login":"DrPandemic","id":3250155,"avatar_url":"https://avatars.githubusercontent.com/u/3250155?v=3","gravatar_id":"","url":"https://api.github.com/users/DrPandemic","html_url":"https://github.com/DrPandemic","followers_url":"https://api.github.com/users/DrPandemic/followers","following_url":"https://api.github.com/users/DrPandemic/following{/other_user}","gists_url":"https://api.github.com/users/DrPandemic/gists{/gist_id}","starred_url":"https://api.github.com/users/DrPandemic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrPandemic/subscriptions","organizations_url":"https://api.github.com/users/DrPandemic/orgs","repos_url":"https://api.github.com/users/DrPandemic/repos","events_url":"https://api.github.com/users/DrPandemic/events{/privacy}","received_events_url":"https://api.github.com/users/DrPandemic/received_events","type":"User","site_admin":false},"repo":{"id":38573882,"name":"mcoo-gn","full_name":"DrPandemic/mcoo-gn","owner":{"login":"DrPandemic","id":3250155,"avatar_url":"https://avatars.githubusercontent.com/u/3250155?v=3","gravatar_id":"","url":"https://api.github.com/users/DrPandemic","html_url":"https://github.com/DrPandemic","followers_url":"https://api.github.com/users/DrPandemic/followers","following_url":"https://api.github.com/users/DrPandemic/following{/other_user}","gists_url":"https://api.github.com/users/DrPandemic/gists{/gist_id}","starred_url":"https://api.github.com/users/DrPandemic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrPandemic/subscriptions","organizations_url":"https://api.github.com/users/DrPandemic/orgs","repos_url":"https://api.github.com/users/DrPandemic/repos","events_url":"https://api.github.com/users/DrPandemic/events{/privacy}","received_events_url":"https://api.github.com/users/DrPandemic/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DrPandemic/mcoo-gn","description":"","fork":false,"url":"https://api.github.com/repos/DrPandemic/mcoo-gn","forks_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/forks","keys_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/teams","hooks_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/hooks","issue_events_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/issues/events{/number}","events_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/events","assignees_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/assignees{/user}","branches_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/branches{/branch}","tags_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/tags","blobs_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/git/refs{/sha}","trees_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/statuses/{sha}","languages_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/languages","stargazers_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/stargazers","contributors_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/contributors","subscribers_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/subscribers","subscription_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/subscription","commits_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/commits{/sha}","git_commits_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/git/commits{/sha}","comments_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/comments{/number}","issue_comment_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/issues/comments{/number}","contents_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/contents/{+path}","compare_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/merges","archive_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/downloads","issues_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/issues{/number}","pulls_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls{/number}","milestones_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/milestones{/number}","notifications_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/labels{/name}","releases_url":"https://api.github.com/repos/DrPandemic/mcoo-gn/releases{/id}","created_at":"2015-07-05T15:30:29Z","updated_at":"2015-07-28T00:47:54Z","pushed_at":"2015-07-31T14:56:24Z","git_url":"git://github.com/DrPandemic/mcoo-gn.git","ssh_url":"git@github.com:DrPandemic/mcoo-gn.git","clone_url":"https://github.com/DrPandemic/mcoo-gn.git","svn_url":"https://github.com/DrPandemic/mcoo-gn","homepage":null,"size":472,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":12,"forks":7,"open_issues":12,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls/44"},"html":{"href":"https://github.com/DrPandemic/mcoo-gn/pull/44"},"issue":{"href":"https://api.github.com/repos/DrPandemic/mcoo-gn/issues/44"},"comments":{"href":"https://api.github.com/repos/DrPandemic/mcoo-gn/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DrPandemic/mcoo-gn/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/DrPandemic/mcoo-gn/statuses/d637c7833389c73d89158d6dde3826f7c0ccc748"}}}}