app controller: fix api responses on access denied errors.

Bug: A .json/.xml/.js request that resulted in an access denied error
returned a html response instead of a .json/.xml/.js response.
This commit is contained in:
evazion
2019-08-25 20:29:32 -05:00
parent c7f8fbbec2
commit 8e39985d66
2 changed files with 13 additions and 4 deletions

View File

@@ -158,6 +158,14 @@ class ApplicationControllerTest < ActionDispatch::IntegrationTest
assert_response 403
assert_select "h1", /Access Denied/
end
should "render a json response for json requests" do
get news_updates_path(format: :json)
assert_response 403
assert_equal "application/json", response.content_type
assert_equal "Access denied", response.parsed_body["message"]
end
end
context "when the api limit is exceeded" do