{"action":"created","comment":{"url":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls/comments/99120330","pull_request_review_id":19784736,"id":99120330,"diff_hunk":"@@ -3,37 +3,91 @@\n RSpec.describe ApiJsonController, type: :controller do\n \n   controller(ApiJsonController) do\n+    skip_authorization_check only: :index\n+    authorize_resource except: :index, class: false\n+\n     def index\n       head :no_content\n     end\n-  end\n \n-  it_behaves_like 'not authenticated' do\n-    before do\n-      get :index\n+    def show\n+      render json: {}\n     end\n   end\n \n-  it_behaves_like 'authenticated' do\n+  context 'for an authenticated but any authorization endpoint' do\n \n-    context 'when not requesting JSON' do\n+    it_behaves_like 'unauthenticated not allowed'  do\n       before do\n-        @request.set_header 'HTTP_ACCEPT', 'text/plain'\n+        get :index\n       end\n+    end\n \n-      it 'should return a 406 Not Acceptable' do\n-        get :index\n-        expect(response).to have_http_status(406)\n+    it_behaves_like 'authenticated' do\n+\n+      context 'when not requesting JSON' do\n+        before do\n+          @request.set_header 'HTTP_ACCEPT', 'text/plain'\n+        end\n+\n+        it 'should return a 406 Not Acceptable' do\n+          get :index\n+          expect(response).to have_http_status(406)\n+        end\n       end\n+\n+      context 'when requesting JSON' do\n+        it 'should serve request as expected' do\n+          get :index\n+          expect(response).to have_http_status(204)\n+        end\n+      end\n+\n     end\n \n-    context 'when requesting JSON' do\n-      it 'should serve request as expected' do\n-        get :index\n-        expect(response).to have_http_status(204)\n+  end\n+\n+  context 'for an authenticated and admin only endpoint' do\n+\n+    it_behaves_like 'unauthenticated not allowed'  do\n+      before do\n+        get :show, params: { id: 'foo' }\n       end\n     end\n \n+    it_behaves_like 'authenticated' do\n+\n+      it_behaves_like 'not an admin so forbidden'  do\n+        before do\n+          get :show, params: { id: 'foo' }\n+        end\n+      end\n+\n+      it_behaves_like 'an admin' do\n+\n+        context 'when not requesting JSON' do\n+          before do\n+            @request.set_header 'HTTP_ACCEPT', 'text/plain'","path":"platform-hub-api/spec/controllers/api_json_controller_spec.rb","position":82,"original_position":82,"commit_id":"5ca855d3dd8c8464753ad1f57a3b00cffa0d5ac2","original_commit_id":"5ca855d3dd8c8464753ad1f57a3b00cffa0d5ac2","user":{"login":"jits","id":31973,"avatar_url":"https://avatars.githubusercontent.com/u/31973?v=3","gravatar_id":"","url":"https://api.github.com/users/jits","html_url":"https://github.com/jits","followers_url":"https://api.github.com/users/jits/followers","following_url":"https://api.github.com/users/jits/following{/other_user}","gists_url":"https://api.github.com/users/jits/gists{/gist_id}","starred_url":"https://api.github.com/users/jits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jits/subscriptions","organizations_url":"https://api.github.com/users/jits/orgs","repos_url":"https://api.github.com/users/jits/repos","events_url":"https://api.github.com/users/jits/events{/privacy}","received_events_url":"https://api.github.com/users/jits/received_events","type":"User","site_admin":false},"body":"It's only repeated once, in this set of specs.","created_at":"2017-02-02T13:38:50Z","updated_at":"2017-02-02T13:38:50Z","html_url":"https://github.com/UKHomeOffice/platform-hub/pull/4#discussion_r99120330","pull_request_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls/comments/99120330"},"html":{"href":"https://github.com/UKHomeOffice/platform-hub/pull/4#discussion_r99120330"},"pull_request":{"href":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls/4","id":104143929,"html_url":"https://github.com/UKHomeOffice/platform-hub/pull/4","diff_url":"https://github.com/UKHomeOffice/platform-hub/pull/4.diff","patch_url":"https://github.com/UKHomeOffice/platform-hub/pull/4.patch","issue_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/issues/4","number":4,"state":"open","locked":false,"title":"Initial hub admin flows and project structures","user":{"login":"jits","id":31973,"avatar_url":"https://avatars.githubusercontent.com/u/31973?v=3","gravatar_id":"","url":"https://api.github.com/users/jits","html_url":"https://github.com/jits","followers_url":"https://api.github.com/users/jits/followers","following_url":"https://api.github.com/users/jits/following{/other_user}","gists_url":"https://api.github.com/users/jits/gists{/gist_id}","starred_url":"https://api.github.com/users/jits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jits/subscriptions","organizations_url":"https://api.github.com/users/jits/orgs","repos_url":"https://api.github.com/users/jits/repos","events_url":"https://api.github.com/users/jits/events{/privacy}","received_events_url":"https://api.github.com/users/jits/received_events","type":"User","site_admin":false},"body":"(see individual commits for details)\r\n\r\n- Users can have an `admin` role\r\n- Admins can view a list of users, and their connected identities\r\n- Admins can make other users admins, or revoke admin status\r\n- Any authenticated user can view a list of Projects and their team members\r\n- Admins can create, edit and delete projects\r\n- Admins can add users as team members to projects","created_at":"2017-02-01T14:15:32Z","updated_at":"2017-02-02T13:38:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1099b30ced200c0d3407db8751da22777acc8b2d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls/4/commits","review_comments_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls/4/comments","review_comment_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls/comments{/number}","comments_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/issues/4/comments","statuses_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/statuses/5ca855d3dd8c8464753ad1f57a3b00cffa0d5ac2","head":{"label":"UKHomeOffice:admin-flows-and-project-team-structures","ref":"admin-flows-and-project-team-structures","sha":"5ca855d3dd8c8464753ad1f57a3b00cffa0d5ac2","user":{"login":"UKHomeOffice","id":3778081,"avatar_url":"https://avatars.githubusercontent.com/u/3778081?v=3","gravatar_id":"","url":"https://api.github.com/users/UKHomeOffice","html_url":"https://github.com/UKHomeOffice","followers_url":"https://api.github.com/users/UKHomeOffice/followers","following_url":"https://api.github.com/users/UKHomeOffice/following{/other_user}","gists_url":"https://api.github.com/users/UKHomeOffice/gists{/gist_id}","starred_url":"https://api.github.com/users/UKHomeOffice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UKHomeOffice/subscriptions","organizations_url":"https://api.github.com/users/UKHomeOffice/orgs","repos_url":"https://api.github.com/users/UKHomeOffice/repos","events_url":"https://api.github.com/users/UKHomeOffice/events{/privacy}","received_events_url":"https://api.github.com/users/UKHomeOffice/received_events","type":"Organization","site_admin":false},"repo":{"id":78856365,"name":"platform-hub","full_name":"UKHomeOffice/platform-hub","owner":{"login":"UKHomeOffice","id":3778081,"avatar_url":"https://avatars.githubusercontent.com/u/3778081?v=3","gravatar_id":"","url":"https://api.github.com/users/UKHomeOffice","html_url":"https://github.com/UKHomeOffice","followers_url":"https://api.github.com/users/UKHomeOffice/followers","following_url":"https://api.github.com/users/UKHomeOffice/following{/other_user}","gists_url":"https://api.github.com/users/UKHomeOffice/gists{/gist_id}","starred_url":"https://api.github.com/users/UKHomeOffice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UKHomeOffice/subscriptions","organizations_url":"https://api.github.com/users/UKHomeOffice/orgs","repos_url":"https://api.github.com/users/UKHomeOffice/repos","events_url":"https://api.github.com/users/UKHomeOffice/events{/privacy}","received_events_url":"https://api.github.com/users/UKHomeOffice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UKHomeOffice/platform-hub","description":"The HO DSP Hosting Platform Hub application","fork":false,"url":"https://api.github.com/repos/UKHomeOffice/platform-hub","forks_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/forks","keys_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/teams","hooks_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/hooks","issue_events_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/issues/events{/number}","events_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/events","assignees_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/assignees{/user}","branches_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/branches{/branch}","tags_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/tags","blobs_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/git/refs{/sha}","trees_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/statuses/{sha}","languages_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/languages","stargazers_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/stargazers","contributors_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/contributors","subscribers_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/subscribers","subscription_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/subscription","commits_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/commits{/sha}","git_commits_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/git/commits{/sha}","comments_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/comments{/number}","issue_comment_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/issues/comments{/number}","contents_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/contents/{+path}","compare_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/merges","archive_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/downloads","issues_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/issues{/number}","pulls_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls{/number}","milestones_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/milestones{/number}","notifications_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/labels{/name}","releases_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/releases{/id}","deployments_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/deployments","created_at":"2017-01-13T14:30:18Z","updated_at":"2017-01-13T14:41:20Z","pushed_at":"2017-02-01T16:46:51Z","git_url":"git://github.com/UKHomeOffice/platform-hub.git","ssh_url":"git@github.com:UKHomeOffice/platform-hub.git","clone_url":"https://github.com/UKHomeOffice/platform-hub.git","svn_url":"https://github.com/UKHomeOffice/platform-hub","homepage":null,"size":221,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"UKHomeOffice:master","ref":"master","sha":"a2fec41e4b955e593083470e92633e06e1b57897","user":{"login":"UKHomeOffice","id":3778081,"avatar_url":"https://avatars.githubusercontent.com/u/3778081?v=3","gravatar_id":"","url":"https://api.github.com/users/UKHomeOffice","html_url":"https://github.com/UKHomeOffice","followers_url":"https://api.github.com/users/UKHomeOffice/followers","following_url":"https://api.github.com/users/UKHomeOffice/following{/other_user}","gists_url":"https://api.github.com/users/UKHomeOffice/gists{/gist_id}","starred_url":"https://api.github.com/users/UKHomeOffice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UKHomeOffice/subscriptions","organizations_url":"https://api.github.com/users/UKHomeOffice/orgs","repos_url":"https://api.github.com/users/UKHomeOffice/repos","events_url":"https://api.github.com/users/UKHomeOffice/events{/privacy}","received_events_url":"https://api.github.com/users/UKHomeOffice/received_events","type":"Organization","site_admin":false},"repo":{"id":78856365,"name":"platform-hub","full_name":"UKHomeOffice/platform-hub","owner":{"login":"UKHomeOffice","id":3778081,"avatar_url":"https://avatars.githubusercontent.com/u/3778081?v=3","gravatar_id":"","url":"https://api.github.com/users/UKHomeOffice","html_url":"https://github.com/UKHomeOffice","followers_url":"https://api.github.com/users/UKHomeOffice/followers","following_url":"https://api.github.com/users/UKHomeOffice/following{/other_user}","gists_url":"https://api.github.com/users/UKHomeOffice/gists{/gist_id}","starred_url":"https://api.github.com/users/UKHomeOffice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UKHomeOffice/subscriptions","organizations_url":"https://api.github.com/users/UKHomeOffice/orgs","repos_url":"https://api.github.com/users/UKHomeOffice/repos","events_url":"https://api.github.com/users/UKHomeOffice/events{/privacy}","received_events_url":"https://api.github.com/users/UKHomeOffice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UKHomeOffice/platform-hub","description":"The HO DSP Hosting Platform Hub application","fork":false,"url":"https://api.github.com/repos/UKHomeOffice/platform-hub","forks_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/forks","keys_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/teams","hooks_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/hooks","issue_events_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/issues/events{/number}","events_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/events","assignees_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/assignees{/user}","branches_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/branches{/branch}","tags_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/tags","blobs_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/git/refs{/sha}","trees_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/statuses/{sha}","languages_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/languages","stargazers_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/stargazers","contributors_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/contributors","subscribers_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/subscribers","subscription_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/subscription","commits_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/commits{/sha}","git_commits_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/git/commits{/sha}","comments_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/comments{/number}","issue_comment_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/issues/comments{/number}","contents_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/contents/{+path}","compare_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/merges","archive_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/downloads","issues_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/issues{/number}","pulls_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls{/number}","milestones_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/milestones{/number}","notifications_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/labels{/name}","releases_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/releases{/id}","deployments_url":"https://api.github.com/repos/UKHomeOffice/platform-hub/deployments","created_at":"2017-01-13T14:30:18Z","updated_at":"2017-01-13T14:41:20Z","pushed_at":"2017-02-01T16:46:51Z","git_url":"git://github.com/UKHomeOffice/platform-hub.git","ssh_url":"git@github.com:UKHomeOffice/platform-hub.git","clone_url":"https://github.com/UKHomeOffice/platform-hub.git","svn_url":"https://github.com/UKHomeOffice/platform-hub","homepage":null,"size":221,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls/4"},"html":{"href":"https://github.com/UKHomeOffice/platform-hub/pull/4"},"issue":{"href":"https://api.github.com/repos/UKHomeOffice/platform-hub/issues/4"},"comments":{"href":"https://api.github.com/repos/UKHomeOffice/platform-hub/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/UKHomeOffice/platform-hub/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/UKHomeOffice/platform-hub/statuses/5ca855d3dd8c8464753ad1f57a3b00cffa0d5ac2"}}}}
{"actor":{"display_login":"jits"}}