{"action":"created","comment":{"url":"https://api.github.com/repos/PagerNation/Escalator-API/pulls/comments/86698512","pull_request_review_id":7343300,"id":86698512,"diff_hunk":"@@ -206,4 +208,131 @@ describe('# User Service', () => {\n         });\n     });\n   });\n+\n+  describe('# addDevice() | getDevice()', () => {\n+    const baseUser = {\n+      name: 'Jarryd Lee',\n+      email: 'Jarryd@lee.com'\n+    };\n+\n+    const device = new Device({\n+      name: 'email',\n+      type: 'email',\n+      contactInformation: '1234567890'\n+    });\n+\n+    let user;\n+\n+    before((done) => {\n+      userService.createUser(baseUser)\n+        .then((createdUser) => {\n+          user = createdUser;\n+          done();\n+        });\n+    });\n+\n+    it('should add and retrieve a users device', (done) => {\n+      user.addDevice(device)\n+        .then(savedUser => savedUser.getDevice(device.id))\n+        .then((retrievedDevice) => {\n+          expect(retrievedDevice.name).to.equal(device.name);\n+          expect(retrievedDevice.type).to.equal(device.type);\n+          expect(retrievedDevice.contactInformation).to.equal(device.contactInformation);\n+          done();\n+        });\n+    });\n+\n+    it('should fail to retrieve a users device with incorrect deviceId', (done) => {\n+      const fakeId = '1234567890abcdef123456789';\n+      user.getDevice(fakeId)\n+        .catch((err) => {\n+          expect(err).to.exist;\n+          expect(err.message).to.equal(`Device with ID ${fakeId} doesn\\'t exist!`);\n+          done();\n+        });\n+    });\n+  });\n+\n+\n+  describe('# removeDevice()', () => {\n+    const baseUser = {\n+      name: 'Jarryd Lee',\n+      email: 'Jarryd@lee.com'\n+    };\n+\n+    const device = new Device({\n+      name: 'email',\n+      type: 'email',\n+      contactInformation: '1234567890'\n+    });\n+\n+    let user;\n+\n+    before((done) => {\n+      userService.createUser(baseUser)\n+        .then(createdUser => createdUser.addDevice(device))\n+        .then((updatedUser) => {\n+          user = updatedUser;\n+          done();\n+        });\n+    });\n+\n+    it('should remove a device from the user', (done) => {\n+      userService.removeDevice(user, device.id)\n+        .then((updatedUser) => {\n+          expect(updatedUser).to.exist;\n+          expect(updatedUser.devices).to.be.empty;\n+          done();\n+        });\n+    });\n+  });\n+\n+  describe('# sortDevices()', () => {\n+    const baseUser = {\n+      name: 'Jarryd Lee',\n+      email: 'Jarryd@lee.com'\n+    };\n+\n+    const baseDevice = {\n+      name: 'email',\n+      type: 'email',\n+      contactInformation: '1234567890'\n+    };\n+\n+    const device1 = new Device(baseDevice);","path":"server/tests/services/user.test.js","position":182,"original_position":182,"commit_id":"7329fa49267697d61d8bb934df37e5753bbb4c98","original_commit_id":"7329fa49267697d61d8bb934df37e5753bbb4c98","user":{"login":"kalebdavis","id":6809736,"avatar_url":"https://avatars.githubusercontent.com/u/6809736?v=3","gravatar_id":"","url":"https://api.github.com/users/kalebdavis","html_url":"https://github.com/kalebdavis","followers_url":"https://api.github.com/users/kalebdavis/followers","following_url":"https://api.github.com/users/kalebdavis/following{/other_user}","gists_url":"https://api.github.com/users/kalebdavis/gists{/gist_id}","starred_url":"https://api.github.com/users/kalebdavis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalebdavis/subscriptions","organizations_url":"https://api.github.com/users/kalebdavis/orgs","repos_url":"https://api.github.com/users/kalebdavis/repos","events_url":"https://api.github.com/users/kalebdavis/events{/privacy}","received_events_url":"https://api.github.com/users/kalebdavis/received_events","type":"User","site_admin":false},"body":"Thoughts on using lodash to reduce the duplicate code here? Something like\r\n\r\n```\r\n_.map(devices, new Device(device));\r\n```","created_at":"2016-11-06T22:42:44Z","updated_at":"2016-11-06T22:42:45Z","html_url":"https://github.com/PagerNation/Escalator-API/pull/19#discussion_r86698512","pull_request_url":"https://api.github.com/repos/PagerNation/Escalator-API/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/PagerNation/Escalator-API/pulls/comments/86698512"},"html":{"href":"https://github.com/PagerNation/Escalator-API/pull/19#discussion_r86698512"},"pull_request":{"href":"https://api.github.com/repos/PagerNation/Escalator-API/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/PagerNation/Escalator-API/pulls/19","id":92198885,"html_url":"https://github.com/PagerNation/Escalator-API/pull/19","diff_url":"https://github.com/PagerNation/Escalator-API/pull/19.diff","patch_url":"https://github.com/PagerNation/Escalator-API/pull/19.patch","issue_url":"https://api.github.com/repos/PagerNation/Escalator-API/issues/19","number":19,"state":"open","locked":false,"title":"User device modification methods","user":{"login":"jarrydlee","id":5650600,"avatar_url":"https://avatars.githubusercontent.com/u/5650600?v=3","gravatar_id":"","url":"https://api.github.com/users/jarrydlee","html_url":"https://github.com/jarrydlee","followers_url":"https://api.github.com/users/jarrydlee/followers","following_url":"https://api.github.com/users/jarrydlee/following{/other_user}","gists_url":"https://api.github.com/users/jarrydlee/gists{/gist_id}","starred_url":"https://api.github.com/users/jarrydlee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarrydlee/subscriptions","organizations_url":"https://api.github.com/users/jarrydlee/orgs","repos_url":"https://api.github.com/users/jarrydlee/repos","events_url":"https://api.github.com/users/jarrydlee/events{/privacy}","received_events_url":"https://api.github.com/users/jarrydlee/received_events","type":"User","site_admin":false},"body":"- [x] Routes + validation\r\n- [x] Route tests\r\n- [x] Service tests\r\n\r\nfixes https://github.com/PagerNation/PagerNation/issues/70","created_at":"2016-11-03T17:11:23Z","updated_at":"2016-11-06T22:42:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fbf1ecd8096b87b8225999908bc523f14cb17b11","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/PagerNation/Escalator-API/pulls/19/commits","review_comments_url":"https://api.github.com/repos/PagerNation/Escalator-API/pulls/19/comments","review_comment_url":"https://api.github.com/repos/PagerNation/Escalator-API/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PagerNation/Escalator-API/issues/19/comments","statuses_url":"https://api.github.com/repos/PagerNation/Escalator-API/statuses/7329fa49267697d61d8bb934df37e5753bbb4c98","head":{"label":"PagerNation:user-device-mods","ref":"user-device-mods","sha":"7329fa49267697d61d8bb934df37e5753bbb4c98","user":{"login":"PagerNation","id":22669519,"avatar_url":"https://avatars.githubusercontent.com/u/22669519?v=3","gravatar_id":"","url":"https://api.github.com/users/PagerNation","html_url":"https://github.com/PagerNation","followers_url":"https://api.github.com/users/PagerNation/followers","following_url":"https://api.github.com/users/PagerNation/following{/other_user}","gists_url":"https://api.github.com/users/PagerNation/gists{/gist_id}","starred_url":"https://api.github.com/users/PagerNation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PagerNation/subscriptions","organizations_url":"https://api.github.com/users/PagerNation/orgs","repos_url":"https://api.github.com/users/PagerNation/repos","events_url":"https://api.github.com/users/PagerNation/events{/privacy}","received_events_url":"https://api.github.com/users/PagerNation/received_events","type":"Organization","site_admin":false},"repo":{"id":70527288,"name":"Escalator-API","full_name":"PagerNation/Escalator-API","owner":{"login":"PagerNation","id":22669519,"avatar_url":"https://avatars.githubusercontent.com/u/22669519?v=3","gravatar_id":"","url":"https://api.github.com/users/PagerNation","html_url":"https://github.com/PagerNation","followers_url":"https://api.github.com/users/PagerNation/followers","following_url":"https://api.github.com/users/PagerNation/following{/other_user}","gists_url":"https://api.github.com/users/PagerNation/gists{/gist_id}","starred_url":"https://api.github.com/users/PagerNation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PagerNation/subscriptions","organizations_url":"https://api.github.com/users/PagerNation/orgs","repos_url":"https://api.github.com/users/PagerNation/repos","events_url":"https://api.github.com/users/PagerNation/events{/privacy}","received_events_url":"https://api.github.com/users/PagerNation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PagerNation/Escalator-API","description":null,"fork":false,"url":"https://api.github.com/repos/PagerNation/Escalator-API","forks_url":"https://api.github.com/repos/PagerNation/Escalator-API/forks","keys_url":"https://api.github.com/repos/PagerNation/Escalator-API/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PagerNation/Escalator-API/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PagerNation/Escalator-API/teams","hooks_url":"https://api.github.com/repos/PagerNation/Escalator-API/hooks","issue_events_url":"https://api.github.com/repos/PagerNation/Escalator-API/issues/events{/number}","events_url":"https://api.github.com/repos/PagerNation/Escalator-API/events","assignees_url":"https://api.github.com/repos/PagerNation/Escalator-API/assignees{/user}","branches_url":"https://api.github.com/repos/PagerNation/Escalator-API/branches{/branch}","tags_url":"https://api.github.com/repos/PagerNation/Escalator-API/tags","blobs_url":"https://api.github.com/repos/PagerNation/Escalator-API/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PagerNation/Escalator-API/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PagerNation/Escalator-API/git/refs{/sha}","trees_url":"https://api.github.com/repos/PagerNation/Escalator-API/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PagerNation/Escalator-API/statuses/{sha}","languages_url":"https://api.github.com/repos/PagerNation/Escalator-API/languages","stargazers_url":"https://api.github.com/repos/PagerNation/Escalator-API/stargazers","contributors_url":"https://api.github.com/repos/PagerNation/Escalator-API/contributors","subscribers_url":"https://api.github.com/repos/PagerNation/Escalator-API/subscribers","subscription_url":"https://api.github.com/repos/PagerNation/Escalator-API/subscription","commits_url":"https://api.github.com/repos/PagerNation/Escalator-API/commits{/sha}","git_commits_url":"https://api.github.com/repos/PagerNation/Escalator-API/git/commits{/sha}","comments_url":"https://api.github.com/repos/PagerNation/Escalator-API/comments{/number}","issue_comment_url":"https://api.github.com/repos/PagerNation/Escalator-API/issues/comments{/number}","contents_url":"https://api.github.com/repos/PagerNation/Escalator-API/contents/{+path}","compare_url":"https://api.github.com/repos/PagerNation/Escalator-API/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PagerNation/Escalator-API/merges","archive_url":"https://api.github.com/repos/PagerNation/Escalator-API/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PagerNation/Escalator-API/downloads","issues_url":"https://api.github.com/repos/PagerNation/Escalator-API/issues{/number}","pulls_url":"https://api.github.com/repos/PagerNation/Escalator-API/pulls{/number}","milestones_url":"https://api.github.com/repos/PagerNation/Escalator-API/milestones{/number}","notifications_url":"https://api.github.com/repos/PagerNation/Escalator-API/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PagerNation/Escalator-API/labels{/name}","releases_url":"https://api.github.com/repos/PagerNation/Escalator-API/releases{/id}","deployments_url":"https://api.github.com/repos/PagerNation/Escalator-API/deployments","created_at":"2016-10-10T20:44:59Z","updated_at":"2016-11-05T16:25:12Z","pushed_at":"2016-11-05T21:51:20Z","git_url":"git://github.com/PagerNation/Escalator-API.git","ssh_url":"git@github.com:PagerNation/Escalator-API.git","clone_url":"https://github.com/PagerNation/Escalator-API.git","svn_url":"https://github.com/PagerNation/Escalator-API","homepage":null,"size":108,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":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":2,"default_branch":"master"}},"base":{"label":"PagerNation:master","ref":"master","sha":"37d78944db28b3911c96db8792c13d69195c3809","user":{"login":"PagerNation","id":22669519,"avatar_url":"https://avatars.githubusercontent.com/u/22669519?v=3","gravatar_id":"","url":"https://api.github.com/users/PagerNation","html_url":"https://github.com/PagerNation","followers_url":"https://api.github.com/users/PagerNation/followers","following_url":"https://api.github.com/users/PagerNation/following{/other_user}","gists_url":"https://api.github.com/users/PagerNation/gists{/gist_id}","starred_url":"https://api.github.com/users/PagerNation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PagerNation/subscriptions","organizations_url":"https://api.github.com/users/PagerNation/orgs","repos_url":"https://api.github.com/users/PagerNation/repos","events_url":"https://api.github.com/users/PagerNation/events{/privacy}","received_events_url":"https://api.github.com/users/PagerNation/received_events","type":"Organization","site_admin":false},"repo":{"id":70527288,"name":"Escalator-API","full_name":"PagerNation/Escalator-API","owner":{"login":"PagerNation","id":22669519,"avatar_url":"https://avatars.githubusercontent.com/u/22669519?v=3","gravatar_id":"","url":"https://api.github.com/users/PagerNation","html_url":"https://github.com/PagerNation","followers_url":"https://api.github.com/users/PagerNation/followers","following_url":"https://api.github.com/users/PagerNation/following{/other_user}","gists_url":"https://api.github.com/users/PagerNation/gists{/gist_id}","starred_url":"https://api.github.com/users/PagerNation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PagerNation/subscriptions","organizations_url":"https://api.github.com/users/PagerNation/orgs","repos_url":"https://api.github.com/users/PagerNation/repos","events_url":"https://api.github.com/users/PagerNation/events{/privacy}","received_events_url":"https://api.github.com/users/PagerNation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PagerNation/Escalator-API","description":null,"fork":false,"url":"https://api.github.com/repos/PagerNation/Escalator-API","forks_url":"https://api.github.com/repos/PagerNation/Escalator-API/forks","keys_url":"https://api.github.com/repos/PagerNation/Escalator-API/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PagerNation/Escalator-API/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PagerNation/Escalator-API/teams","hooks_url":"https://api.github.com/repos/PagerNation/Escalator-API/hooks","issue_events_url":"https://api.github.com/repos/PagerNation/Escalator-API/issues/events{/number}","events_url":"https://api.github.com/repos/PagerNation/Escalator-API/events","assignees_url":"https://api.github.com/repos/PagerNation/Escalator-API/assignees{/user}","branches_url":"https://api.github.com/repos/PagerNation/Escalator-API/branches{/branch}","tags_url":"https://api.github.com/repos/PagerNation/Escalator-API/tags","blobs_url":"https://api.github.com/repos/PagerNation/Escalator-API/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PagerNation/Escalator-API/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PagerNation/Escalator-API/git/refs{/sha}","trees_url":"https://api.github.com/repos/PagerNation/Escalator-API/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PagerNation/Escalator-API/statuses/{sha}","languages_url":"https://api.github.com/repos/PagerNation/Escalator-API/languages","stargazers_url":"https://api.github.com/repos/PagerNation/Escalator-API/stargazers","contributors_url":"https://api.github.com/repos/PagerNation/Escalator-API/contributors","subscribers_url":"https://api.github.com/repos/PagerNation/Escalator-API/subscribers","subscription_url":"https://api.github.com/repos/PagerNation/Escalator-API/subscription","commits_url":"https://api.github.com/repos/PagerNation/Escalator-API/commits{/sha}","git_commits_url":"https://api.github.com/repos/PagerNation/Escalator-API/git/commits{/sha}","comments_url":"https://api.github.com/repos/PagerNation/Escalator-API/comments{/number}","issue_comment_url":"https://api.github.com/repos/PagerNation/Escalator-API/issues/comments{/number}","contents_url":"https://api.github.com/repos/PagerNation/Escalator-API/contents/{+path}","compare_url":"https://api.github.com/repos/PagerNation/Escalator-API/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PagerNation/Escalator-API/merges","archive_url":"https://api.github.com/repos/PagerNation/Escalator-API/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PagerNation/Escalator-API/downloads","issues_url":"https://api.github.com/repos/PagerNation/Escalator-API/issues{/number}","pulls_url":"https://api.github.com/repos/PagerNation/Escalator-API/pulls{/number}","milestones_url":"https://api.github.com/repos/PagerNation/Escalator-API/milestones{/number}","notifications_url":"https://api.github.com/repos/PagerNation/Escalator-API/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PagerNation/Escalator-API/labels{/name}","releases_url":"https://api.github.com/repos/PagerNation/Escalator-API/releases{/id}","deployments_url":"https://api.github.com/repos/PagerNation/Escalator-API/deployments","created_at":"2016-10-10T20:44:59Z","updated_at":"2016-11-05T16:25:12Z","pushed_at":"2016-11-05T21:51:20Z","git_url":"git://github.com/PagerNation/Escalator-API.git","ssh_url":"git@github.com:PagerNation/Escalator-API.git","clone_url":"https://github.com/PagerNation/Escalator-API.git","svn_url":"https://github.com/PagerNation/Escalator-API","homepage":null,"size":108,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":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":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PagerNation/Escalator-API/pulls/19"},"html":{"href":"https://github.com/PagerNation/Escalator-API/pull/19"},"issue":{"href":"https://api.github.com/repos/PagerNation/Escalator-API/issues/19"},"comments":{"href":"https://api.github.com/repos/PagerNation/Escalator-API/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/PagerNation/Escalator-API/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/PagerNation/Escalator-API/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PagerNation/Escalator-API/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/PagerNation/Escalator-API/statuses/7329fa49267697d61d8bb934df37e5753bbb4c98"}}}}
{"actor":{"display_login":"kalebdavis"}}