{"action":"created","comment":{"url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls/comments/39916375","id":39916375,"diff_hunk":"@@ -174,4 +174,101 @@ def doorkeeper_unauthorized_render_options(error: nil)\n       end\n     end\n   end\n+\n+  context 'when custom forbidden render options are configured' do\n+    after do\n+      module ControllerActions\n+        def doorkeeper_forbidden_render_options(error: nil)\n+        end\n+      end\n+    end\n+\n+    controller do\n+      before_filter -> { doorkeeper_authorize! :write }\n+\n+      include ControllerActions\n+    end\n+\n+    let(:token_string) { '1A2DUWE' }\n+\n+    context 'with a JSON custom render' do\n+      before do\n+        module ControllerActions\n+          def doorkeeper_forbidden_render_options(error: nil)\n+            { json: { error_message: 'Forbidden' } }\n+          end\n+        end\n+      end\n+\n+      it 'renders a custom JSON response' do\n+        forbidden_render_test\n+        expect(response.content_type).to eq('application/json')\n+        expect(response.status).to eq 403\n+        parsed_body = JSON.parse(response.body)\n+        expect(parsed_body).not_to be_nil\n+        expect(parsed_body['error_message']).to match('Forbidden')\n+      end\n+    end\n+\n+    context 'with a status and JSON custom render' do\n+      before do\n+        module ControllerActions\n+          def doorkeeper_forbidden_render_options(error: nil)\n+            { json: { error_message: 'Not Found' }, status: 404 }\n+          end\n+        end\n+      end\n+\n+      it 'renders a custom JSON response' do\n+        forbidden_render_test\n+        expect(response.content_type).to eq('application/json')\n+        expect(response.status).to eq 404\n+        parsed_body = JSON.parse(response.body)\n+        expect(parsed_body).not_to be_nil\n+        expect(parsed_body['error_message']).to match('Not Found')\n+      end\n+    end\n+\n+    context 'with a text custom render' do\n+      before do\n+        module ControllerActions\n+          def doorkeeper_forbidden_render_options(error: nil)\n+            { text: 'Forbidden' }\n+          end\n+        end\n+      end\n+\n+      it 'renders a custom status code and text response' do\n+        forbidden_render_test\n+        expect(response.status).to eq 403\n+        expect(response.body).to eq('Forbidden')\n+      end\n+    end\n+\n+    context 'with a status and text custom render' do\n+      before do\n+        module ControllerActions\n+          def doorkeeper_forbidden_render_options(error: nil)","path":"spec/controllers/protected_resources_controller_spec.rb","position":87,"original_position":87,"commit_id":"74b34dbaee21491b7b69a9672ec17d83587545c8","original_commit_id":"74b34dbaee21491b7b69a9672ec17d83587545c8","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":"Unused method argument - `error`. You can also write as `doorkeeper_forbidden_render_options(*)` if you want the method to accept any arguments but don't care about them.","created_at":"2015-09-19T04:57:53Z","updated_at":"2015-09-19T04:57:53Z","html_url":"https://github.com/doorkeeper-gem/doorkeeper/pull/722#discussion_r39916375","pull_request_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls/722","_links":{"self":{"href":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls/comments/39916375"},"html":{"href":"https://github.com/doorkeeper-gem/doorkeeper/pull/722#discussion_r39916375"},"pull_request":{"href":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls/722"}}},"pull_request":{"url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls/722","id":45470040,"html_url":"https://github.com/doorkeeper-gem/doorkeeper/pull/722","diff_url":"https://github.com/doorkeeper-gem/doorkeeper/pull/722.diff","patch_url":"https://github.com/doorkeeper-gem/doorkeeper/pull/722.patch","issue_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues/722","number":722,"state":"open","locked":false,"title":"Add support for overriding forbidden status code","user":{"login":"jeffreyc","id":526530,"avatar_url":"https://avatars.githubusercontent.com/u/526530?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffreyc","html_url":"https://github.com/jeffreyc","followers_url":"https://api.github.com/users/jeffreyc/followers","following_url":"https://api.github.com/users/jeffreyc/following{/other_user}","gists_url":"https://api.github.com/users/jeffreyc/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffreyc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffreyc/subscriptions","organizations_url":"https://api.github.com/users/jeffreyc/orgs","repos_url":"https://api.github.com/users/jeffreyc/repos","events_url":"https://api.github.com/users/jeffreyc/events{/privacy}","received_events_url":"https://api.github.com/users/jeffreyc/received_events","type":"User","site_admin":false},"body":"Doorkeeper allows you to specify the message returned when a forbidden error is triggered (*e.g.*, a token does not have the correct scope). However, it does not allow you to specify the status code. A common practice is to return a 404 for 403s. This updates `doorkeeper_forbidden_render_options` to allow specifying a `status` as well as `text`/`json` and `layout`, overriding `error.status`.\r\n\r\nI didn't find any tests for `doorkeeper_forbidden_render_options`, so I added coverage similar to `doorkeeper_unauthorized_render_options`.\r\n\r\nThis includes a changelog message, though it might make more sense to update https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-the-response-body-when-unauthorized to detail both the unauthorized and forbidden options \r\n\r\nI also fixed a misnamed test.\r\n","created_at":"2015-09-19T04:53:05Z","updated_at":"2015-09-19T04:57:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"69bac4bd7653e2a66f14e318e6ef059436c1ea32","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls/722/commits","review_comments_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls/722/comments","review_comment_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues/722/comments","statuses_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/statuses/74b34dbaee21491b7b69a9672ec17d83587545c8","head":{"label":"jeffreyc:render_error_status","ref":"render_error_status","sha":"74b34dbaee21491b7b69a9672ec17d83587545c8","user":{"login":"jeffreyc","id":526530,"avatar_url":"https://avatars.githubusercontent.com/u/526530?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffreyc","html_url":"https://github.com/jeffreyc","followers_url":"https://api.github.com/users/jeffreyc/followers","following_url":"https://api.github.com/users/jeffreyc/following{/other_user}","gists_url":"https://api.github.com/users/jeffreyc/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffreyc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffreyc/subscriptions","organizations_url":"https://api.github.com/users/jeffreyc/orgs","repos_url":"https://api.github.com/users/jeffreyc/repos","events_url":"https://api.github.com/users/jeffreyc/events{/privacy}","received_events_url":"https://api.github.com/users/jeffreyc/received_events","type":"User","site_admin":false},"repo":{"id":42754802,"name":"doorkeeper","full_name":"jeffreyc/doorkeeper","owner":{"login":"jeffreyc","id":526530,"avatar_url":"https://avatars.githubusercontent.com/u/526530?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffreyc","html_url":"https://github.com/jeffreyc","followers_url":"https://api.github.com/users/jeffreyc/followers","following_url":"https://api.github.com/users/jeffreyc/following{/other_user}","gists_url":"https://api.github.com/users/jeffreyc/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffreyc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffreyc/subscriptions","organizations_url":"https://api.github.com/users/jeffreyc/orgs","repos_url":"https://api.github.com/users/jeffreyc/repos","events_url":"https://api.github.com/users/jeffreyc/events{/privacy}","received_events_url":"https://api.github.com/users/jeffreyc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeffreyc/doorkeeper","description":"Doorkeeper is an OAuth 2 provider for Rails and Grape","fork":true,"url":"https://api.github.com/repos/jeffreyc/doorkeeper","forks_url":"https://api.github.com/repos/jeffreyc/doorkeeper/forks","keys_url":"https://api.github.com/repos/jeffreyc/doorkeeper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeffreyc/doorkeeper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeffreyc/doorkeeper/teams","hooks_url":"https://api.github.com/repos/jeffreyc/doorkeeper/hooks","issue_events_url":"https://api.github.com/repos/jeffreyc/doorkeeper/issues/events{/number}","events_url":"https://api.github.com/repos/jeffreyc/doorkeeper/events","assignees_url":"https://api.github.com/repos/jeffreyc/doorkeeper/assignees{/user}","branches_url":"https://api.github.com/repos/jeffreyc/doorkeeper/branches{/branch}","tags_url":"https://api.github.com/repos/jeffreyc/doorkeeper/tags","blobs_url":"https://api.github.com/repos/jeffreyc/doorkeeper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeffreyc/doorkeeper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeffreyc/doorkeeper/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeffreyc/doorkeeper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeffreyc/doorkeeper/statuses/{sha}","languages_url":"https://api.github.com/repos/jeffreyc/doorkeeper/languages","stargazers_url":"https://api.github.com/repos/jeffreyc/doorkeeper/stargazers","contributors_url":"https://api.github.com/repos/jeffreyc/doorkeeper/contributors","subscribers_url":"https://api.github.com/repos/jeffreyc/doorkeeper/subscribers","subscription_url":"https://api.github.com/repos/jeffreyc/doorkeeper/subscription","commits_url":"https://api.github.com/repos/jeffreyc/doorkeeper/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeffreyc/doorkeeper/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeffreyc/doorkeeper/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeffreyc/doorkeeper/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeffreyc/doorkeeper/contents/{+path}","compare_url":"https://api.github.com/repos/jeffreyc/doorkeeper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeffreyc/doorkeeper/merges","archive_url":"https://api.github.com/repos/jeffreyc/doorkeeper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeffreyc/doorkeeper/downloads","issues_url":"https://api.github.com/repos/jeffreyc/doorkeeper/issues{/number}","pulls_url":"https://api.github.com/repos/jeffreyc/doorkeeper/pulls{/number}","milestones_url":"https://api.github.com/repos/jeffreyc/doorkeeper/milestones{/number}","notifications_url":"https://api.github.com/repos/jeffreyc/doorkeeper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeffreyc/doorkeeper/labels{/name}","releases_url":"https://api.github.com/repos/jeffreyc/doorkeeper/releases{/id}","created_at":"2015-09-19T01:35:31Z","updated_at":"2015-09-19T01:35:33Z","pushed_at":"2015-09-19T04:55:04Z","git_url":"git://github.com/jeffreyc/doorkeeper.git","ssh_url":"git@github.com:jeffreyc/doorkeeper.git","clone_url":"https://github.com/jeffreyc/doorkeeper.git","svn_url":"https://github.com/jeffreyc/doorkeeper","homepage":"","size":6236,"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":"doorkeeper-gem:master","ref":"master","sha":"a70e1a86cf5290dd642e00aedbdbb94bfd553f6b","user":{"login":"doorkeeper-gem","id":7275750,"avatar_url":"https://avatars.githubusercontent.com/u/7275750?v=3","gravatar_id":"","url":"https://api.github.com/users/doorkeeper-gem","html_url":"https://github.com/doorkeeper-gem","followers_url":"https://api.github.com/users/doorkeeper-gem/followers","following_url":"https://api.github.com/users/doorkeeper-gem/following{/other_user}","gists_url":"https://api.github.com/users/doorkeeper-gem/gists{/gist_id}","starred_url":"https://api.github.com/users/doorkeeper-gem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doorkeeper-gem/subscriptions","organizations_url":"https://api.github.com/users/doorkeeper-gem/orgs","repos_url":"https://api.github.com/users/doorkeeper-gem/repos","events_url":"https://api.github.com/users/doorkeeper-gem/events{/privacy}","received_events_url":"https://api.github.com/users/doorkeeper-gem/received_events","type":"Organization","site_admin":false},"repo":{"id":2802565,"name":"doorkeeper","full_name":"doorkeeper-gem/doorkeeper","owner":{"login":"doorkeeper-gem","id":7275750,"avatar_url":"https://avatars.githubusercontent.com/u/7275750?v=3","gravatar_id":"","url":"https://api.github.com/users/doorkeeper-gem","html_url":"https://github.com/doorkeeper-gem","followers_url":"https://api.github.com/users/doorkeeper-gem/followers","following_url":"https://api.github.com/users/doorkeeper-gem/following{/other_user}","gists_url":"https://api.github.com/users/doorkeeper-gem/gists{/gist_id}","starred_url":"https://api.github.com/users/doorkeeper-gem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doorkeeper-gem/subscriptions","organizations_url":"https://api.github.com/users/doorkeeper-gem/orgs","repos_url":"https://api.github.com/users/doorkeeper-gem/repos","events_url":"https://api.github.com/users/doorkeeper-gem/events{/privacy}","received_events_url":"https://api.github.com/users/doorkeeper-gem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/doorkeeper-gem/doorkeeper","description":"Doorkeeper is an OAuth 2 provider for Rails and Grape","fork":false,"url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper","forks_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/forks","keys_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/teams","hooks_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/hooks","issue_events_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues/events{/number}","events_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/events","assignees_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/assignees{/user}","branches_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/branches{/branch}","tags_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/tags","blobs_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/git/refs{/sha}","trees_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/statuses/{sha}","languages_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/languages","stargazers_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/stargazers","contributors_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/contributors","subscribers_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/subscribers","subscription_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/subscription","commits_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/commits{/sha}","git_commits_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/git/commits{/sha}","comments_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/comments{/number}","issue_comment_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues/comments{/number}","contents_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/contents/{+path}","compare_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/merges","archive_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/downloads","issues_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues{/number}","pulls_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls{/number}","milestones_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/milestones{/number}","notifications_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/labels{/name}","releases_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/releases{/id}","created_at":"2011-11-18T13:02:01Z","updated_at":"2015-09-18T22:51:33Z","pushed_at":"2015-09-19T04:55:04Z","git_url":"git://github.com/doorkeeper-gem/doorkeeper.git","ssh_url":"git@github.com:doorkeeper-gem/doorkeeper.git","clone_url":"https://github.com/doorkeeper-gem/doorkeeper.git","svn_url":"https://github.com/doorkeeper-gem/doorkeeper","homepage":"","size":6236,"stargazers_count":2572,"watchers_count":2572,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":520,"mirror_url":null,"open_issues_count":20,"forks":520,"open_issues":20,"watchers":2572,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls/722"},"html":{"href":"https://github.com/doorkeeper-gem/doorkeeper/pull/722"},"issue":{"href":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues/722"},"comments":{"href":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues/722/comments"},"review_comments":{"href":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls/722/comments"},"review_comment":{"href":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/pulls/722/commits"},"statuses":{"href":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/statuses/74b34dbaee21491b7b69a9672ec17d83587545c8"}}}}