{"action":"created","comment":{"url":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls/comments/109746279","pull_request_review_id":30868298,"id":109746279,"diff_hunk":"@@ -0,0 +1,125 @@\n+/*eslint no-unused-expressions: \"off\"*/\n+import chai from 'chai';\n+import { userDetail, roleDetail, invalidUserParams } from '../testFile';\n+import db from '../../models';\n+\n+const expect = chai.expect;\n+const should = chai.should();\n+\n+describe('User Model', () => {\n+  let user;\n+  const Role = db.Role;\n+\n+  before((done) => {\n+    Role.bulkCreate(roleDetail)\n+      .then(() => {\n+        done();\n+      });\n+  });\n+\n+  after(() => db.Role.destroy({ where: {} }));\n+\n+  describe('Create User', () => {\n+    it('should create new user', (done) => {\n+      db.User.create(userDetail[2])\n+      .then((newUser) => {\n+        user = newUser;\n+        done();\n+      });\n+    });\n+\n+    it('should be able to create a user', (done) => {\n+      user.should.be.defined;\n+      expect(typeof user).to.equal('object');\n+      done();\n+    });\n+    it('user should have username', (done) => {\n+      user.should.exist;\n+      user.should.have.property('username');\n+      done();\n+    });\n+    it('should create a user with first name & last name', (done) => {\n+      user.firstname.should.equal(userDetail[2].firstname);\n+      user.lastname.should.equal(userDetail[2].lastname);\n+      done();\n+    });\n+    it('should create a user with a valid email', (done) => {\n+      user.email.should.equal(userDetail[2].email);\n+      done();\n+    });\n+    it('should ensure that username is not null', (done) => {\n+      db.User.create(invalidUserParams[1])\n+      .catch((error) => {\n+        error.message.should.equal('notNull Violation: username cannot be null')\n+        done();\n+      });\n+    });\n+    it('should create a user with a defined role', (done) => {\n+      db.User.findById(user.id, {\n+        include: [db.Role]\n+      })\n+      .then((foundUser) => {\n+        foundUser.Role.title.should.equal('regular');\n+        done();\n+      });\n+    });\n+  });\n+\n+  describe('User validation', () => {\n+    describe('User Validation', () => {\n+      it('requires firstname field to create a user', (done) => {\n+        db.User.create(invalidUserParams[2].firstname)\n+        .catch((error) => {\n+          /notNull Violation/.test(error.message).should.be.true;\n+          done();\n+        });\n+      });\n+      it('requires email field to create a user', (done) => {\n+        db.User.create(invalidUserParams[0].email)\n+        .catch((error) => {\n+         /notNull Violation/.test(error.message).should.be.true;\n+          done();\n+        });\n+      });\n+      it('requires username field to create a user', (done) => {\n+        db.User.create(invalidUserParams[2].username)\n+        .catch((error) => {\n+          /notNull Violation/.test(error.message).should.be.true;\n+          done();\n+        });\n+      });\n+      it('ensures a user can only be created once(unique)', (done) => {\n+        db.User.create(user)\n+        .catch((error) => {\n+          /notNull Violation/.test(error.message).should.be.true;\n+          done();\n+        });\n+      });\n+      it('ensures a username can only be created once(unique)', (done) => {\n+        db.User.create(invalidUserParams[3].username)\n+        .catch((error) => {\n+          /notNull Violation/.test(error.message).should.be.true;\n+          done();\n+        });\n+      });\n+    });\n+  });\n+  ","path":"server/tests/models/users.spec.js","position":107,"original_position":107,"commit_id":"9bb921fdab1da41c618778466511611b59f26d2b","original_commit_id":"9bb921fdab1da41c618778466511611b59f26d2b","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars3.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Trailing spaces not allowed                                   no-trailing-spaces","created_at":"2017-04-04T18:45:15Z","updated_at":"2017-04-04T18:45:15Z","html_url":"https://github.com/andela-oawofadeju/document-api/pull/3#discussion_r109746279","pull_request_url":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls/comments/109746279"},"html":{"href":"https://github.com/andela-oawofadeju/document-api/pull/3#discussion_r109746279"},"pull_request":{"href":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls/3","id":113569376,"html_url":"https://github.com/andela-oawofadeju/document-api/pull/3","diff_url":"https://github.com/andela-oawofadeju/document-api/pull/3.diff","patch_url":"https://github.com/andela-oawofadeju/document-api/pull/3.patch","issue_url":"https://api.github.com/repos/andela-oawofadeju/document-api/issues/3","number":3,"state":"open","locked":false,"title":"Feature/#142286265/generate tests","user":{"login":"andela-oawofadeju","id":24937690,"avatar_url":"https://avatars2.githubusercontent.com/u/24937690?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-oawofadeju","html_url":"https://github.com/andela-oawofadeju","followers_url":"https://api.github.com/users/andela-oawofadeju/followers","following_url":"https://api.github.com/users/andela-oawofadeju/following{/other_user}","gists_url":"https://api.github.com/users/andela-oawofadeju/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-oawofadeju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-oawofadeju/subscriptions","organizations_url":"https://api.github.com/users/andela-oawofadeju/orgs","repos_url":"https://api.github.com/users/andela-oawofadeju/repos","events_url":"https://api.github.com/users/andela-oawofadeju/events{/privacy}","received_events_url":"https://api.github.com/users/andela-oawofadeju/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\n\r\nThis PR is meant to test the functionalities of the app\r\n\r\n#### Description of Task to be completed?\r\n\r\nTest all the features and functionalities of the app","created_at":"2017-03-31T03:45:28Z","updated_at":"2017-04-04T18:45:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8983e8d7a92681036148a05dba82771c13ee4df4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls/3/commits","review_comments_url":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls/3/comments","review_comment_url":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela-oawofadeju/document-api/issues/3/comments","statuses_url":"https://api.github.com/repos/andela-oawofadeju/document-api/statuses/9bb921fdab1da41c618778466511611b59f26d2b","head":{"label":"andela-oawofadeju:feature/#142286265/generate-tests","ref":"feature/#142286265/generate-tests","sha":"9bb921fdab1da41c618778466511611b59f26d2b","user":{"login":"andela-oawofadeju","id":24937690,"avatar_url":"https://avatars2.githubusercontent.com/u/24937690?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-oawofadeju","html_url":"https://github.com/andela-oawofadeju","followers_url":"https://api.github.com/users/andela-oawofadeju/followers","following_url":"https://api.github.com/users/andela-oawofadeju/following{/other_user}","gists_url":"https://api.github.com/users/andela-oawofadeju/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-oawofadeju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-oawofadeju/subscriptions","organizations_url":"https://api.github.com/users/andela-oawofadeju/orgs","repos_url":"https://api.github.com/users/andela-oawofadeju/repos","events_url":"https://api.github.com/users/andela-oawofadeju/events{/privacy}","received_events_url":"https://api.github.com/users/andela-oawofadeju/received_events","type":"User","site_admin":false},"repo":{"id":82961077,"name":"document-api","full_name":"andela-oawofadeju/document-api","owner":{"login":"andela-oawofadeju","id":24937690,"avatar_url":"https://avatars2.githubusercontent.com/u/24937690?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-oawofadeju","html_url":"https://github.com/andela-oawofadeju","followers_url":"https://api.github.com/users/andela-oawofadeju/followers","following_url":"https://api.github.com/users/andela-oawofadeju/following{/other_user}","gists_url":"https://api.github.com/users/andela-oawofadeju/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-oawofadeju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-oawofadeju/subscriptions","organizations_url":"https://api.github.com/users/andela-oawofadeju/orgs","repos_url":"https://api.github.com/users/andela-oawofadeju/repos","events_url":"https://api.github.com/users/andela-oawofadeju/events{/privacy}","received_events_url":"https://api.github.com/users/andela-oawofadeju/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-oawofadeju/document-api","description":"The system manages documents, users and user roles. Each document defines access rights; the document defines which roles can access it. Also, each document specifies the date it was published.","fork":false,"url":"https://api.github.com/repos/andela-oawofadeju/document-api","forks_url":"https://api.github.com/repos/andela-oawofadeju/document-api/forks","keys_url":"https://api.github.com/repos/andela-oawofadeju/document-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-oawofadeju/document-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-oawofadeju/document-api/teams","hooks_url":"https://api.github.com/repos/andela-oawofadeju/document-api/hooks","issue_events_url":"https://api.github.com/repos/andela-oawofadeju/document-api/issues/events{/number}","events_url":"https://api.github.com/repos/andela-oawofadeju/document-api/events","assignees_url":"https://api.github.com/repos/andela-oawofadeju/document-api/assignees{/user}","branches_url":"https://api.github.com/repos/andela-oawofadeju/document-api/branches{/branch}","tags_url":"https://api.github.com/repos/andela-oawofadeju/document-api/tags","blobs_url":"https://api.github.com/repos/andela-oawofadeju/document-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-oawofadeju/document-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-oawofadeju/document-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-oawofadeju/document-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-oawofadeju/document-api/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-oawofadeju/document-api/languages","stargazers_url":"https://api.github.com/repos/andela-oawofadeju/document-api/stargazers","contributors_url":"https://api.github.com/repos/andela-oawofadeju/document-api/contributors","subscribers_url":"https://api.github.com/repos/andela-oawofadeju/document-api/subscribers","subscription_url":"https://api.github.com/repos/andela-oawofadeju/document-api/subscription","commits_url":"https://api.github.com/repos/andela-oawofadeju/document-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-oawofadeju/document-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-oawofadeju/document-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-oawofadeju/document-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-oawofadeju/document-api/contents/{+path}","compare_url":"https://api.github.com/repos/andela-oawofadeju/document-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-oawofadeju/document-api/merges","archive_url":"https://api.github.com/repos/andela-oawofadeju/document-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-oawofadeju/document-api/downloads","issues_url":"https://api.github.com/repos/andela-oawofadeju/document-api/issues{/number}","pulls_url":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-oawofadeju/document-api/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-oawofadeju/document-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-oawofadeju/document-api/labels{/name}","releases_url":"https://api.github.com/repos/andela-oawofadeju/document-api/releases{/id}","deployments_url":"https://api.github.com/repos/andela-oawofadeju/document-api/deployments","created_at":"2017-02-23T19:03:25Z","updated_at":"2017-02-23T19:03:25Z","pushed_at":"2017-04-04T18:44:52Z","git_url":"git://github.com/andela-oawofadeju/document-api.git","ssh_url":"git@github.com:andela-oawofadeju/document-api.git","clone_url":"https://github.com/andela-oawofadeju/document-api.git","svn_url":"https://github.com/andela-oawofadeju/document-api","homepage":null,"size":105,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"andela-oawofadeju:develop","ref":"develop","sha":"d143bdc2e4610cf484a4f5ada52ad219d760d27a","user":{"login":"andela-oawofadeju","id":24937690,"avatar_url":"https://avatars2.githubusercontent.com/u/24937690?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-oawofadeju","html_url":"https://github.com/andela-oawofadeju","followers_url":"https://api.github.com/users/andela-oawofadeju/followers","following_url":"https://api.github.com/users/andela-oawofadeju/following{/other_user}","gists_url":"https://api.github.com/users/andela-oawofadeju/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-oawofadeju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-oawofadeju/subscriptions","organizations_url":"https://api.github.com/users/andela-oawofadeju/orgs","repos_url":"https://api.github.com/users/andela-oawofadeju/repos","events_url":"https://api.github.com/users/andela-oawofadeju/events{/privacy}","received_events_url":"https://api.github.com/users/andela-oawofadeju/received_events","type":"User","site_admin":false},"repo":{"id":82961077,"name":"document-api","full_name":"andela-oawofadeju/document-api","owner":{"login":"andela-oawofadeju","id":24937690,"avatar_url":"https://avatars2.githubusercontent.com/u/24937690?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-oawofadeju","html_url":"https://github.com/andela-oawofadeju","followers_url":"https://api.github.com/users/andela-oawofadeju/followers","following_url":"https://api.github.com/users/andela-oawofadeju/following{/other_user}","gists_url":"https://api.github.com/users/andela-oawofadeju/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-oawofadeju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-oawofadeju/subscriptions","organizations_url":"https://api.github.com/users/andela-oawofadeju/orgs","repos_url":"https://api.github.com/users/andela-oawofadeju/repos","events_url":"https://api.github.com/users/andela-oawofadeju/events{/privacy}","received_events_url":"https://api.github.com/users/andela-oawofadeju/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-oawofadeju/document-api","description":"The system manages documents, users and user roles. Each document defines access rights; the document defines which roles can access it. Also, each document specifies the date it was published.","fork":false,"url":"https://api.github.com/repos/andela-oawofadeju/document-api","forks_url":"https://api.github.com/repos/andela-oawofadeju/document-api/forks","keys_url":"https://api.github.com/repos/andela-oawofadeju/document-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-oawofadeju/document-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-oawofadeju/document-api/teams","hooks_url":"https://api.github.com/repos/andela-oawofadeju/document-api/hooks","issue_events_url":"https://api.github.com/repos/andela-oawofadeju/document-api/issues/events{/number}","events_url":"https://api.github.com/repos/andela-oawofadeju/document-api/events","assignees_url":"https://api.github.com/repos/andela-oawofadeju/document-api/assignees{/user}","branches_url":"https://api.github.com/repos/andela-oawofadeju/document-api/branches{/branch}","tags_url":"https://api.github.com/repos/andela-oawofadeju/document-api/tags","blobs_url":"https://api.github.com/repos/andela-oawofadeju/document-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-oawofadeju/document-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-oawofadeju/document-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-oawofadeju/document-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-oawofadeju/document-api/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-oawofadeju/document-api/languages","stargazers_url":"https://api.github.com/repos/andela-oawofadeju/document-api/stargazers","contributors_url":"https://api.github.com/repos/andela-oawofadeju/document-api/contributors","subscribers_url":"https://api.github.com/repos/andela-oawofadeju/document-api/subscribers","subscription_url":"https://api.github.com/repos/andela-oawofadeju/document-api/subscription","commits_url":"https://api.github.com/repos/andela-oawofadeju/document-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-oawofadeju/document-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-oawofadeju/document-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-oawofadeju/document-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-oawofadeju/document-api/contents/{+path}","compare_url":"https://api.github.com/repos/andela-oawofadeju/document-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-oawofadeju/document-api/merges","archive_url":"https://api.github.com/repos/andela-oawofadeju/document-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-oawofadeju/document-api/downloads","issues_url":"https://api.github.com/repos/andela-oawofadeju/document-api/issues{/number}","pulls_url":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-oawofadeju/document-api/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-oawofadeju/document-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-oawofadeju/document-api/labels{/name}","releases_url":"https://api.github.com/repos/andela-oawofadeju/document-api/releases{/id}","deployments_url":"https://api.github.com/repos/andela-oawofadeju/document-api/deployments","created_at":"2017-02-23T19:03:25Z","updated_at":"2017-02-23T19:03:25Z","pushed_at":"2017-04-04T18:44:52Z","git_url":"git://github.com/andela-oawofadeju/document-api.git","ssh_url":"git@github.com:andela-oawofadeju/document-api.git","clone_url":"https://github.com/andela-oawofadeju/document-api.git","svn_url":"https://github.com/andela-oawofadeju/document-api","homepage":null,"size":105,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls/3"},"html":{"href":"https://github.com/andela-oawofadeju/document-api/pull/3"},"issue":{"href":"https://api.github.com/repos/andela-oawofadeju/document-api/issues/3"},"comments":{"href":"https://api.github.com/repos/andela-oawofadeju/document-api/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela-oawofadeju/document-api/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/andela-oawofadeju/document-api/statuses/9bb921fdab1da41c618778466511611b59f26d2b"}}}}
{"actor":{"display_login":"houndci-bot"}}