Fix non-existent .js requests raising DoubleRenderError.
Fix requests for non-existent .js pages, for example https://danbooru.donmai.us/oaisfj.js, raising AbstractController::DoubleRenderError when trying to render the 404 response.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
class StaticController < ApplicationController
|
class StaticController < ApplicationController
|
||||||
respond_to :html, :json, :xml
|
respond_to :html, :json, :xml
|
||||||
|
skip_forgery_protection only: :not_found, if: -> { request.format.js? }
|
||||||
|
|
||||||
def privacy_policy
|
def privacy_policy
|
||||||
end
|
end
|
||||||
|
|||||||
0
app/views/static/not_found.js
Normal file
0
app/views/static/not_found.js
Normal file
@@ -71,6 +71,13 @@ class StaticControllerTest < ActionDispatch::IntegrationTest
|
|||||||
assert_equal("Page not found", response.parsed_body.xpath("result/message").text)
|
assert_equal("Page not found", response.parsed_body.xpath("result/message").text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "return a JS response for a 404'd .js request" do
|
||||||
|
get "/qwoiqogieqg.js"
|
||||||
|
|
||||||
|
assert_response 404
|
||||||
|
assert_equal("", response.body)
|
||||||
|
end
|
||||||
|
|
||||||
should "render the 404 page when page_not_found_pool_id is configured" do
|
should "render the 404 page when page_not_found_pool_id is configured" do
|
||||||
as(create(:user)) do
|
as(create(:user)) do
|
||||||
@post = create(:post, tag_string: "artist:bkub")
|
@post = create(:post, tag_string: "artist:bkub")
|
||||||
|
|||||||
Reference in New Issue
Block a user