{"action":"created","comment":{"url":"https://api.github.com/repos/openSNP/snpr/pulls/comments/52607125","id":52607125,"diff_hunk":"@@ -0,0 +1,20 @@\n+require 'spec_helper.rb'\n+\n+describe PlosDetails do\n+  let(:plos_paper) do\n+    create(:plos_paper, id: 1, reader: 0, doi: '10.1371/journal.pone.0089204')\n+  end\n+  let(:job) {PlosDetails.new}\n+\n+  it 'updates the view count' do\n+    before = plos_paper.reader\n+\n+    response = double('response', body: '{\"views\":23}')\n+    expect(Net::HTTP).to receive(:get_response).\n+        with(URI 'http://alm.plos.org/api/v3/articles/10.1371/journal.pone.0089204?api_key=foo').","path":"spec/workers/plos_details_spec.rb","position":14,"original_position":14,"commit_id":"a3009dd110f6272e5db789ed8fc81684fd807954","original_commit_id":"a3009dd110f6272e5db789ed8fc81684fd807954","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Place the . on the next line, together with the method name.<br>Use 2 (not 4) spaces for indenting an expression spanning multiple lines.<br>Add parentheses to nested method call `URI 'http://alm.plos.org/api/v3/articles/10.1371/journal.pone.0089204?api_key=foo'`.","created_at":"2016-02-11T14:27:49Z","updated_at":"2016-02-11T14:27:49Z","html_url":"https://github.com/openSNP/snpr/pull/251#discussion_r52607125","pull_request_url":"https://api.github.com/repos/openSNP/snpr/pulls/251","_links":{"self":{"href":"https://api.github.com/repos/openSNP/snpr/pulls/comments/52607125"},"html":{"href":"https://github.com/openSNP/snpr/pull/251#discussion_r52607125"},"pull_request":{"href":"https://api.github.com/repos/openSNP/snpr/pulls/251"}}},"pull_request":{"url":"https://api.github.com/repos/openSNP/snpr/pulls/251","id":58843667,"html_url":"https://github.com/openSNP/snpr/pull/251","diff_url":"https://github.com/openSNP/snpr/pull/251.diff","patch_url":"https://github.com/openSNP/snpr/pull/251.patch","issue_url":"https://api.github.com/repos/openSNP/snpr/issues/251","number":251,"state":"open","locked":false,"title":"Fixes undefined method [] for nil:NilClass error in ALM details","user":{"login":"philippbayer","id":413885,"avatar_url":"https://avatars.githubusercontent.com/u/413885?v=3","gravatar_id":"","url":"https://api.github.com/users/philippbayer","html_url":"https://github.com/philippbayer","followers_url":"https://api.github.com/users/philippbayer/followers","following_url":"https://api.github.com/users/philippbayer/following{/other_user}","gists_url":"https://api.github.com/users/philippbayer/gists{/gist_id}","starred_url":"https://api.github.com/users/philippbayer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philippbayer/subscriptions","organizations_url":"https://api.github.com/users/philippbayer/orgs","repos_url":"https://api.github.com/users/philippbayer/repos","events_url":"https://api.github.com/users/philippbayer/events{/privacy}","received_events_url":"https://api.github.com/users/philippbayer/received_events","type":"User","site_admin":false},"body":"It seems that the output of the ALM API changed a little bit, causing heaps of `NoMethodError: undefined method [] for nil:NilClass`\r\n\r\nfrom this line:\r\n\r\n`readers_total = detail_result[0][\"views\"]`\r\n\r\nbecause it's not a list anymore, so [0] gives you nil, so you can't run [\"views\"] on that\r\n\r\nThis commit puts in an example reply in the comments (try it for yourself: http://alm.plos.org/api/v3/articles/10.1371/journal.pone.0080003?api_key=OUR_API_KEY ) and fixes this bug, and adds a little check to see whether the HTTP response from the API is correct so that we don't parse garbage or empty text.\r\n\r\nEdit: This commit also fixes that annoying failing UserAchievement test\r\n\r\nEdit 2: Apparently the above link works without the API-key, too. huh","created_at":"2016-02-10T03:26:36Z","updated_at":"2016-02-11T14:27:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc1a36a3a991cf87c9f40314759445e9f22f118b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openSNP/snpr/pulls/251/commits","review_comments_url":"https://api.github.com/repos/openSNP/snpr/pulls/251/comments","review_comment_url":"https://api.github.com/repos/openSNP/snpr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openSNP/snpr/issues/251/comments","statuses_url":"https://api.github.com/repos/openSNP/snpr/statuses/a3009dd110f6272e5db789ed8fc81684fd807954","head":{"label":"philippbayer:master","ref":"master","sha":"a3009dd110f6272e5db789ed8fc81684fd807954","user":{"login":"philippbayer","id":413885,"avatar_url":"https://avatars.githubusercontent.com/u/413885?v=3","gravatar_id":"","url":"https://api.github.com/users/philippbayer","html_url":"https://github.com/philippbayer","followers_url":"https://api.github.com/users/philippbayer/followers","following_url":"https://api.github.com/users/philippbayer/following{/other_user}","gists_url":"https://api.github.com/users/philippbayer/gists{/gist_id}","starred_url":"https://api.github.com/users/philippbayer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philippbayer/subscriptions","organizations_url":"https://api.github.com/users/philippbayer/orgs","repos_url":"https://api.github.com/users/philippbayer/repos","events_url":"https://api.github.com/users/philippbayer/events{/privacy}","received_events_url":"https://api.github.com/users/philippbayer/received_events","type":"User","site_admin":false},"repo":{"id":43995103,"name":"snpr","full_name":"philippbayer/snpr","owner":{"login":"philippbayer","id":413885,"avatar_url":"https://avatars.githubusercontent.com/u/413885?v=3","gravatar_id":"","url":"https://api.github.com/users/philippbayer","html_url":"https://github.com/philippbayer","followers_url":"https://api.github.com/users/philippbayer/followers","following_url":"https://api.github.com/users/philippbayer/following{/other_user}","gists_url":"https://api.github.com/users/philippbayer/gists{/gist_id}","starred_url":"https://api.github.com/users/philippbayer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philippbayer/subscriptions","organizations_url":"https://api.github.com/users/philippbayer/orgs","repos_url":"https://api.github.com/users/philippbayer/repos","events_url":"https://api.github.com/users/philippbayer/events{/privacy}","received_events_url":"https://api.github.com/users/philippbayer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/philippbayer/snpr","description":"The sources of the openSNP website","fork":true,"url":"https://api.github.com/repos/philippbayer/snpr","forks_url":"https://api.github.com/repos/philippbayer/snpr/forks","keys_url":"https://api.github.com/repos/philippbayer/snpr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/philippbayer/snpr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/philippbayer/snpr/teams","hooks_url":"https://api.github.com/repos/philippbayer/snpr/hooks","issue_events_url":"https://api.github.com/repos/philippbayer/snpr/issues/events{/number}","events_url":"https://api.github.com/repos/philippbayer/snpr/events","assignees_url":"https://api.github.com/repos/philippbayer/snpr/assignees{/user}","branches_url":"https://api.github.com/repos/philippbayer/snpr/branches{/branch}","tags_url":"https://api.github.com/repos/philippbayer/snpr/tags","blobs_url":"https://api.github.com/repos/philippbayer/snpr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/philippbayer/snpr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/philippbayer/snpr/git/refs{/sha}","trees_url":"https://api.github.com/repos/philippbayer/snpr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/philippbayer/snpr/statuses/{sha}","languages_url":"https://api.github.com/repos/philippbayer/snpr/languages","stargazers_url":"https://api.github.com/repos/philippbayer/snpr/stargazers","contributors_url":"https://api.github.com/repos/philippbayer/snpr/contributors","subscribers_url":"https://api.github.com/repos/philippbayer/snpr/subscribers","subscription_url":"https://api.github.com/repos/philippbayer/snpr/subscription","commits_url":"https://api.github.com/repos/philippbayer/snpr/commits{/sha}","git_commits_url":"https://api.github.com/repos/philippbayer/snpr/git/commits{/sha}","comments_url":"https://api.github.com/repos/philippbayer/snpr/comments{/number}","issue_comment_url":"https://api.github.com/repos/philippbayer/snpr/issues/comments{/number}","contents_url":"https://api.github.com/repos/philippbayer/snpr/contents/{+path}","compare_url":"https://api.github.com/repos/philippbayer/snpr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/philippbayer/snpr/merges","archive_url":"https://api.github.com/repos/philippbayer/snpr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/philippbayer/snpr/downloads","issues_url":"https://api.github.com/repos/philippbayer/snpr/issues{/number}","pulls_url":"https://api.github.com/repos/philippbayer/snpr/pulls{/number}","milestones_url":"https://api.github.com/repos/philippbayer/snpr/milestones{/number}","notifications_url":"https://api.github.com/repos/philippbayer/snpr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/philippbayer/snpr/labels{/name}","releases_url":"https://api.github.com/repos/philippbayer/snpr/releases{/id}","deployments_url":"https://api.github.com/repos/philippbayer/snpr/deployments","created_at":"2015-10-10T05:09:02Z","updated_at":"2016-01-18T03:02:02Z","pushed_at":"2016-02-11T14:27:42Z","git_url":"git://github.com/philippbayer/snpr.git","ssh_url":"git@github.com:philippbayer/snpr.git","clone_url":"https://github.com/philippbayer/snpr.git","svn_url":"https://github.com/philippbayer/snpr","homepage":"http://opensnp.org","size":20069,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openSNP:master","ref":"master","sha":"56f9831d8959762c89a0eef204ce8b646c2d8536","user":{"login":"openSNP","id":17121300,"avatar_url":"https://avatars.githubusercontent.com/u/17121300?v=3","gravatar_id":"","url":"https://api.github.com/users/openSNP","html_url":"https://github.com/openSNP","followers_url":"https://api.github.com/users/openSNP/followers","following_url":"https://api.github.com/users/openSNP/following{/other_user}","gists_url":"https://api.github.com/users/openSNP/gists{/gist_id}","starred_url":"https://api.github.com/users/openSNP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openSNP/subscriptions","organizations_url":"https://api.github.com/users/openSNP/orgs","repos_url":"https://api.github.com/users/openSNP/repos","events_url":"https://api.github.com/users/openSNP/events{/privacy}","received_events_url":"https://api.github.com/users/openSNP/received_events","type":"Organization","site_admin":false},"repo":{"id":1861088,"name":"snpr","full_name":"openSNP/snpr","owner":{"login":"openSNP","id":17121300,"avatar_url":"https://avatars.githubusercontent.com/u/17121300?v=3","gravatar_id":"","url":"https://api.github.com/users/openSNP","html_url":"https://github.com/openSNP","followers_url":"https://api.github.com/users/openSNP/followers","following_url":"https://api.github.com/users/openSNP/following{/other_user}","gists_url":"https://api.github.com/users/openSNP/gists{/gist_id}","starred_url":"https://api.github.com/users/openSNP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openSNP/subscriptions","organizations_url":"https://api.github.com/users/openSNP/orgs","repos_url":"https://api.github.com/users/openSNP/repos","events_url":"https://api.github.com/users/openSNP/events{/privacy}","received_events_url":"https://api.github.com/users/openSNP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openSNP/snpr","description":"The sources of the openSNP website","fork":false,"url":"https://api.github.com/repos/openSNP/snpr","forks_url":"https://api.github.com/repos/openSNP/snpr/forks","keys_url":"https://api.github.com/repos/openSNP/snpr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openSNP/snpr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openSNP/snpr/teams","hooks_url":"https://api.github.com/repos/openSNP/snpr/hooks","issue_events_url":"https://api.github.com/repos/openSNP/snpr/issues/events{/number}","events_url":"https://api.github.com/repos/openSNP/snpr/events","assignees_url":"https://api.github.com/repos/openSNP/snpr/assignees{/user}","branches_url":"https://api.github.com/repos/openSNP/snpr/branches{/branch}","tags_url":"https://api.github.com/repos/openSNP/snpr/tags","blobs_url":"https://api.github.com/repos/openSNP/snpr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openSNP/snpr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openSNP/snpr/git/refs{/sha}","trees_url":"https://api.github.com/repos/openSNP/snpr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openSNP/snpr/statuses/{sha}","languages_url":"https://api.github.com/repos/openSNP/snpr/languages","stargazers_url":"https://api.github.com/repos/openSNP/snpr/stargazers","contributors_url":"https://api.github.com/repos/openSNP/snpr/contributors","subscribers_url":"https://api.github.com/repos/openSNP/snpr/subscribers","subscription_url":"https://api.github.com/repos/openSNP/snpr/subscription","commits_url":"https://api.github.com/repos/openSNP/snpr/commits{/sha}","git_commits_url":"https://api.github.com/repos/openSNP/snpr/git/commits{/sha}","comments_url":"https://api.github.com/repos/openSNP/snpr/comments{/number}","issue_comment_url":"https://api.github.com/repos/openSNP/snpr/issues/comments{/number}","contents_url":"https://api.github.com/repos/openSNP/snpr/contents/{+path}","compare_url":"https://api.github.com/repos/openSNP/snpr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openSNP/snpr/merges","archive_url":"https://api.github.com/repos/openSNP/snpr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openSNP/snpr/downloads","issues_url":"https://api.github.com/repos/openSNP/snpr/issues{/number}","pulls_url":"https://api.github.com/repos/openSNP/snpr/pulls{/number}","milestones_url":"https://api.github.com/repos/openSNP/snpr/milestones{/number}","notifications_url":"https://api.github.com/repos/openSNP/snpr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openSNP/snpr/labels{/name}","releases_url":"https://api.github.com/repos/openSNP/snpr/releases{/id}","deployments_url":"https://api.github.com/repos/openSNP/snpr/deployments","created_at":"2011-06-07T17:37:02Z","updated_at":"2016-02-08T11:41:30Z","pushed_at":"2016-02-11T14:27:43Z","git_url":"git://github.com/openSNP/snpr.git","ssh_url":"git@github.com:openSNP/snpr.git","clone_url":"https://github.com/openSNP/snpr.git","svn_url":"https://github.com/openSNP/snpr","homepage":"http://opensnp.org","size":20206,"stargazers_count":74,"watchers_count":74,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":17,"forks":17,"open_issues":17,"watchers":74,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openSNP/snpr/pulls/251"},"html":{"href":"https://github.com/openSNP/snpr/pull/251"},"issue":{"href":"https://api.github.com/repos/openSNP/snpr/issues/251"},"comments":{"href":"https://api.github.com/repos/openSNP/snpr/issues/251/comments"},"review_comments":{"href":"https://api.github.com/repos/openSNP/snpr/pulls/251/comments"},"review_comment":{"href":"https://api.github.com/repos/openSNP/snpr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openSNP/snpr/pulls/251/commits"},"statuses":{"href":"https://api.github.com/repos/openSNP/snpr/statuses/a3009dd110f6272e5db789ed8fc81684fd807954"}}}}