{"action":"created","comment":{"url":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls/comments/192763162","pull_request_review_id":125601032,"id":192763162,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5Mjc2MzE2Mg==","diff_hunk":"@@ -0,0 +1,119 @@\n+const underTest = require('../../../app/middleware/error-handler');\n+const i18n = require('i18n');\n+const enLocale = require('../../../app/locales/en');\n+const expect = require('chai').expect;\n+\n+describe('error handling', () => {\n+  before(() =>\n+    i18n.configure({\n+      locales: ['en'],\n+      directory: `${__dirname}/../../../app/locales`,\n+      defaultLocale: 'en',\n+      autoReload: true,\n+      objectNotation: true,\n+      useCookie: false,\n+      updateFiles: true,\n+      indent: '  ',\n+    })\n+  );\n+\n+  it('if validation error then status is set to 400', () => {\n+    let actualCode;\n+    const err = { isJoi: true };\n+    const req = {};\n+    const res = {\n+      status: code => (actualCode = code),\n+      render: () => {\n+      },\n+    };\n+    const next = {};\n+\n+    underTest(false)(err, req, res, next);\n+\n+    expect(actualCode).to.eql(400);\n+  });\n+\n+  it('if not validation error then status code is set to 500', () => {\n+    let actualCode;\n+    const err = {};\n+    const req = {};\n+    const res = {","path":"test/unit/middleware/error-handler.js","position":40,"original_position":40,"commit_id":"967f36dbc622e127cefb4d5b017e5c73e251eabb","original_commit_id":"967f36dbc622e127cefb4d5b017e5c73e251eabb","user":{"login":"chilliwilly77","id":29380535,"node_id":"MDQ6VXNlcjI5MzgwNTM1","avatar_url":"https://avatars0.githubusercontent.com/u/29380535?v=4","gravatar_id":"","url":"https://api.github.com/users/chilliwilly77","html_url":"https://github.com/chilliwilly77","followers_url":"https://api.github.com/users/chilliwilly77/followers","following_url":"https://api.github.com/users/chilliwilly77/following{/other_user}","gists_url":"https://api.github.com/users/chilliwilly77/gists{/gist_id}","starred_url":"https://api.github.com/users/chilliwilly77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chilliwilly77/subscriptions","organizations_url":"https://api.github.com/users/chilliwilly77/orgs","repos_url":"https://api.github.com/users/chilliwilly77/repos","events_url":"https://api.github.com/users/chilliwilly77/events{/privacy}","received_events_url":"https://api.github.com/users/chilliwilly77/received_events","type":"User","site_admin":false},"body":"Can you refactor this into a helper method or something. Or add instantiation of objects to beforeEach or somethign","created_at":"2018-06-04T14:36:37Z","updated_at":"2018-06-04T14:36:37Z","html_url":"https://github.com/lm-tools/choose-your-activities/pull/126#discussion_r192763162","pull_request_url":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls/126","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls/comments/192763162"},"html":{"href":"https://github.com/lm-tools/choose-your-activities/pull/126#discussion_r192763162"},"pull_request":{"href":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls/126"}}},"pull_request":{"url":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls/126","id":192369626,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyMzY5NjI2","html_url":"https://github.com/lm-tools/choose-your-activities/pull/126","diff_url":"https://github.com/lm-tools/choose-your-activities/pull/126.diff","patch_url":"https://github.com/lm-tools/choose-your-activities/pull/126.patch","issue_url":"https://api.github.com/repos/lm-tools/choose-your-activities/issues/126","number":126,"state":"open","locked":false,"title":"Controller refactor","user":{"login":"will518","id":39299502,"node_id":"MDQ6VXNlcjM5Mjk5NTAy","avatar_url":"https://avatars3.githubusercontent.com/u/39299502?v=4","gravatar_id":"","url":"https://api.github.com/users/will518","html_url":"https://github.com/will518","followers_url":"https://api.github.com/users/will518/followers","following_url":"https://api.github.com/users/will518/following{/other_user}","gists_url":"https://api.github.com/users/will518/gists{/gist_id}","starred_url":"https://api.github.com/users/will518/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/will518/subscriptions","organizations_url":"https://api.github.com/users/will518/orgs","repos_url":"https://api.github.com/users/will518/repos","events_url":"https://api.github.com/users/will518/events{/privacy}","received_events_url":"https://api.github.com/users/will518/received_events","type":"User","site_admin":false},"body":"This turned into a slightly bigger refactor around controllers and middleware. I was aiming to group all the controllers and middleware into `index.js` files that could be required in `app.js`. \r\n\r\nI've also refactored the middleware that relied on the express router so that they no longer required it. I felt this approach decouples the framework from the middleware itself.","created_at":"2018-06-04T10:52:58Z","updated_at":"2018-06-04T14:36:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"14a6a5a7ceb85223041d713ea312924f78201f55","assignee":null,"assignees":[],"requested_reviewers":[{"login":"mangogrin","id":37105143,"node_id":"MDQ6VXNlcjM3MTA1MTQz","avatar_url":"https://avatars3.githubusercontent.com/u/37105143?v=4","gravatar_id":"","url":"https://api.github.com/users/mangogrin","html_url":"https://github.com/mangogrin","followers_url":"https://api.github.com/users/mangogrin/followers","following_url":"https://api.github.com/users/mangogrin/following{/other_user}","gists_url":"https://api.github.com/users/mangogrin/gists{/gist_id}","starred_url":"https://api.github.com/users/mangogrin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mangogrin/subscriptions","organizations_url":"https://api.github.com/users/mangogrin/orgs","repos_url":"https://api.github.com/users/mangogrin/repos","events_url":"https://api.github.com/users/mangogrin/events{/privacy}","received_events_url":"https://api.github.com/users/mangogrin/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls/126/commits","review_comments_url":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls/126/comments","review_comment_url":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lm-tools/choose-your-activities/issues/126/comments","statuses_url":"https://api.github.com/repos/lm-tools/choose-your-activities/statuses/967f36dbc622e127cefb4d5b017e5c73e251eabb","head":{"label":"lm-tools:controller-refactor","ref":"controller-refactor","sha":"967f36dbc622e127cefb4d5b017e5c73e251eabb","user":{"login":"lm-tools","id":12998430,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyOTk4NDMw","avatar_url":"https://avatars3.githubusercontent.com/u/12998430?v=4","gravatar_id":"","url":"https://api.github.com/users/lm-tools","html_url":"https://github.com/lm-tools","followers_url":"https://api.github.com/users/lm-tools/followers","following_url":"https://api.github.com/users/lm-tools/following{/other_user}","gists_url":"https://api.github.com/users/lm-tools/gists{/gist_id}","starred_url":"https://api.github.com/users/lm-tools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lm-tools/subscriptions","organizations_url":"https://api.github.com/users/lm-tools/orgs","repos_url":"https://api.github.com/users/lm-tools/repos","events_url":"https://api.github.com/users/lm-tools/events{/privacy}","received_events_url":"https://api.github.com/users/lm-tools/received_events","type":"Organization","site_admin":false},"repo":{"id":75070443,"node_id":"MDEwOlJlcG9zaXRvcnk3NTA3MDQ0Mw==","name":"choose-your-activities","full_name":"lm-tools/choose-your-activities","owner":{"login":"lm-tools","id":12998430,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyOTk4NDMw","avatar_url":"https://avatars3.githubusercontent.com/u/12998430?v=4","gravatar_id":"","url":"https://api.github.com/users/lm-tools","html_url":"https://github.com/lm-tools","followers_url":"https://api.github.com/users/lm-tools/followers","following_url":"https://api.github.com/users/lm-tools/following{/other_user}","gists_url":"https://api.github.com/users/lm-tools/gists{/gist_id}","starred_url":"https://api.github.com/users/lm-tools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lm-tools/subscriptions","organizations_url":"https://api.github.com/users/lm-tools/orgs","repos_url":"https://api.github.com/users/lm-tools/repos","events_url":"https://api.github.com/users/lm-tools/events{/privacy}","received_events_url":"https://api.github.com/users/lm-tools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lm-tools/choose-your-activities","description":null,"fork":false,"url":"https://api.github.com/repos/lm-tools/choose-your-activities","forks_url":"https://api.github.com/repos/lm-tools/choose-your-activities/forks","keys_url":"https://api.github.com/repos/lm-tools/choose-your-activities/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lm-tools/choose-your-activities/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lm-tools/choose-your-activities/teams","hooks_url":"https://api.github.com/repos/lm-tools/choose-your-activities/hooks","issue_events_url":"https://api.github.com/repos/lm-tools/choose-your-activities/issues/events{/number}","events_url":"https://api.github.com/repos/lm-tools/choose-your-activities/events","assignees_url":"https://api.github.com/repos/lm-tools/choose-your-activities/assignees{/user}","branches_url":"https://api.github.com/repos/lm-tools/choose-your-activities/branches{/branch}","tags_url":"https://api.github.com/repos/lm-tools/choose-your-activities/tags","blobs_url":"https://api.github.com/repos/lm-tools/choose-your-activities/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lm-tools/choose-your-activities/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lm-tools/choose-your-activities/git/refs{/sha}","trees_url":"https://api.github.com/repos/lm-tools/choose-your-activities/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lm-tools/choose-your-activities/statuses/{sha}","languages_url":"https://api.github.com/repos/lm-tools/choose-your-activities/languages","stargazers_url":"https://api.github.com/repos/lm-tools/choose-your-activities/stargazers","contributors_url":"https://api.github.com/repos/lm-tools/choose-your-activities/contributors","subscribers_url":"https://api.github.com/repos/lm-tools/choose-your-activities/subscribers","subscription_url":"https://api.github.com/repos/lm-tools/choose-your-activities/subscription","commits_url":"https://api.github.com/repos/lm-tools/choose-your-activities/commits{/sha}","git_commits_url":"https://api.github.com/repos/lm-tools/choose-your-activities/git/commits{/sha}","comments_url":"https://api.github.com/repos/lm-tools/choose-your-activities/comments{/number}","issue_comment_url":"https://api.github.com/repos/lm-tools/choose-your-activities/issues/comments{/number}","contents_url":"https://api.github.com/repos/lm-tools/choose-your-activities/contents/{+path}","compare_url":"https://api.github.com/repos/lm-tools/choose-your-activities/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lm-tools/choose-your-activities/merges","archive_url":"https://api.github.com/repos/lm-tools/choose-your-activities/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lm-tools/choose-your-activities/downloads","issues_url":"https://api.github.com/repos/lm-tools/choose-your-activities/issues{/number}","pulls_url":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls{/number}","milestones_url":"https://api.github.com/repos/lm-tools/choose-your-activities/milestones{/number}","notifications_url":"https://api.github.com/repos/lm-tools/choose-your-activities/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lm-tools/choose-your-activities/labels{/name}","releases_url":"https://api.github.com/repos/lm-tools/choose-your-activities/releases{/id}","deployments_url":"https://api.github.com/repos/lm-tools/choose-your-activities/deployments","created_at":"2016-11-29T10:29:56Z","updated_at":"2018-06-04T14:25:34Z","pushed_at":"2018-06-04T14:25:38Z","git_url":"git://github.com/lm-tools/choose-your-activities.git","ssh_url":"git@github.com:lm-tools/choose-your-activities.git","clone_url":"https://github.com/lm-tools/choose-your-activities.git","svn_url":"https://github.com/lm-tools/choose-your-activities","homepage":null,"size":1172,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":13,"license":null,"forks":0,"open_issues":13,"watchers":2,"default_branch":"master"}},"base":{"label":"lm-tools:master","ref":"master","sha":"ed6a55530f4125800ef3e6566a4e3e409a89f9bd","user":{"login":"lm-tools","id":12998430,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyOTk4NDMw","avatar_url":"https://avatars3.githubusercontent.com/u/12998430?v=4","gravatar_id":"","url":"https://api.github.com/users/lm-tools","html_url":"https://github.com/lm-tools","followers_url":"https://api.github.com/users/lm-tools/followers","following_url":"https://api.github.com/users/lm-tools/following{/other_user}","gists_url":"https://api.github.com/users/lm-tools/gists{/gist_id}","starred_url":"https://api.github.com/users/lm-tools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lm-tools/subscriptions","organizations_url":"https://api.github.com/users/lm-tools/orgs","repos_url":"https://api.github.com/users/lm-tools/repos","events_url":"https://api.github.com/users/lm-tools/events{/privacy}","received_events_url":"https://api.github.com/users/lm-tools/received_events","type":"Organization","site_admin":false},"repo":{"id":75070443,"node_id":"MDEwOlJlcG9zaXRvcnk3NTA3MDQ0Mw==","name":"choose-your-activities","full_name":"lm-tools/choose-your-activities","owner":{"login":"lm-tools","id":12998430,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyOTk4NDMw","avatar_url":"https://avatars3.githubusercontent.com/u/12998430?v=4","gravatar_id":"","url":"https://api.github.com/users/lm-tools","html_url":"https://github.com/lm-tools","followers_url":"https://api.github.com/users/lm-tools/followers","following_url":"https://api.github.com/users/lm-tools/following{/other_user}","gists_url":"https://api.github.com/users/lm-tools/gists{/gist_id}","starred_url":"https://api.github.com/users/lm-tools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lm-tools/subscriptions","organizations_url":"https://api.github.com/users/lm-tools/orgs","repos_url":"https://api.github.com/users/lm-tools/repos","events_url":"https://api.github.com/users/lm-tools/events{/privacy}","received_events_url":"https://api.github.com/users/lm-tools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lm-tools/choose-your-activities","description":null,"fork":false,"url":"https://api.github.com/repos/lm-tools/choose-your-activities","forks_url":"https://api.github.com/repos/lm-tools/choose-your-activities/forks","keys_url":"https://api.github.com/repos/lm-tools/choose-your-activities/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lm-tools/choose-your-activities/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lm-tools/choose-your-activities/teams","hooks_url":"https://api.github.com/repos/lm-tools/choose-your-activities/hooks","issue_events_url":"https://api.github.com/repos/lm-tools/choose-your-activities/issues/events{/number}","events_url":"https://api.github.com/repos/lm-tools/choose-your-activities/events","assignees_url":"https://api.github.com/repos/lm-tools/choose-your-activities/assignees{/user}","branches_url":"https://api.github.com/repos/lm-tools/choose-your-activities/branches{/branch}","tags_url":"https://api.github.com/repos/lm-tools/choose-your-activities/tags","blobs_url":"https://api.github.com/repos/lm-tools/choose-your-activities/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lm-tools/choose-your-activities/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lm-tools/choose-your-activities/git/refs{/sha}","trees_url":"https://api.github.com/repos/lm-tools/choose-your-activities/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lm-tools/choose-your-activities/statuses/{sha}","languages_url":"https://api.github.com/repos/lm-tools/choose-your-activities/languages","stargazers_url":"https://api.github.com/repos/lm-tools/choose-your-activities/stargazers","contributors_url":"https://api.github.com/repos/lm-tools/choose-your-activities/contributors","subscribers_url":"https://api.github.com/repos/lm-tools/choose-your-activities/subscribers","subscription_url":"https://api.github.com/repos/lm-tools/choose-your-activities/subscription","commits_url":"https://api.github.com/repos/lm-tools/choose-your-activities/commits{/sha}","git_commits_url":"https://api.github.com/repos/lm-tools/choose-your-activities/git/commits{/sha}","comments_url":"https://api.github.com/repos/lm-tools/choose-your-activities/comments{/number}","issue_comment_url":"https://api.github.com/repos/lm-tools/choose-your-activities/issues/comments{/number}","contents_url":"https://api.github.com/repos/lm-tools/choose-your-activities/contents/{+path}","compare_url":"https://api.github.com/repos/lm-tools/choose-your-activities/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lm-tools/choose-your-activities/merges","archive_url":"https://api.github.com/repos/lm-tools/choose-your-activities/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lm-tools/choose-your-activities/downloads","issues_url":"https://api.github.com/repos/lm-tools/choose-your-activities/issues{/number}","pulls_url":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls{/number}","milestones_url":"https://api.github.com/repos/lm-tools/choose-your-activities/milestones{/number}","notifications_url":"https://api.github.com/repos/lm-tools/choose-your-activities/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lm-tools/choose-your-activities/labels{/name}","releases_url":"https://api.github.com/repos/lm-tools/choose-your-activities/releases{/id}","deployments_url":"https://api.github.com/repos/lm-tools/choose-your-activities/deployments","created_at":"2016-11-29T10:29:56Z","updated_at":"2018-06-04T14:25:34Z","pushed_at":"2018-06-04T14:25:38Z","git_url":"git://github.com/lm-tools/choose-your-activities.git","ssh_url":"git@github.com:lm-tools/choose-your-activities.git","clone_url":"https://github.com/lm-tools/choose-your-activities.git","svn_url":"https://github.com/lm-tools/choose-your-activities","homepage":null,"size":1172,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":13,"license":null,"forks":0,"open_issues":13,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls/126"},"html":{"href":"https://github.com/lm-tools/choose-your-activities/pull/126"},"issue":{"href":"https://api.github.com/repos/lm-tools/choose-your-activities/issues/126"},"comments":{"href":"https://api.github.com/repos/lm-tools/choose-your-activities/issues/126/comments"},"review_comments":{"href":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls/126/comments"},"review_comment":{"href":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lm-tools/choose-your-activities/pulls/126/commits"},"statuses":{"href":"https://api.github.com/repos/lm-tools/choose-your-activities/statuses/967f36dbc622e127cefb4d5b017e5c73e251eabb"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"chilliwilly77"}}