{"action":"created","comment":{"url":"https://api.github.com/repos/zendesk/samson/pulls/comments/56713872","id":56713872,"diff_hunk":"@@ -0,0 +1,70 @@\n+require_relative '../test_helper'\n+\n+describe CsvExportJob do\n+  let(:deployer) { users(:deployer) }\n+  let(:deploy_export_job) { CsvExport.create(user: deployer, content: 'deploys') }\n+  let(:invalid_export_job) { CsvExport.create(user: deployer, content: 'deploy') }\n+  \n+  it \"enqueues properly\" do\n+    assert_enqueued_jobs 1 do\n+      CsvExportJob.perform_later(deploy_export_job.id)\n+    end\n+  end\n+  \n+  describe \"Job executes for deploy csv\" do\n+    teardown do\n+      job = CsvExport.find(deploy_export_job.id)\n+      filename = \"#{Rails.root}/export/#{job.id}\"\n+      File.delete(filename) if File.exist?(filename)\n+    end\n+    \n+    it \"finishes with file\" do\n+      CsvExportJob.perform_now(deploy_export_job.id)\n+      job = CsvExport.find(deploy_export_job.id)\n+      filename = \"#{Rails.root}/export/#{job.id}\"\n+      assert job.finished?, \"Not Finished\"\n+      assert File.exist?(filename), \"File Not exist\"\n+    end\n+    \n+    it \"creates deploys csv file accurately and completely\" do\n+      CsvExportJob.perform_now(deploy_export_job.id)\n+      job = CsvExport.find(deploy_export_job.id)\n+      filename = \"#{Rails.root}/export/#{job.id}\"\n+      assert File.exist?(filename), \"File Not exist\"\n+\n+      csv_response = CSV.read(filename)\n+      csv_headers = csv_response.shift\n+      deploycount = csv_headers.pop.to_i\n+      Deploy.joins(:stage).count.must_equal deploycount\n+      deploycount.must_equal csv_response.length\n+      assert_not_nil csv_response\n+      csv_response.each do |d|\n+        deploy_info = Deploy.find_by(id: d[0])\n+        deploy_info.wont_be_nil\n+        deploy_info.project.name.must_equal d[1]\n+        deploy_info.summary.must_equal d[2]\n+        deploy_info.updated_at.to_s.must_equal d[3]\n+        deploy_info.start_time.to_s.must_equal d[4]\n+        deploy_info.job.user.name.must_equal d[5]\n+        deploy_info.csv_buddy.must_equal d[6]\n+        deploy_info.stage.production.to_s.must_equal d[7]\n+      end\n+    end\n+  end\n+  \n+  describe \"Job executes for invalid csv export type\" do\n+    teardown do\n+      job = CsvExport.find(invalid_export_job.id)\n+      filename = \"#{Rails.root}/export/#{job.id}\"\n+      File.delete(filename) if File.exist?(filename)\n+    end\n+\n+    test \"fails with no file\" do\n+      CsvExportJob.perform_now(invalid_export_job.id)\n+      job = CsvExport.find(invalid_export_job.id)","path":"test/jobs/csv_export_job_test.rb","position":64,"original_position":64,"commit_id":"e13be46e628aa652776878b5410114fbc03121ae","original_commit_id":"e13be46e628aa652776878b5410114fbc03121ae","user":{"login":"grosser","id":11367,"avatar_url":"https://avatars.githubusercontent.com/u/11367?v=3","gravatar_id":"","url":"https://api.github.com/users/grosser","html_url":"https://github.com/grosser","followers_url":"https://api.github.com/users/grosser/followers","following_url":"https://api.github.com/users/grosser/following{/other_user}","gists_url":"https://api.github.com/users/grosser/gists{/gist_id}","starred_url":"https://api.github.com/users/grosser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grosser/subscriptions","organizations_url":"https://api.github.com/users/grosser/orgs","repos_url":"https://api.github.com/users/grosser/repos","events_url":"https://api.github.com/users/grosser/events{/privacy}","received_events_url":"https://api.github.com/users/grosser/received_events","type":"User","site_admin":false},"body":"`.reload` ?","created_at":"2016-03-18T19:59:29Z","updated_at":"2016-03-18T19:59:29Z","html_url":"https://github.com/zendesk/samson/pull/766#discussion_r56713872","pull_request_url":"https://api.github.com/repos/zendesk/samson/pulls/766","_links":{"self":{"href":"https://api.github.com/repos/zendesk/samson/pulls/comments/56713872"},"html":{"href":"https://github.com/zendesk/samson/pull/766#discussion_r56713872"},"pull_request":{"href":"https://api.github.com/repos/zendesk/samson/pulls/766"}}},"pull_request":{"url":"https://api.github.com/repos/zendesk/samson/pulls/766","id":63412019,"html_url":"https://github.com/zendesk/samson/pull/766","diff_url":"https://github.com/zendesk/samson/pull/766.diff","patch_url":"https://github.com/zendesk/samson/pull/766.patch","issue_url":"https://api.github.com/repos/zendesk/samson/issues/766","number":766,"state":"open","locked":false,"title":"Move deploys csv export to an asynchronous job","user":{"login":"rikeoka","id":11447948,"avatar_url":"https://avatars.githubusercontent.com/u/11447948?v=3","gravatar_id":"","url":"https://api.github.com/users/rikeoka","html_url":"https://github.com/rikeoka","followers_url":"https://api.github.com/users/rikeoka/followers","following_url":"https://api.github.com/users/rikeoka/following{/other_user}","gists_url":"https://api.github.com/users/rikeoka/gists{/gist_id}","starred_url":"https://api.github.com/users/rikeoka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rikeoka/subscriptions","organizations_url":"https://api.github.com/users/rikeoka/orgs","repos_url":"https://api.github.com/users/rikeoka/repos","events_url":"https://api.github.com/users/rikeoka/events{/privacy}","received_events_url":"https://api.github.com/users/rikeoka/received_events","type":"User","site_admin":false},"body":"* The deploys report was failing to generate realtime with a large number of records.  The report is now generated in a background job.  The stored files is cleaned up the next time a CSV Job is run, when it is older than the lessor of 12 hours after download or 1 month after creation.\r\n\r\n* UI changes.\r\nHeader - Added reports to Admin menu (Admin menu now shows for all users but only shows Admin options if admin, reporting is one such non-admin task):\r\n<img width=\"328\" alt=\"screen shot 2016-03-11 at 1 38 20 pm\" src=\"https://cloud.githubusercontent.com/assets/11447948/13716249/c78f73e6-e78e-11e5-8ff8-e7614bc03ab6.png\">\r\n\r\nRecent Deploys:\r\n![screen shot 2016-02-24 at 11 50 24 am](https://cloud.githubusercontent.com/assets/11447948/13298833/460ab8e2-daed-11e5-8592-57e2728676f6.png)\r\n\r\nNew CSV pages:\r\n/csv\r\n![screen shot 2016-02-24 at 11 50 59 am](https://cloud.githubusercontent.com/assets/11447948/13298853/5bfbcdda-daed-11e5-9a30-4d5030b59cf8.png)\r\n\r\n/csv/new\r\n![screen shot 2016-02-24 at 11 51 05 am](https://cloud.githubusercontent.com/assets/11447948/13298869/6b88a62e-daed-11e5-8878-008b3364d33c.png)\r\n\r\n/csv/status/:id\r\n![screen shot 2016-03-18 at 10 44 11 am](https://cloud.githubusercontent.com/assets/11447948/13886886/63e1ec58-ecf6-11e5-8cd6-a0bcb252cf00.png)\r\n![screen shot 2016-03-18 at 10 44 48 am](https://cloud.githubusercontent.com/assets/11447948/13886908/7a427ba2-ecf6-11e5-8acb-71e0a51bfa03.png)\r\n\r\n\r\n/cc @zendesk/samson\r\n\r\n### Tasks\r\n - [ ] :+1: from team\r\n\r\n### References\r\nMoved code branch from forked repo to zendesk repo to ease review per @grosser .  \r\nOriginal PR https://github.com/zendesk/samson/pull/747 \r\n\r\n### Risks\r\n- Level: Med\r\n","created_at":"2016-03-18T17:49:04Z","updated_at":"2016-03-18T19:59:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9da5bdcd8ed6e7140e979e6a56656dad6de66167","assignee":{"login":"rikeoka","id":11447948,"avatar_url":"https://avatars.githubusercontent.com/u/11447948?v=3","gravatar_id":"","url":"https://api.github.com/users/rikeoka","html_url":"https://github.com/rikeoka","followers_url":"https://api.github.com/users/rikeoka/followers","following_url":"https://api.github.com/users/rikeoka/following{/other_user}","gists_url":"https://api.github.com/users/rikeoka/gists{/gist_id}","starred_url":"https://api.github.com/users/rikeoka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rikeoka/subscriptions","organizations_url":"https://api.github.com/users/rikeoka/orgs","repos_url":"https://api.github.com/users/rikeoka/repos","events_url":"https://api.github.com/users/rikeoka/events{/privacy}","received_events_url":"https://api.github.com/users/rikeoka/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/zendesk/samson/pulls/766/commits","review_comments_url":"https://api.github.com/repos/zendesk/samson/pulls/766/comments","review_comment_url":"https://api.github.com/repos/zendesk/samson/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zendesk/samson/issues/766/comments","statuses_url":"https://api.github.com/repos/zendesk/samson/statuses/e13be46e628aa652776878b5410114fbc03121ae","head":{"label":"zendesk:rikeoka/asynchronous_csv","ref":"rikeoka/asynchronous_csv","sha":"e13be46e628aa652776878b5410114fbc03121ae","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":20208662,"name":"samson","full_name":"zendesk/samson","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/samson","description":"Web interface for deployments","fork":false,"url":"https://api.github.com/repos/zendesk/samson","forks_url":"https://api.github.com/repos/zendesk/samson/forks","keys_url":"https://api.github.com/repos/zendesk/samson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/samson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/samson/teams","hooks_url":"https://api.github.com/repos/zendesk/samson/hooks","issue_events_url":"https://api.github.com/repos/zendesk/samson/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/samson/events","assignees_url":"https://api.github.com/repos/zendesk/samson/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/samson/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/samson/tags","blobs_url":"https://api.github.com/repos/zendesk/samson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/samson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/samson/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/samson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/samson/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/samson/languages","stargazers_url":"https://api.github.com/repos/zendesk/samson/stargazers","contributors_url":"https://api.github.com/repos/zendesk/samson/contributors","subscribers_url":"https://api.github.com/repos/zendesk/samson/subscribers","subscription_url":"https://api.github.com/repos/zendesk/samson/subscription","commits_url":"https://api.github.com/repos/zendesk/samson/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/samson/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/samson/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/samson/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/samson/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/samson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/samson/merges","archive_url":"https://api.github.com/repos/zendesk/samson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/samson/downloads","issues_url":"https://api.github.com/repos/zendesk/samson/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/samson/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/samson/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/samson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/samson/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/samson/releases{/id}","deployments_url":"https://api.github.com/repos/zendesk/samson/deployments","created_at":"2014-05-27T05:55:57Z","updated_at":"2016-03-16T20:43:30Z","pushed_at":"2016-03-18T19:45:22Z","git_url":"git://github.com/zendesk/samson.git","ssh_url":"git@github.com:zendesk/samson.git","clone_url":"https://github.com/zendesk/samson.git","svn_url":"https://github.com/zendesk/samson","homepage":null,"size":156109,"stargazers_count":622,"watchers_count":622,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":104,"mirror_url":null,"open_issues_count":53,"forks":104,"open_issues":53,"watchers":622,"default_branch":"master"}},"base":{"label":"zendesk:master","ref":"master","sha":"23db17048dc486c1576ee5b3f4961f9aa54b8313","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":20208662,"name":"samson","full_name":"zendesk/samson","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/samson","description":"Web interface for deployments","fork":false,"url":"https://api.github.com/repos/zendesk/samson","forks_url":"https://api.github.com/repos/zendesk/samson/forks","keys_url":"https://api.github.com/repos/zendesk/samson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/samson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/samson/teams","hooks_url":"https://api.github.com/repos/zendesk/samson/hooks","issue_events_url":"https://api.github.com/repos/zendesk/samson/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/samson/events","assignees_url":"https://api.github.com/repos/zendesk/samson/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/samson/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/samson/tags","blobs_url":"https://api.github.com/repos/zendesk/samson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/samson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/samson/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/samson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/samson/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/samson/languages","stargazers_url":"https://api.github.com/repos/zendesk/samson/stargazers","contributors_url":"https://api.github.com/repos/zendesk/samson/contributors","subscribers_url":"https://api.github.com/repos/zendesk/samson/subscribers","subscription_url":"https://api.github.com/repos/zendesk/samson/subscription","commits_url":"https://api.github.com/repos/zendesk/samson/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/samson/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/samson/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/samson/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/samson/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/samson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/samson/merges","archive_url":"https://api.github.com/repos/zendesk/samson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/samson/downloads","issues_url":"https://api.github.com/repos/zendesk/samson/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/samson/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/samson/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/samson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/samson/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/samson/releases{/id}","deployments_url":"https://api.github.com/repos/zendesk/samson/deployments","created_at":"2014-05-27T05:55:57Z","updated_at":"2016-03-16T20:43:30Z","pushed_at":"2016-03-18T19:45:22Z","git_url":"git://github.com/zendesk/samson.git","ssh_url":"git@github.com:zendesk/samson.git","clone_url":"https://github.com/zendesk/samson.git","svn_url":"https://github.com/zendesk/samson","homepage":null,"size":156109,"stargazers_count":622,"watchers_count":622,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":104,"mirror_url":null,"open_issues_count":53,"forks":104,"open_issues":53,"watchers":622,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zendesk/samson/pulls/766"},"html":{"href":"https://github.com/zendesk/samson/pull/766"},"issue":{"href":"https://api.github.com/repos/zendesk/samson/issues/766"},"comments":{"href":"https://api.github.com/repos/zendesk/samson/issues/766/comments"},"review_comments":{"href":"https://api.github.com/repos/zendesk/samson/pulls/766/comments"},"review_comment":{"href":"https://api.github.com/repos/zendesk/samson/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zendesk/samson/pulls/766/commits"},"statuses":{"href":"https://api.github.com/repos/zendesk/samson/statuses/e13be46e628aa652776878b5410114fbc03121ae"}}}}