{"action":"created","comment":{"url":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls/comments/79586538","id":79586538,"diff_hunk":"@@ -0,0 +1,211 @@\n+const app = require('../../index');\n+const request = require('supertest')(app);\n+const Document = require('../../server/models/document');\n+\n+describe('Document tests', () => {\n+  // Before all tests, log in Victor Hugo\n+  let token;\n+\n+  beforeAll((done) => {\n+    request\n+    .post('/api/login')\n+    .send({\n+      username: 'vichugo',\n+      password: 'victorhugo',\n+    })\n+    .end((err, res) => {\n+      token = res.body.token;\n+      done();\n+    });\n+  });\n+\n+  it('Should validate that a new document created has a published date defined', (done) => {\n+    const datePublished = Document.schema.path('createdAt');\n+    expect(datePublished).toBeDefined();\n+    done();\n+  });\n+\n+  it('Should validate that a user can create documents', (done) => {\n+    request\n+    .post('/api/documents')\n+    .set('x-access-token', token)\n+    .send({\n+      title: 'An idea',\n+      content: 'Whose time has come',\n+      privacy: 'private',\n+    })\n+    .end((err, res) => {\n+      expect(res.status).toBe(201);\n+      expect(res.body.message).toBe('Document created successfully');\n+      done();\n+    });\n+  });\n+\n+  it('Should validate that all public and the users\\' own documents are returned', (done) => {\n+    request\n+    .get('/api/documents')\n+    .set('x-access-token', token)\n+    .end((err, res) => {\n+      expect(res.status).toBe(200);\n+      expect(res.body).toBeDefined();\n+      expect(Array.isArray(res.body)).toBe(true);\n+      done();\n+    });\n+  });\n+\n+  it('Should get a document by its id provided it belongs to the logged in user ', () => {\n+    request\n+    .get('/api/documents/57c975eb2c3d08864b51cd08')\n+    .set('x-access-token', token)\n+    .end((err, res) => {\n+      expect(res.status).toBe(200);\n+      expect(res.status).not.toBe(401);\n+    });\n+  });\n+\n+  it('Should validate that a user can update the content of their own documents', (done) => {\n+    request\n+    .put('/api/documents/57c975eb2c3d08864b51cd08')\n+    .set('x-access-token', token)\n+    .send({\n+      content: 'It was the best of times, it was the worst of times. It was the age of wisdom, it was the age of...',\n+    })\n+    .end((err, res) => {\n+      expect(res.status).toBe(200);\n+      expect(res.status).not.toBe(401);\n+      expect(res.body.message).toBe('Document details updated successfully');\n+      done();\n+    });\n+  });\n+\n+  // it('Should validate that a user can update the privacy of their own documents', (done) => {\n+  //   request\n+  //   .put('/api/documents/58c175eb2c3d08874b51cd08')\n+  //   .set('x-access-token', token)\n+  //   .send({\n+  //     privacy: 'public',\n+  //   })\n+  //   .end((err, res) => {\n+  //     expect(res.status).toBe(200);\n+  //     expect(res.status).not.toBe(401);\n+  //     expect(res.body).toBeDefined();\n+  //     expect(res.body.message).toBe('Document details updated successfully');\n+  //     done();\n+  //   });\n+  // });","path":"spec/backend/documents-spec.js","position":null,"original_position":95,"commit_id":"404bc9a028e137daf61b84767a1e01c0dcc2fd76","original_commit_id":"bcc3126a6644dca0169dd70751618b6c9f3df7cc","user":{"login":"andela-emabishi","id":19430113,"avatar_url":"https://avatars.githubusercontent.com/u/19430113?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-emabishi","html_url":"https://github.com/andela-emabishi","followers_url":"https://api.github.com/users/andela-emabishi/followers","following_url":"https://api.github.com/users/andela-emabishi/following{/other_user}","gists_url":"https://api.github.com/users/andela-emabishi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-emabishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-emabishi/subscriptions","organizations_url":"https://api.github.com/users/andela-emabishi/orgs","repos_url":"https://api.github.com/users/andela-emabishi/repos","events_url":"https://api.github.com/users/andela-emabishi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-emabishi/received_events","type":"User","site_admin":false},"body":"Resolved","created_at":"2016-09-20T11:10:54Z","updated_at":"2016-09-20T11:10:54Z","html_url":"https://github.com/andela-emabishi/document-management-system/pull/2#discussion_r79586538","pull_request_url":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls/comments/79586538"},"html":{"href":"https://github.com/andela-emabishi/document-management-system/pull/2#discussion_r79586538"},"pull_request":{"href":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls/2","id":85744498,"html_url":"https://github.com/andela-emabishi/document-management-system/pull/2","diff_url":"https://github.com/andela-emabishi/document-management-system/pull/2.diff","patch_url":"https://github.com/andela-emabishi/document-management-system/pull/2.patch","issue_url":"https://api.github.com/repos/andela-emabishi/document-management-system/issues/2","number":2,"state":"open","locked":false,"title":"Peer Review","user":{"login":"andela-emabishi","id":19430113,"avatar_url":"https://avatars.githubusercontent.com/u/19430113?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-emabishi","html_url":"https://github.com/andela-emabishi","followers_url":"https://api.github.com/users/andela-emabishi/followers","following_url":"https://api.github.com/users/andela-emabishi/following{/other_user}","gists_url":"https://api.github.com/users/andela-emabishi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-emabishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-emabishi/subscriptions","organizations_url":"https://api.github.com/users/andela-emabishi/orgs","repos_url":"https://api.github.com/users/andela-emabishi/repos","events_url":"https://api.github.com/users/andela-emabishi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-emabishi/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-19T06:49:21Z","updated_at":"2016-09-20T11:10:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls/2/commits","review_comments_url":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls/2/comments","review_comment_url":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela-emabishi/document-management-system/issues/2/comments","statuses_url":"https://api.github.com/repos/andela-emabishi/document-management-system/statuses/404bc9a028e137daf61b84767a1e01c0dcc2fd76","head":{"label":"andela-emabishi:dev","ref":"dev","sha":"404bc9a028e137daf61b84767a1e01c0dcc2fd76","user":{"login":"andela-emabishi","id":19430113,"avatar_url":"https://avatars.githubusercontent.com/u/19430113?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-emabishi","html_url":"https://github.com/andela-emabishi","followers_url":"https://api.github.com/users/andela-emabishi/followers","following_url":"https://api.github.com/users/andela-emabishi/following{/other_user}","gists_url":"https://api.github.com/users/andela-emabishi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-emabishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-emabishi/subscriptions","organizations_url":"https://api.github.com/users/andela-emabishi/orgs","repos_url":"https://api.github.com/users/andela-emabishi/repos","events_url":"https://api.github.com/users/andela-emabishi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-emabishi/received_events","type":"User","site_admin":false},"repo":{"id":65451755,"name":"document-management-system","full_name":"andela-emabishi/document-management-system","owner":{"login":"andela-emabishi","id":19430113,"avatar_url":"https://avatars.githubusercontent.com/u/19430113?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-emabishi","html_url":"https://github.com/andela-emabishi","followers_url":"https://api.github.com/users/andela-emabishi/followers","following_url":"https://api.github.com/users/andela-emabishi/following{/other_user}","gists_url":"https://api.github.com/users/andela-emabishi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-emabishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-emabishi/subscriptions","organizations_url":"https://api.github.com/users/andela-emabishi/orgs","repos_url":"https://api.github.com/users/andela-emabishi/repos","events_url":"https://api.github.com/users/andela-emabishi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-emabishi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-emabishi/document-management-system","description":"Andela Javascript Checkpoint 3: Document Management Sysytem API","fork":false,"url":"https://api.github.com/repos/andela-emabishi/document-management-system","forks_url":"https://api.github.com/repos/andela-emabishi/document-management-system/forks","keys_url":"https://api.github.com/repos/andela-emabishi/document-management-system/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-emabishi/document-management-system/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-emabishi/document-management-system/teams","hooks_url":"https://api.github.com/repos/andela-emabishi/document-management-system/hooks","issue_events_url":"https://api.github.com/repos/andela-emabishi/document-management-system/issues/events{/number}","events_url":"https://api.github.com/repos/andela-emabishi/document-management-system/events","assignees_url":"https://api.github.com/repos/andela-emabishi/document-management-system/assignees{/user}","branches_url":"https://api.github.com/repos/andela-emabishi/document-management-system/branches{/branch}","tags_url":"https://api.github.com/repos/andela-emabishi/document-management-system/tags","blobs_url":"https://api.github.com/repos/andela-emabishi/document-management-system/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-emabishi/document-management-system/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-emabishi/document-management-system/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-emabishi/document-management-system/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-emabishi/document-management-system/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-emabishi/document-management-system/languages","stargazers_url":"https://api.github.com/repos/andela-emabishi/document-management-system/stargazers","contributors_url":"https://api.github.com/repos/andela-emabishi/document-management-system/contributors","subscribers_url":"https://api.github.com/repos/andela-emabishi/document-management-system/subscribers","subscription_url":"https://api.github.com/repos/andela-emabishi/document-management-system/subscription","commits_url":"https://api.github.com/repos/andela-emabishi/document-management-system/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-emabishi/document-management-system/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-emabishi/document-management-system/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-emabishi/document-management-system/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-emabishi/document-management-system/contents/{+path}","compare_url":"https://api.github.com/repos/andela-emabishi/document-management-system/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-emabishi/document-management-system/merges","archive_url":"https://api.github.com/repos/andela-emabishi/document-management-system/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-emabishi/document-management-system/downloads","issues_url":"https://api.github.com/repos/andela-emabishi/document-management-system/issues{/number}","pulls_url":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-emabishi/document-management-system/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-emabishi/document-management-system/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-emabishi/document-management-system/labels{/name}","releases_url":"https://api.github.com/repos/andela-emabishi/document-management-system/releases{/id}","deployments_url":"https://api.github.com/repos/andela-emabishi/document-management-system/deployments","created_at":"2016-08-11T08:18:50Z","updated_at":"2016-09-10T22:06:54Z","pushed_at":"2016-09-20T10:28:16Z","git_url":"git://github.com/andela-emabishi/document-management-system.git","ssh_url":"git@github.com:andela-emabishi/document-management-system.git","clone_url":"https://github.com/andela-emabishi/document-management-system.git","svn_url":"https://github.com/andela-emabishi/document-management-system","homepage":null,"size":197,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"andela-emabishi:master","ref":"master","sha":"e9ea663f3208474d95e7eb145d6950ed959dd865","user":{"login":"andela-emabishi","id":19430113,"avatar_url":"https://avatars.githubusercontent.com/u/19430113?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-emabishi","html_url":"https://github.com/andela-emabishi","followers_url":"https://api.github.com/users/andela-emabishi/followers","following_url":"https://api.github.com/users/andela-emabishi/following{/other_user}","gists_url":"https://api.github.com/users/andela-emabishi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-emabishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-emabishi/subscriptions","organizations_url":"https://api.github.com/users/andela-emabishi/orgs","repos_url":"https://api.github.com/users/andela-emabishi/repos","events_url":"https://api.github.com/users/andela-emabishi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-emabishi/received_events","type":"User","site_admin":false},"repo":{"id":65451755,"name":"document-management-system","full_name":"andela-emabishi/document-management-system","owner":{"login":"andela-emabishi","id":19430113,"avatar_url":"https://avatars.githubusercontent.com/u/19430113?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-emabishi","html_url":"https://github.com/andela-emabishi","followers_url":"https://api.github.com/users/andela-emabishi/followers","following_url":"https://api.github.com/users/andela-emabishi/following{/other_user}","gists_url":"https://api.github.com/users/andela-emabishi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-emabishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-emabishi/subscriptions","organizations_url":"https://api.github.com/users/andela-emabishi/orgs","repos_url":"https://api.github.com/users/andela-emabishi/repos","events_url":"https://api.github.com/users/andela-emabishi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-emabishi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-emabishi/document-management-system","description":"Andela Javascript Checkpoint 3: Document Management Sysytem API","fork":false,"url":"https://api.github.com/repos/andela-emabishi/document-management-system","forks_url":"https://api.github.com/repos/andela-emabishi/document-management-system/forks","keys_url":"https://api.github.com/repos/andela-emabishi/document-management-system/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-emabishi/document-management-system/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-emabishi/document-management-system/teams","hooks_url":"https://api.github.com/repos/andela-emabishi/document-management-system/hooks","issue_events_url":"https://api.github.com/repos/andela-emabishi/document-management-system/issues/events{/number}","events_url":"https://api.github.com/repos/andela-emabishi/document-management-system/events","assignees_url":"https://api.github.com/repos/andela-emabishi/document-management-system/assignees{/user}","branches_url":"https://api.github.com/repos/andela-emabishi/document-management-system/branches{/branch}","tags_url":"https://api.github.com/repos/andela-emabishi/document-management-system/tags","blobs_url":"https://api.github.com/repos/andela-emabishi/document-management-system/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-emabishi/document-management-system/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-emabishi/document-management-system/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-emabishi/document-management-system/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-emabishi/document-management-system/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-emabishi/document-management-system/languages","stargazers_url":"https://api.github.com/repos/andela-emabishi/document-management-system/stargazers","contributors_url":"https://api.github.com/repos/andela-emabishi/document-management-system/contributors","subscribers_url":"https://api.github.com/repos/andela-emabishi/document-management-system/subscribers","subscription_url":"https://api.github.com/repos/andela-emabishi/document-management-system/subscription","commits_url":"https://api.github.com/repos/andela-emabishi/document-management-system/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-emabishi/document-management-system/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-emabishi/document-management-system/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-emabishi/document-management-system/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-emabishi/document-management-system/contents/{+path}","compare_url":"https://api.github.com/repos/andela-emabishi/document-management-system/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-emabishi/document-management-system/merges","archive_url":"https://api.github.com/repos/andela-emabishi/document-management-system/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-emabishi/document-management-system/downloads","issues_url":"https://api.github.com/repos/andela-emabishi/document-management-system/issues{/number}","pulls_url":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-emabishi/document-management-system/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-emabishi/document-management-system/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-emabishi/document-management-system/labels{/name}","releases_url":"https://api.github.com/repos/andela-emabishi/document-management-system/releases{/id}","deployments_url":"https://api.github.com/repos/andela-emabishi/document-management-system/deployments","created_at":"2016-08-11T08:18:50Z","updated_at":"2016-09-10T22:06:54Z","pushed_at":"2016-09-20T10:28:16Z","git_url":"git://github.com/andela-emabishi/document-management-system.git","ssh_url":"git@github.com:andela-emabishi/document-management-system.git","clone_url":"https://github.com/andela-emabishi/document-management-system.git","svn_url":"https://github.com/andela-emabishi/document-management-system","homepage":null,"size":197,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls/2"},"html":{"href":"https://github.com/andela-emabishi/document-management-system/pull/2"},"issue":{"href":"https://api.github.com/repos/andela-emabishi/document-management-system/issues/2"},"comments":{"href":"https://api.github.com/repos/andela-emabishi/document-management-system/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela-emabishi/document-management-system/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/andela-emabishi/document-management-system/statuses/404bc9a028e137daf61b84767a1e01c0dcc2fd76"}}}}
{"actor":{"display_login":"andela-emabishi"}}