{"action":"created","comment":{"url":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls/comments/86645386","pull_request_review_id":7128957,"id":86645386,"diff_hunk":"@@ -209,27 +211,21 @@\n     end\n   end\n \n-  it \"orders 10 civilians correctly, by creation time\" do\n-    create_partial_incident(:civilians, 10, 1)\n+  it \"orders 5 civilians correctly, by creation time\" do\n+    create(:incident, num_civilians: 5, stop_step: :civilians)\n+    visit incident_path(Incident.first)\n     expect(current_path).to end_with('involved_civilians/new')\n-    10.times do\n+\n+    5.times do\n       answer_all_civilian submit: true\n     end\n     expect(current_path).to end_with('involved_officers/new')\n+\n     click_link 'Civilians'\n-    links = all('a.person-link')\n-    expect(links.length).to eq(10)\n+    expect(all('a.person-link').length).to eq(5)\n \n-    # The odds of 10 items to be correctly sorted by chance is ~3million:1\n     incident = Incident.first\n-    civs_sorted = InvolvedPerson.sorted_persons(incident.involved_civilians)\n-    # Uncomment for debugging\n-    # (0..9).each do |i|\n-    #   puts \"Unsorted #{i} #{incident.involved_civilians[i].id} #{incident.involved_civilians[i].created_at}\"\n-    #   puts \"Sorted   #{i} #{civs_sorted[i].id} #{civs_sorted[i].created_at}\"\n-    # end\n-    (1..9).each do |i|\n-      expect(civs_sorted[i].created_at).to be > civs_sorted[i - 1].created_at\n-    end\n+    civilians_sorted = InvolvedPerson.sorted_persons(incident.involved_civilians)\n+    expect(civilians_sorted.map(&:created_at)).to be_sorted","path":"spec/requests/involved_civilian_spec.rb","position":54,"original_position":54,"commit_id":"e900d6a5281f16b8198576a6487dfaa7fb8ed617","original_commit_id":"e900d6a5281f16b8198576a6487dfaa7fb8ed617","user":{"login":"everett-wetchler","id":1421476,"avatar_url":"https://avatars.githubusercontent.com/u/1421476?v=3","gravatar_id":"","url":"https://api.github.com/users/everett-wetchler","html_url":"https://github.com/everett-wetchler","followers_url":"https://api.github.com/users/everett-wetchler/followers","following_url":"https://api.github.com/users/everett-wetchler/following{/other_user}","gists_url":"https://api.github.com/users/everett-wetchler/gists{/gist_id}","starred_url":"https://api.github.com/users/everett-wetchler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/everett-wetchler/subscriptions","organizations_url":"https://api.github.com/users/everett-wetchler/orgs","repos_url":"https://api.github.com/users/everett-wetchler/repos","events_url":"https://api.github.com/users/everett-wetchler/events{/privacy}","received_events_url":"https://api.github.com/users/everett-wetchler/received_events","type":"User","site_admin":false},"body":"Whoa.... TIL be_sorted","created_at":"2016-11-04T22:46:24Z","updated_at":"2016-11-04T22:59:03Z","html_url":"https://github.com/bayesimpact/bridge-uof/pull/36#discussion_r86645386","pull_request_url":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls/comments/86645386"},"html":{"href":"https://github.com/bayesimpact/bridge-uof/pull/36#discussion_r86645386"},"pull_request":{"href":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls/36","id":92263079,"html_url":"https://github.com/bayesimpact/bridge-uof/pull/36","diff_url":"https://github.com/bayesimpact/bridge-uof/pull/36.diff","patch_url":"https://github.com/bayesimpact/bridge-uof/pull/36.patch","issue_url":"https://api.github.com/repos/bayesimpact/bridge-uof/issues/36","number":36,"state":"open","locked":false,"title":"Cut test suite runtime from 27 min to 14 min on CircleCI","user":{"login":"AlexNisnevich","id":415965,"avatar_url":"https://avatars.githubusercontent.com/u/415965?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexNisnevich","html_url":"https://github.com/AlexNisnevich","followers_url":"https://api.github.com/users/AlexNisnevich/followers","following_url":"https://api.github.com/users/AlexNisnevich/following{/other_user}","gists_url":"https://api.github.com/users/AlexNisnevich/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexNisnevich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexNisnevich/subscriptions","organizations_url":"https://api.github.com/users/AlexNisnevich/orgs","repos_url":"https://api.github.com/users/AlexNisnevich/repos","events_url":"https://api.github.com/users/AlexNisnevich/events{/privacy}","received_events_url":"https://api.github.com/users/AlexNisnevich/received_events","type":"User","site_admin":false},"body":"Thanks to @money for suggesting some of these techniques.\r\n\r\n- Enable profiling in rspec to track which specs are taking the longest.\r\n- Turn `before :each` blocks into `let` declarations whenever possible.\r\n- `build` factories instead of `create`ing them whenever possible.\r\n- Create incidents using factories instead of requests in all cases where we don't care about the incident creation itself. (<- this is what led to most of the speedup)\r\n- Add rubocop rules to avoid bad behavior (in particular, using instance variables in specs) in the future.\r\n\r\nI think it's possible to get the tests even faster with some more of the same work, but this is a decent starting point.","created_at":"2016-11-04T00:00:57Z","updated_at":"2016-11-04T22:59:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e658d91814283bbb664be56dd079b4b9bcfd0514","assignee":{"login":"money","id":1409179,"avatar_url":"https://avatars.githubusercontent.com/u/1409179?v=3","gravatar_id":"","url":"https://api.github.com/users/money","html_url":"https://github.com/money","followers_url":"https://api.github.com/users/money/followers","following_url":"https://api.github.com/users/money/following{/other_user}","gists_url":"https://api.github.com/users/money/gists{/gist_id}","starred_url":"https://api.github.com/users/money/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/money/subscriptions","organizations_url":"https://api.github.com/users/money/orgs","repos_url":"https://api.github.com/users/money/repos","events_url":"https://api.github.com/users/money/events{/privacy}","received_events_url":"https://api.github.com/users/money/received_events","type":"User","site_admin":false},"assignees":[{"login":"money","id":1409179,"avatar_url":"https://avatars.githubusercontent.com/u/1409179?v=3","gravatar_id":"","url":"https://api.github.com/users/money","html_url":"https://github.com/money","followers_url":"https://api.github.com/users/money/followers","following_url":"https://api.github.com/users/money/following{/other_user}","gists_url":"https://api.github.com/users/money/gists{/gist_id}","starred_url":"https://api.github.com/users/money/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/money/subscriptions","organizations_url":"https://api.github.com/users/money/orgs","repos_url":"https://api.github.com/users/money/repos","events_url":"https://api.github.com/users/money/events{/privacy}","received_events_url":"https://api.github.com/users/money/received_events","type":"User","site_admin":false},{"login":"everett-wetchler","id":1421476,"avatar_url":"https://avatars.githubusercontent.com/u/1421476?v=3","gravatar_id":"","url":"https://api.github.com/users/everett-wetchler","html_url":"https://github.com/everett-wetchler","followers_url":"https://api.github.com/users/everett-wetchler/followers","following_url":"https://api.github.com/users/everett-wetchler/following{/other_user}","gists_url":"https://api.github.com/users/everett-wetchler/gists{/gist_id}","starred_url":"https://api.github.com/users/everett-wetchler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/everett-wetchler/subscriptions","organizations_url":"https://api.github.com/users/everett-wetchler/orgs","repos_url":"https://api.github.com/users/everett-wetchler/repos","events_url":"https://api.github.com/users/everett-wetchler/events{/privacy}","received_events_url":"https://api.github.com/users/everett-wetchler/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls/36/commits","review_comments_url":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls/36/comments","review_comment_url":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bayesimpact/bridge-uof/issues/36/comments","statuses_url":"https://api.github.com/repos/bayesimpact/bridge-uof/statuses/e900d6a5281f16b8198576a6487dfaa7fb8ed617","head":{"label":"bayesimpact:an-profile-tests","ref":"an-profile-tests","sha":"e900d6a5281f16b8198576a6487dfaa7fb8ed617","user":{"login":"bayesimpact","id":7692453,"avatar_url":"https://avatars.githubusercontent.com/u/7692453?v=3","gravatar_id":"","url":"https://api.github.com/users/bayesimpact","html_url":"https://github.com/bayesimpact","followers_url":"https://api.github.com/users/bayesimpact/followers","following_url":"https://api.github.com/users/bayesimpact/following{/other_user}","gists_url":"https://api.github.com/users/bayesimpact/gists{/gist_id}","starred_url":"https://api.github.com/users/bayesimpact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bayesimpact/subscriptions","organizations_url":"https://api.github.com/users/bayesimpact/orgs","repos_url":"https://api.github.com/users/bayesimpact/repos","events_url":"https://api.github.com/users/bayesimpact/events{/privacy}","received_events_url":"https://api.github.com/users/bayesimpact/received_events","type":"Organization","site_admin":false},"repo":{"id":68900294,"name":"bridge-uof","full_name":"bayesimpact/bridge-uof","owner":{"login":"bayesimpact","id":7692453,"avatar_url":"https://avatars.githubusercontent.com/u/7692453?v=3","gravatar_id":"","url":"https://api.github.com/users/bayesimpact","html_url":"https://github.com/bayesimpact","followers_url":"https://api.github.com/users/bayesimpact/followers","following_url":"https://api.github.com/users/bayesimpact/following{/other_user}","gists_url":"https://api.github.com/users/bayesimpact/gists{/gist_id}","starred_url":"https://api.github.com/users/bayesimpact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bayesimpact/subscriptions","organizations_url":"https://api.github.com/users/bayesimpact/orgs","repos_url":"https://api.github.com/users/bayesimpact/repos","events_url":"https://api.github.com/users/bayesimpact/events{/privacy}","received_events_url":"https://api.github.com/users/bayesimpact/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bayesimpact/bridge-uof","description":"Police use of force reporting app, developed in collaboration with California DoJ.","fork":false,"url":"https://api.github.com/repos/bayesimpact/bridge-uof","forks_url":"https://api.github.com/repos/bayesimpact/bridge-uof/forks","keys_url":"https://api.github.com/repos/bayesimpact/bridge-uof/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bayesimpact/bridge-uof/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bayesimpact/bridge-uof/teams","hooks_url":"https://api.github.com/repos/bayesimpact/bridge-uof/hooks","issue_events_url":"https://api.github.com/repos/bayesimpact/bridge-uof/issues/events{/number}","events_url":"https://api.github.com/repos/bayesimpact/bridge-uof/events","assignees_url":"https://api.github.com/repos/bayesimpact/bridge-uof/assignees{/user}","branches_url":"https://api.github.com/repos/bayesimpact/bridge-uof/branches{/branch}","tags_url":"https://api.github.com/repos/bayesimpact/bridge-uof/tags","blobs_url":"https://api.github.com/repos/bayesimpact/bridge-uof/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bayesimpact/bridge-uof/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bayesimpact/bridge-uof/git/refs{/sha}","trees_url":"https://api.github.com/repos/bayesimpact/bridge-uof/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bayesimpact/bridge-uof/statuses/{sha}","languages_url":"https://api.github.com/repos/bayesimpact/bridge-uof/languages","stargazers_url":"https://api.github.com/repos/bayesimpact/bridge-uof/stargazers","contributors_url":"https://api.github.com/repos/bayesimpact/bridge-uof/contributors","subscribers_url":"https://api.github.com/repos/bayesimpact/bridge-uof/subscribers","subscription_url":"https://api.github.com/repos/bayesimpact/bridge-uof/subscription","commits_url":"https://api.github.com/repos/bayesimpact/bridge-uof/commits{/sha}","git_commits_url":"https://api.github.com/repos/bayesimpact/bridge-uof/git/commits{/sha}","comments_url":"https://api.github.com/repos/bayesimpact/bridge-uof/comments{/number}","issue_comment_url":"https://api.github.com/repos/bayesimpact/bridge-uof/issues/comments{/number}","contents_url":"https://api.github.com/repos/bayesimpact/bridge-uof/contents/{+path}","compare_url":"https://api.github.com/repos/bayesimpact/bridge-uof/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bayesimpact/bridge-uof/merges","archive_url":"https://api.github.com/repos/bayesimpact/bridge-uof/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bayesimpact/bridge-uof/downloads","issues_url":"https://api.github.com/repos/bayesimpact/bridge-uof/issues{/number}","pulls_url":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls{/number}","milestones_url":"https://api.github.com/repos/bayesimpact/bridge-uof/milestones{/number}","notifications_url":"https://api.github.com/repos/bayesimpact/bridge-uof/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bayesimpact/bridge-uof/labels{/name}","releases_url":"https://api.github.com/repos/bayesimpact/bridge-uof/releases{/id}","deployments_url":"https://api.github.com/repos/bayesimpact/bridge-uof/deployments","created_at":"2016-09-22T08:20:39Z","updated_at":"2016-10-24T20:07:50Z","pushed_at":"2016-11-04T22:16:09Z","git_url":"git://github.com/bayesimpact/bridge-uof.git","ssh_url":"git@github.com:bayesimpact/bridge-uof.git","clone_url":"https://github.com/bayesimpact/bridge-uof.git","svn_url":"https://github.com/bayesimpact/bridge-uof","homepage":"http://www.bayesimpact.org/focus/justice","size":2487,"stargazers_count":10,"watchers_count":10,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":11,"forks":0,"open_issues":11,"watchers":10,"default_branch":"master"}},"base":{"label":"bayesimpact:master","ref":"master","sha":"5eac7ef3e2b08c419481039143f3b6dc7f597631","user":{"login":"bayesimpact","id":7692453,"avatar_url":"https://avatars.githubusercontent.com/u/7692453?v=3","gravatar_id":"","url":"https://api.github.com/users/bayesimpact","html_url":"https://github.com/bayesimpact","followers_url":"https://api.github.com/users/bayesimpact/followers","following_url":"https://api.github.com/users/bayesimpact/following{/other_user}","gists_url":"https://api.github.com/users/bayesimpact/gists{/gist_id}","starred_url":"https://api.github.com/users/bayesimpact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bayesimpact/subscriptions","organizations_url":"https://api.github.com/users/bayesimpact/orgs","repos_url":"https://api.github.com/users/bayesimpact/repos","events_url":"https://api.github.com/users/bayesimpact/events{/privacy}","received_events_url":"https://api.github.com/users/bayesimpact/received_events","type":"Organization","site_admin":false},"repo":{"id":68900294,"name":"bridge-uof","full_name":"bayesimpact/bridge-uof","owner":{"login":"bayesimpact","id":7692453,"avatar_url":"https://avatars.githubusercontent.com/u/7692453?v=3","gravatar_id":"","url":"https://api.github.com/users/bayesimpact","html_url":"https://github.com/bayesimpact","followers_url":"https://api.github.com/users/bayesimpact/followers","following_url":"https://api.github.com/users/bayesimpact/following{/other_user}","gists_url":"https://api.github.com/users/bayesimpact/gists{/gist_id}","starred_url":"https://api.github.com/users/bayesimpact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bayesimpact/subscriptions","organizations_url":"https://api.github.com/users/bayesimpact/orgs","repos_url":"https://api.github.com/users/bayesimpact/repos","events_url":"https://api.github.com/users/bayesimpact/events{/privacy}","received_events_url":"https://api.github.com/users/bayesimpact/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bayesimpact/bridge-uof","description":"Police use of force reporting app, developed in collaboration with California DoJ.","fork":false,"url":"https://api.github.com/repos/bayesimpact/bridge-uof","forks_url":"https://api.github.com/repos/bayesimpact/bridge-uof/forks","keys_url":"https://api.github.com/repos/bayesimpact/bridge-uof/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bayesimpact/bridge-uof/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bayesimpact/bridge-uof/teams","hooks_url":"https://api.github.com/repos/bayesimpact/bridge-uof/hooks","issue_events_url":"https://api.github.com/repos/bayesimpact/bridge-uof/issues/events{/number}","events_url":"https://api.github.com/repos/bayesimpact/bridge-uof/events","assignees_url":"https://api.github.com/repos/bayesimpact/bridge-uof/assignees{/user}","branches_url":"https://api.github.com/repos/bayesimpact/bridge-uof/branches{/branch}","tags_url":"https://api.github.com/repos/bayesimpact/bridge-uof/tags","blobs_url":"https://api.github.com/repos/bayesimpact/bridge-uof/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bayesimpact/bridge-uof/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bayesimpact/bridge-uof/git/refs{/sha}","trees_url":"https://api.github.com/repos/bayesimpact/bridge-uof/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bayesimpact/bridge-uof/statuses/{sha}","languages_url":"https://api.github.com/repos/bayesimpact/bridge-uof/languages","stargazers_url":"https://api.github.com/repos/bayesimpact/bridge-uof/stargazers","contributors_url":"https://api.github.com/repos/bayesimpact/bridge-uof/contributors","subscribers_url":"https://api.github.com/repos/bayesimpact/bridge-uof/subscribers","subscription_url":"https://api.github.com/repos/bayesimpact/bridge-uof/subscription","commits_url":"https://api.github.com/repos/bayesimpact/bridge-uof/commits{/sha}","git_commits_url":"https://api.github.com/repos/bayesimpact/bridge-uof/git/commits{/sha}","comments_url":"https://api.github.com/repos/bayesimpact/bridge-uof/comments{/number}","issue_comment_url":"https://api.github.com/repos/bayesimpact/bridge-uof/issues/comments{/number}","contents_url":"https://api.github.com/repos/bayesimpact/bridge-uof/contents/{+path}","compare_url":"https://api.github.com/repos/bayesimpact/bridge-uof/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bayesimpact/bridge-uof/merges","archive_url":"https://api.github.com/repos/bayesimpact/bridge-uof/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bayesimpact/bridge-uof/downloads","issues_url":"https://api.github.com/repos/bayesimpact/bridge-uof/issues{/number}","pulls_url":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls{/number}","milestones_url":"https://api.github.com/repos/bayesimpact/bridge-uof/milestones{/number}","notifications_url":"https://api.github.com/repos/bayesimpact/bridge-uof/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bayesimpact/bridge-uof/labels{/name}","releases_url":"https://api.github.com/repos/bayesimpact/bridge-uof/releases{/id}","deployments_url":"https://api.github.com/repos/bayesimpact/bridge-uof/deployments","created_at":"2016-09-22T08:20:39Z","updated_at":"2016-10-24T20:07:50Z","pushed_at":"2016-11-04T22:16:09Z","git_url":"git://github.com/bayesimpact/bridge-uof.git","ssh_url":"git@github.com:bayesimpact/bridge-uof.git","clone_url":"https://github.com/bayesimpact/bridge-uof.git","svn_url":"https://github.com/bayesimpact/bridge-uof","homepage":"http://www.bayesimpact.org/focus/justice","size":2487,"stargazers_count":10,"watchers_count":10,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":11,"forks":0,"open_issues":11,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls/36"},"html":{"href":"https://github.com/bayesimpact/bridge-uof/pull/36"},"issue":{"href":"https://api.github.com/repos/bayesimpact/bridge-uof/issues/36"},"comments":{"href":"https://api.github.com/repos/bayesimpact/bridge-uof/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bayesimpact/bridge-uof/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/bayesimpact/bridge-uof/statuses/e900d6a5281f16b8198576a6487dfaa7fb8ed617"}}}}
{"actor":{"display_login":"everett-wetchler"}}