Replace obsolete HTTP status code :unprocessable_entity
The new naming is :unprocessable_content and required by Rack 3.1+
This commit is contained in:

committed by
Sebastian Serth

parent
4e1e8c0f4d
commit
092487344a
@ -107,7 +107,7 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def render_csrf_error
|
def render_csrf_error
|
||||||
render_error t('sessions.expired'), :unprocessable_entity
|
render_error t('sessions.expired'), :unprocessable_content
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_not_authorized
|
def render_not_authorized
|
||||||
|
@ -69,7 +69,7 @@ module CodeOcean
|
|||||||
flash[:danger] = t('code_ocean/files.error.filename', name: filename)
|
flash[:danger] = t('code_ocean/files.error.filename', name: filename)
|
||||||
redirect_to(options[:path])
|
redirect_to(options[:path])
|
||||||
end
|
end
|
||||||
format.json { render(json: @object.errors, status: :unprocessable_entity) }
|
format.json { render(json: @object.errors, status: :unprocessable_content) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -45,7 +45,7 @@ class CommentsController < ApplicationController
|
|||||||
|
|
||||||
render :show, status: :created, location: @comment
|
render :show, status: :created, location: @comment
|
||||||
else
|
else
|
||||||
render json: @comment.errors, status: :unprocessable_entity
|
render json: @comment.errors, status: :unprocessable_content
|
||||||
end
|
end
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
@ -55,7 +55,7 @@ class CommentsController < ApplicationController
|
|||||||
if @comment.update(comment_params_for_update)
|
if @comment.update(comment_params_for_update)
|
||||||
render :show, status: :ok, location: @comment
|
render :show, status: :ok, location: @comment
|
||||||
else
|
else
|
||||||
render json: @comment.errors, status: :unprocessable_entity
|
render json: @comment.errors, status: :unprocessable_content
|
||||||
end
|
end
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
@ -32,7 +32,7 @@ module CommonBehavior
|
|||||||
|
|
||||||
def respond_with_invalid_object(format, options = {})
|
def respond_with_invalid_object(format, options = {})
|
||||||
format.html { render(options[:template]) }
|
format.html { render(options[:template]) }
|
||||||
format.json { render(json: @object.errors, status: :unprocessable_entity) }
|
format.json { render(json: @object.errors, status: :unprocessable_content) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def respond_with_valid_object(format, options = {})
|
def respond_with_valid_object(format, options = {})
|
||||||
|
@ -47,7 +47,7 @@ class ErrorTemplateAttributesController < ApplicationController
|
|||||||
format.json { render :show, status: :created, location: @error_template_attribute }
|
format.json { render :show, status: :created, location: @error_template_attribute }
|
||||||
else
|
else
|
||||||
format.html { render :new }
|
format.html { render :new }
|
||||||
format.json { render json: @error_template_attribute.errors, status: :unprocessable_entity }
|
format.json { render json: @error_template_attribute.errors, status: :unprocessable_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -64,7 +64,7 @@ class ErrorTemplateAttributesController < ApplicationController
|
|||||||
format.json { render :show, status: :ok, location: @error_template_attribute }
|
format.json { render :show, status: :ok, location: @error_template_attribute }
|
||||||
else
|
else
|
||||||
format.html { render :edit }
|
format.html { render :edit }
|
||||||
format.json { render json: @error_template_attribute.errors, status: :unprocessable_entity }
|
format.json { render json: @error_template_attribute.errors, status: :unprocessable_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -44,7 +44,7 @@ class ErrorTemplatesController < ApplicationController
|
|||||||
format.json { render :show, status: :created, location: @error_template }
|
format.json { render :show, status: :created, location: @error_template }
|
||||||
else
|
else
|
||||||
format.html { render :new }
|
format.html { render :new }
|
||||||
format.json { render json: @error_template.errors, status: :unprocessable_entity }
|
format.json { render json: @error_template.errors, status: :unprocessable_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -59,7 +59,7 @@ class ErrorTemplatesController < ApplicationController
|
|||||||
format.json { render :show, status: :ok, location: @error_template }
|
format.json { render :show, status: :ok, location: @error_template }
|
||||||
else
|
else
|
||||||
format.html { render :edit }
|
format.html { render :edit }
|
||||||
format.json { render json: @error_template.errors, status: :unprocessable_entity }
|
format.json { render json: @error_template.errors, status: :unprocessable_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,8 +11,8 @@ class EventsController < ApplicationController
|
|||||||
format.html { head :created }
|
format.html { head :created }
|
||||||
format.json { head :created }
|
format.json { head :created }
|
||||||
else
|
else
|
||||||
format.html { head :unprocessable_entity }
|
format.html { head :unprocessable_content }
|
||||||
format.json { head :unprocessable_entity }
|
format.json { head :unprocessable_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -52,7 +52,7 @@ class FileTemplatesController < ApplicationController
|
|||||||
format.json { render :show, status: :created, location: @file_template }
|
format.json { render :show, status: :created, location: @file_template }
|
||||||
else
|
else
|
||||||
format.html { render :new }
|
format.html { render :new }
|
||||||
format.json { render json: @file_template.errors, status: :unprocessable_entity }
|
format.json { render json: @file_template.errors, status: :unprocessable_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -67,7 +67,7 @@ class FileTemplatesController < ApplicationController
|
|||||||
format.json { render :show, status: :ok, location: @file_template }
|
format.json { render :show, status: :ok, location: @file_template }
|
||||||
else
|
else
|
||||||
format.html { render :edit }
|
format.html { render :edit }
|
||||||
format.json { render json: @file_template.errors, status: :unprocessable_entity }
|
format.json { render json: @file_template.errors, status: :unprocessable_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -123,7 +123,7 @@ class RequestForCommentsController < ApplicationController
|
|||||||
if @request_for_comment.save
|
if @request_for_comment.save
|
||||||
format.json { render :show, status: :ok, location: @request_for_comment }
|
format.json { render :show, status: :ok, location: @request_for_comment }
|
||||||
else
|
else
|
||||||
format.json { render json: @request_for_comment.errors, status: :unprocessable_entity }
|
format.json { render json: @request_for_comment.errors, status: :unprocessable_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -140,7 +140,7 @@ class RequestForCommentsController < ApplicationController
|
|||||||
if @request_for_comment.save
|
if @request_for_comment.save
|
||||||
format.json { render :show, status: :ok, location: @request_for_comment }
|
format.json { render :show, status: :ok, location: @request_for_comment }
|
||||||
else
|
else
|
||||||
format.json { render json: @request_for_comment.errors, status: :unprocessable_entity }
|
format.json { render json: @request_for_comment.errors, status: :unprocessable_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -183,7 +183,7 @@ class RequestForCommentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
format.html { render :new }
|
format.html { render :new }
|
||||||
format.json { render json: @request_for_comment.errors, status: :unprocessable_entity }
|
format.json { render json: @request_for_comment.errors, status: :unprocessable_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
authorize!
|
authorize!
|
||||||
|
@ -13,7 +13,7 @@ class SubscriptionsController < ApplicationController
|
|||||||
if @subscription.save
|
if @subscription.save
|
||||||
format.json { render json: @subscription, status: :created }
|
format.json { render json: @subscription, status: :created }
|
||||||
else
|
else
|
||||||
format.json { render json: @subscription.errors, status: :unprocessable_entity }
|
format.json { render json: @subscription.errors, status: :unprocessable_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
authorize!
|
authorize!
|
||||||
|
@ -58,7 +58,7 @@ RSpec.describe CodeOcean::FilesController do
|
|||||||
|
|
||||||
expect_assigns(file: CodeOcean::File)
|
expect_assigns(file: CodeOcean::File)
|
||||||
expect_json
|
expect_json
|
||||||
expect_http_status(:unprocessable_entity)
|
expect_http_status(:unprocessable_content)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@ RSpec.describe EventsController do
|
|||||||
before { post :create, params: {event: {exercise_id: 847_482}} }
|
before { post :create, params: {event: {exercise_id: 847_482}} }
|
||||||
|
|
||||||
expect_assigns(event: Event)
|
expect_assigns(event: Event)
|
||||||
expect_http_status(:unprocessable_entity)
|
expect_http_status(:unprocessable_content)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with no event' do
|
context 'with no event' do
|
||||||
before { post :create }
|
before { post :create }
|
||||||
|
|
||||||
expect_http_status(:unprocessable_entity)
|
expect_http_status(:unprocessable_content)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -36,7 +36,7 @@ RSpec.describe SubmissionsController do
|
|||||||
|
|
||||||
expect_assigns(submission: Submission)
|
expect_assigns(submission: Submission)
|
||||||
expect_json
|
expect_json
|
||||||
expect_http_status(:unprocessable_entity)
|
expect_http_status(:unprocessable_content)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user