Replace unprocessable_entity -> unprocessable_content (#35658)
This commit is contained in:
@@ -20,7 +20,7 @@ class Api::V2::SearchController < Api::BaseController
|
|||||||
@search = Search.new(search_results)
|
@search = Search.new(search_results)
|
||||||
render json: @search, serializer: REST::SearchSerializer
|
render json: @search, serializer: REST::SearchSerializer
|
||||||
rescue Mastodon::SyntaxError
|
rescue Mastodon::SyntaxError
|
||||||
unprocessable_entity
|
unprocessable_content
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
not_found
|
not_found
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class ApplicationController < ActionController::Base
|
|||||||
rescue_from Mastodon::NotPermittedError, with: :forbidden
|
rescue_from Mastodon::NotPermittedError, with: :forbidden
|
||||||
rescue_from ActionController::RoutingError, ActiveRecord::RecordNotFound, with: :not_found
|
rescue_from ActionController::RoutingError, ActiveRecord::RecordNotFound, with: :not_found
|
||||||
rescue_from ActionController::UnknownFormat, with: :not_acceptable
|
rescue_from ActionController::UnknownFormat, with: :not_acceptable
|
||||||
rescue_from ActionController::InvalidAuthenticityToken, with: :unprocessable_entity
|
rescue_from ActionController::InvalidAuthenticityToken, with: :unprocessable_content
|
||||||
rescue_from Mastodon::RateLimitExceededError, with: :too_many_requests
|
rescue_from Mastodon::RateLimitExceededError, with: :too_many_requests
|
||||||
|
|
||||||
rescue_from(*Mastodon::HTTP_CONNECTION_ERRORS, with: :internal_server_error)
|
rescue_from(*Mastodon::HTTP_CONNECTION_ERRORS, with: :internal_server_error)
|
||||||
@@ -123,7 +123,7 @@ class ApplicationController < ActionController::Base
|
|||||||
respond_with_error(410)
|
respond_with_error(410)
|
||||||
end
|
end
|
||||||
|
|
||||||
def unprocessable_entity
|
def unprocessable_content
|
||||||
respond_with_error(422)
|
respond_with_error(422)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ module Settings
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
flash[:error] = I18n.t('webauthn_credentials.create.error')
|
flash[:error] = I18n.t('webauthn_credentials.create.error')
|
||||||
status = :unprocessable_entity
|
status = :unprocessable_content
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
flash[:error] = t('webauthn_credentials.create.error')
|
flash[:error] = t('webauthn_credentials.create.error')
|
||||||
|
|||||||
@@ -219,16 +219,16 @@ RSpec.describe ApplicationController do
|
|||||||
it_behaves_like 'error response', 410
|
it_behaves_like 'error response', 410
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'unprocessable_entity' do
|
describe 'unprocessable_content' do
|
||||||
controller do
|
controller do
|
||||||
def route_unprocessable_entity
|
def route_unprocessable_content
|
||||||
unprocessable_entity
|
unprocessable_content
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
routes.draw { get 'route_unprocessable_entity' => 'anonymous#route_unprocessable_entity' }
|
routes.draw { get 'route_unprocessable_content' => 'anonymous#route_unprocessable_content' }
|
||||||
get 'route_unprocessable_entity'
|
get 'route_unprocessable_content'
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'error response', 422
|
it_behaves_like 'error response', 422
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ RSpec.describe 'Search API' do
|
|||||||
context 'when search raises syntax error' do
|
context 'when search raises syntax error' do
|
||||||
before { allow(Search).to receive(:new).and_raise(Mastodon::SyntaxError) }
|
before { allow(Search).to receive(:new).and_raise(Mastodon::SyntaxError) }
|
||||||
|
|
||||||
it 'returns http unprocessable_entity' do
|
it 'returns http unprocessable_content' do
|
||||||
get '/api/v2/search', headers: headers, params: params
|
get '/api/v2/search', headers: headers, params: params
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(422)
|
||||||
|
|||||||
Reference in New Issue
Block a user