{"action":"created","comment":{"url":"https://api.github.com/repos/nativestranger/personal/pulls/comments/93987587","pull_request_review_id":14517891,"id":93987587,"diff_hunk":"@@ -0,0 +1,74 @@\n+require File.expand_path(\"../../../../config/environment\", __FILE__)\n+require 'rails_helper'\n+\n+RSpec.configure do |config|\n+  config.include Devise::TestHelpers, type: :controller\n+  config.include Warden::Test::Helpers\n+  Warden.test_mode!\n+end\n+\n+RSpec.describe V1::PostsController, type: :controller do\n+  let!(:admin_user) { User.create(email: APP_CONFIG['personal_email'],\n+                            password: 'password',\n+                            confirmed_at: DateTime.now,\n+                            is_admin: true) }\n+\n+  let!(:user) { User.create(email: 'email123@example.com',\n+                            password: 'password',\n+                            confirmed_at: DateTime.now) }\n+\n+  let!(:published_post) { Post.create(title: 'Published', body: 'Body', is_published: true) }\n+  let!(:unpublished_post) { Post.create(title: 'Unpublished', body: 'Body', is_published: false) }\n+\n+  describe \"GET index\" do\n+    context \"not logged in\" do\n+      it \"responds with a 200 OK and returns published posts by default\" do\n+        get :index, format: :json\n+        expect(response.status).to eq(200)\n+        expect(response.body.include?(published_post.title)).to eq(true)\n+      end\n+\n+      it \"responds with a 200 OK and returns published posts even when 'type' is 'unpublished'\" do\n+        get :index, format: :json, type: 'unpublished'\n+        expect(response.status).to eq(200)\n+        expect(response.body.include?(published_post.title)).to eq(true)\n+        expect(response.body.include?(unpublished_post.title)).to eq(false)\n+      end\n+    end\n+\n+    context \"logged in as admin\" do\n+      it \"responds with a 200 OK and returns published posts by default\" do\n+        sign_in admin_user\n+        get :index, format: :json\n+        expect(response.status).to eq(200)\n+        expect(response.body.include?(published_post.title)).to eq(true)\n+      end\n+\n+      it \"responds with a 200 OK and returns unpublished posts when 'type' is 'unpublished'\" do\n+        sign_in admin_user\n+        get :index, format: :json, type: 'unpublished'\n+        expect(response.status).to eq(200)\n+        expect(response.body.include?(published_post.title)).to eq(false)\n+        expect(response.body.include?(unpublished_post.title)).to eq(true)\n+      end\n+    end\n+\n+    context \"logged in as non-admin\" do\n+      it \"responds with a redirect and returns published posts by default\" do\n+        sign_in user\n+        get :index, format: :json\n+        expect(response.status).to eq(200)\n+        expect(response.body.include?(published_post.title)).to eq(true)\n+      end\n+\n+      it \"responds with a 200 OK and returns published posts even when 'type' is 'unpublished'\" do\n+        sign_in user\n+        get :index, format: :json, type: 'unpublished'\n+        expect(response.status).to eq(200)\n+        expect(response.body.include?(published_post.title)).to eq(true)\n+        expect(response.body.include?(unpublished_post.title)).to eq(false)\n+      end\n+    end\n+  end\n+","path":"spec/controllers/v1/posts_controller_spec.rb","position":73,"original_position":73,"commit_id":"c713c9eb9308f137013ea5e66a731a9711c4146c","original_commit_id":"c713c9eb9308f137013ea5e66a731a9711c4146c","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Extra empty line detected at block body end.","created_at":"2016-12-28T02:02:44Z","updated_at":"2016-12-28T02:02:44Z","html_url":"https://github.com/nativestranger/personal/pull/42#discussion_r93987587","pull_request_url":"https://api.github.com/repos/nativestranger/personal/pulls/42","_links":{"self":{"href":"https://api.github.com/repos/nativestranger/personal/pulls/comments/93987587"},"html":{"href":"https://github.com/nativestranger/personal/pull/42#discussion_r93987587"},"pull_request":{"href":"https://api.github.com/repos/nativestranger/personal/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/nativestranger/personal/pulls/42","id":99500347,"html_url":"https://github.com/nativestranger/personal/pull/42","diff_url":"https://github.com/nativestranger/personal/pull/42.diff","patch_url":"https://github.com/nativestranger/personal/pull/42.patch","issue_url":"https://api.github.com/repos/nativestranger/personal/issues/42","number":42,"state":"open","locked":false,"title":"initial Admin posts section","user":{"login":"nativestranger","id":7106165,"avatar_url":"https://avatars.githubusercontent.com/u/7106165?v=3","gravatar_id":"","url":"https://api.github.com/users/nativestranger","html_url":"https://github.com/nativestranger","followers_url":"https://api.github.com/users/nativestranger/followers","following_url":"https://api.github.com/users/nativestranger/following{/other_user}","gists_url":"https://api.github.com/users/nativestranger/gists{/gist_id}","starred_url":"https://api.github.com/users/nativestranger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nativestranger/subscriptions","organizations_url":"https://api.github.com/users/nativestranger/orgs","repos_url":"https://api.github.com/users/nativestranger/repos","events_url":"https://api.github.com/users/nativestranger/events{/privacy}","received_events_url":"https://api.github.com/users/nativestranger/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-28T02:02:29Z","updated_at":"2016-12-28T02:02:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fa216164e76dec1a86adfccd3b90fa0ce4b2b508","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nativestranger/personal/pulls/42/commits","review_comments_url":"https://api.github.com/repos/nativestranger/personal/pulls/42/comments","review_comment_url":"https://api.github.com/repos/nativestranger/personal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nativestranger/personal/issues/42/comments","statuses_url":"https://api.github.com/repos/nativestranger/personal/statuses/c713c9eb9308f137013ea5e66a731a9711c4146c","head":{"label":"nativestranger:some-cleanup","ref":"some-cleanup","sha":"c713c9eb9308f137013ea5e66a731a9711c4146c","user":{"login":"nativestranger","id":7106165,"avatar_url":"https://avatars.githubusercontent.com/u/7106165?v=3","gravatar_id":"","url":"https://api.github.com/users/nativestranger","html_url":"https://github.com/nativestranger","followers_url":"https://api.github.com/users/nativestranger/followers","following_url":"https://api.github.com/users/nativestranger/following{/other_user}","gists_url":"https://api.github.com/users/nativestranger/gists{/gist_id}","starred_url":"https://api.github.com/users/nativestranger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nativestranger/subscriptions","organizations_url":"https://api.github.com/users/nativestranger/orgs","repos_url":"https://api.github.com/users/nativestranger/repos","events_url":"https://api.github.com/users/nativestranger/events{/privacy}","received_events_url":"https://api.github.com/users/nativestranger/received_events","type":"User","site_admin":false},"repo":{"id":52776565,"name":"personal","full_name":"nativestranger/personal","owner":{"login":"nativestranger","id":7106165,"avatar_url":"https://avatars.githubusercontent.com/u/7106165?v=3","gravatar_id":"","url":"https://api.github.com/users/nativestranger","html_url":"https://github.com/nativestranger","followers_url":"https://api.github.com/users/nativestranger/followers","following_url":"https://api.github.com/users/nativestranger/following{/other_user}","gists_url":"https://api.github.com/users/nativestranger/gists{/gist_id}","starred_url":"https://api.github.com/users/nativestranger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nativestranger/subscriptions","organizations_url":"https://api.github.com/users/nativestranger/orgs","repos_url":"https://api.github.com/users/nativestranger/repos","events_url":"https://api.github.com/users/nativestranger/events{/privacy}","received_events_url":"https://api.github.com/users/nativestranger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nativestranger/personal","description":null,"fork":false,"url":"https://api.github.com/repos/nativestranger/personal","forks_url":"https://api.github.com/repos/nativestranger/personal/forks","keys_url":"https://api.github.com/repos/nativestranger/personal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nativestranger/personal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nativestranger/personal/teams","hooks_url":"https://api.github.com/repos/nativestranger/personal/hooks","issue_events_url":"https://api.github.com/repos/nativestranger/personal/issues/events{/number}","events_url":"https://api.github.com/repos/nativestranger/personal/events","assignees_url":"https://api.github.com/repos/nativestranger/personal/assignees{/user}","branches_url":"https://api.github.com/repos/nativestranger/personal/branches{/branch}","tags_url":"https://api.github.com/repos/nativestranger/personal/tags","blobs_url":"https://api.github.com/repos/nativestranger/personal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nativestranger/personal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nativestranger/personal/git/refs{/sha}","trees_url":"https://api.github.com/repos/nativestranger/personal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nativestranger/personal/statuses/{sha}","languages_url":"https://api.github.com/repos/nativestranger/personal/languages","stargazers_url":"https://api.github.com/repos/nativestranger/personal/stargazers","contributors_url":"https://api.github.com/repos/nativestranger/personal/contributors","subscribers_url":"https://api.github.com/repos/nativestranger/personal/subscribers","subscription_url":"https://api.github.com/repos/nativestranger/personal/subscription","commits_url":"https://api.github.com/repos/nativestranger/personal/commits{/sha}","git_commits_url":"https://api.github.com/repos/nativestranger/personal/git/commits{/sha}","comments_url":"https://api.github.com/repos/nativestranger/personal/comments{/number}","issue_comment_url":"https://api.github.com/repos/nativestranger/personal/issues/comments{/number}","contents_url":"https://api.github.com/repos/nativestranger/personal/contents/{+path}","compare_url":"https://api.github.com/repos/nativestranger/personal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nativestranger/personal/merges","archive_url":"https://api.github.com/repos/nativestranger/personal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nativestranger/personal/downloads","issues_url":"https://api.github.com/repos/nativestranger/personal/issues{/number}","pulls_url":"https://api.github.com/repos/nativestranger/personal/pulls{/number}","milestones_url":"https://api.github.com/repos/nativestranger/personal/milestones{/number}","notifications_url":"https://api.github.com/repos/nativestranger/personal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nativestranger/personal/labels{/name}","releases_url":"https://api.github.com/repos/nativestranger/personal/releases{/id}","deployments_url":"https://api.github.com/repos/nativestranger/personal/deployments","created_at":"2016-02-29T08:41:29Z","updated_at":"2016-06-07T22:11:21Z","pushed_at":"2016-12-28T02:02:29Z","git_url":"git://github.com/nativestranger/personal.git","ssh_url":"git@github.com:nativestranger/personal.git","clone_url":"https://github.com/nativestranger/personal.git","svn_url":"https://github.com/nativestranger/personal","homepage":null,"size":525,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"staging"}},"base":{"label":"nativestranger:staging","ref":"staging","sha":"ee3c573a2572f5c0c39b33cc09494c8fa9648827","user":{"login":"nativestranger","id":7106165,"avatar_url":"https://avatars.githubusercontent.com/u/7106165?v=3","gravatar_id":"","url":"https://api.github.com/users/nativestranger","html_url":"https://github.com/nativestranger","followers_url":"https://api.github.com/users/nativestranger/followers","following_url":"https://api.github.com/users/nativestranger/following{/other_user}","gists_url":"https://api.github.com/users/nativestranger/gists{/gist_id}","starred_url":"https://api.github.com/users/nativestranger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nativestranger/subscriptions","organizations_url":"https://api.github.com/users/nativestranger/orgs","repos_url":"https://api.github.com/users/nativestranger/repos","events_url":"https://api.github.com/users/nativestranger/events{/privacy}","received_events_url":"https://api.github.com/users/nativestranger/received_events","type":"User","site_admin":false},"repo":{"id":52776565,"name":"personal","full_name":"nativestranger/personal","owner":{"login":"nativestranger","id":7106165,"avatar_url":"https://avatars.githubusercontent.com/u/7106165?v=3","gravatar_id":"","url":"https://api.github.com/users/nativestranger","html_url":"https://github.com/nativestranger","followers_url":"https://api.github.com/users/nativestranger/followers","following_url":"https://api.github.com/users/nativestranger/following{/other_user}","gists_url":"https://api.github.com/users/nativestranger/gists{/gist_id}","starred_url":"https://api.github.com/users/nativestranger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nativestranger/subscriptions","organizations_url":"https://api.github.com/users/nativestranger/orgs","repos_url":"https://api.github.com/users/nativestranger/repos","events_url":"https://api.github.com/users/nativestranger/events{/privacy}","received_events_url":"https://api.github.com/users/nativestranger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nativestranger/personal","description":null,"fork":false,"url":"https://api.github.com/repos/nativestranger/personal","forks_url":"https://api.github.com/repos/nativestranger/personal/forks","keys_url":"https://api.github.com/repos/nativestranger/personal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nativestranger/personal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nativestranger/personal/teams","hooks_url":"https://api.github.com/repos/nativestranger/personal/hooks","issue_events_url":"https://api.github.com/repos/nativestranger/personal/issues/events{/number}","events_url":"https://api.github.com/repos/nativestranger/personal/events","assignees_url":"https://api.github.com/repos/nativestranger/personal/assignees{/user}","branches_url":"https://api.github.com/repos/nativestranger/personal/branches{/branch}","tags_url":"https://api.github.com/repos/nativestranger/personal/tags","blobs_url":"https://api.github.com/repos/nativestranger/personal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nativestranger/personal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nativestranger/personal/git/refs{/sha}","trees_url":"https://api.github.com/repos/nativestranger/personal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nativestranger/personal/statuses/{sha}","languages_url":"https://api.github.com/repos/nativestranger/personal/languages","stargazers_url":"https://api.github.com/repos/nativestranger/personal/stargazers","contributors_url":"https://api.github.com/repos/nativestranger/personal/contributors","subscribers_url":"https://api.github.com/repos/nativestranger/personal/subscribers","subscription_url":"https://api.github.com/repos/nativestranger/personal/subscription","commits_url":"https://api.github.com/repos/nativestranger/personal/commits{/sha}","git_commits_url":"https://api.github.com/repos/nativestranger/personal/git/commits{/sha}","comments_url":"https://api.github.com/repos/nativestranger/personal/comments{/number}","issue_comment_url":"https://api.github.com/repos/nativestranger/personal/issues/comments{/number}","contents_url":"https://api.github.com/repos/nativestranger/personal/contents/{+path}","compare_url":"https://api.github.com/repos/nativestranger/personal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nativestranger/personal/merges","archive_url":"https://api.github.com/repos/nativestranger/personal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nativestranger/personal/downloads","issues_url":"https://api.github.com/repos/nativestranger/personal/issues{/number}","pulls_url":"https://api.github.com/repos/nativestranger/personal/pulls{/number}","milestones_url":"https://api.github.com/repos/nativestranger/personal/milestones{/number}","notifications_url":"https://api.github.com/repos/nativestranger/personal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nativestranger/personal/labels{/name}","releases_url":"https://api.github.com/repos/nativestranger/personal/releases{/id}","deployments_url":"https://api.github.com/repos/nativestranger/personal/deployments","created_at":"2016-02-29T08:41:29Z","updated_at":"2016-06-07T22:11:21Z","pushed_at":"2016-12-28T02:02:29Z","git_url":"git://github.com/nativestranger/personal.git","ssh_url":"git@github.com:nativestranger/personal.git","clone_url":"https://github.com/nativestranger/personal.git","svn_url":"https://github.com/nativestranger/personal","homepage":null,"size":525,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/nativestranger/personal/pulls/42"},"html":{"href":"https://github.com/nativestranger/personal/pull/42"},"issue":{"href":"https://api.github.com/repos/nativestranger/personal/issues/42"},"comments":{"href":"https://api.github.com/repos/nativestranger/personal/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/nativestranger/personal/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/nativestranger/personal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nativestranger/personal/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/nativestranger/personal/statuses/c713c9eb9308f137013ea5e66a731a9711c4146c"}}}}
{"actor":{"display_login":"houndci-bot"}}