diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a1b91309..3060d18d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -107,7 +107,7 @@ class ApplicationController < ActionController::Base end def render_csrf_error - render_error t('sessions.expired'), :unprocessable_entity + render_error t('sessions.expired'), :unprocessable_content end def render_not_authorized diff --git a/app/controllers/code_ocean/files_controller.rb b/app/controllers/code_ocean/files_controller.rb index 39ce811d..49111cc2 100644 --- a/app/controllers/code_ocean/files_controller.rb +++ b/app/controllers/code_ocean/files_controller.rb @@ -69,7 +69,7 @@ module CodeOcean flash[:danger] = t('code_ocean/files.error.filename', name: filename) redirect_to(options[:path]) end - format.json { render(json: @object.errors, status: :unprocessable_entity) } + format.json { render(json: @object.errors, status: :unprocessable_content) } end end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 79f9c839..ed832359 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -45,7 +45,7 @@ class CommentsController < ApplicationController render :show, status: :created, location: @comment else - render json: @comment.errors, status: :unprocessable_entity + render json: @comment.errors, status: :unprocessable_content end authorize! end @@ -55,7 +55,7 @@ class CommentsController < ApplicationController if @comment.update(comment_params_for_update) render :show, status: :ok, location: @comment else - render json: @comment.errors, status: :unprocessable_entity + render json: @comment.errors, status: :unprocessable_content end authorize! end diff --git a/app/controllers/concerns/common_behavior.rb b/app/controllers/concerns/common_behavior.rb index 34e05dc5..d4f4cac5 100644 --- a/app/controllers/concerns/common_behavior.rb +++ b/app/controllers/concerns/common_behavior.rb @@ -32,7 +32,7 @@ module CommonBehavior def respond_with_invalid_object(format, options = {}) format.html { render(options[:template]) } - format.json { render(json: @object.errors, status: :unprocessable_entity) } + format.json { render(json: @object.errors, status: :unprocessable_content) } end def respond_with_valid_object(format, options = {}) diff --git a/app/controllers/error_template_attributes_controller.rb b/app/controllers/error_template_attributes_controller.rb index b00b387a..88f736bd 100644 --- a/app/controllers/error_template_attributes_controller.rb +++ b/app/controllers/error_template_attributes_controller.rb @@ -47,7 +47,7 @@ class ErrorTemplateAttributesController < ApplicationController format.json { render :show, status: :created, location: @error_template_attribute } else 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 @@ -64,7 +64,7 @@ class ErrorTemplateAttributesController < ApplicationController format.json { render :show, status: :ok, location: @error_template_attribute } else 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 diff --git a/app/controllers/error_templates_controller.rb b/app/controllers/error_templates_controller.rb index 6b89e680..c8c376df 100644 --- a/app/controllers/error_templates_controller.rb +++ b/app/controllers/error_templates_controller.rb @@ -44,7 +44,7 @@ class ErrorTemplatesController < ApplicationController format.json { render :show, status: :created, location: @error_template } else 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 @@ -59,7 +59,7 @@ class ErrorTemplatesController < ApplicationController format.json { render :show, status: :ok, location: @error_template } else 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 diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 16ba0d63..e353537c 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -11,8 +11,8 @@ class EventsController < ApplicationController format.html { head :created } format.json { head :created } else - format.html { head :unprocessable_entity } - format.json { head :unprocessable_entity } + format.html { head :unprocessable_content } + format.json { head :unprocessable_content } end end end diff --git a/app/controllers/file_templates_controller.rb b/app/controllers/file_templates_controller.rb index 224860e0..f88a3726 100644 --- a/app/controllers/file_templates_controller.rb +++ b/app/controllers/file_templates_controller.rb @@ -52,7 +52,7 @@ class FileTemplatesController < ApplicationController format.json { render :show, status: :created, location: @file_template } else 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 @@ -67,7 +67,7 @@ class FileTemplatesController < ApplicationController format.json { render :show, status: :ok, location: @file_template } else 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 diff --git a/app/controllers/request_for_comments_controller.rb b/app/controllers/request_for_comments_controller.rb index b92de462..9df21cb8 100644 --- a/app/controllers/request_for_comments_controller.rb +++ b/app/controllers/request_for_comments_controller.rb @@ -123,7 +123,7 @@ class RequestForCommentsController < ApplicationController if @request_for_comment.save format.json { render :show, status: :ok, location: @request_for_comment } 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 @@ -140,7 +140,7 @@ class RequestForCommentsController < ApplicationController if @request_for_comment.save format.json { render :show, status: :ok, location: @request_for_comment } 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 @@ -183,7 +183,7 @@ class RequestForCommentsController < ApplicationController end else 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 authorize! diff --git a/app/controllers/subscriptions_controller.rb b/app/controllers/subscriptions_controller.rb index 65575884..dd8cd29e 100644 --- a/app/controllers/subscriptions_controller.rb +++ b/app/controllers/subscriptions_controller.rb @@ -13,7 +13,7 @@ class SubscriptionsController < ApplicationController if @subscription.save format.json { render json: @subscription, status: :created } else - format.json { render json: @subscription.errors, status: :unprocessable_entity } + format.json { render json: @subscription.errors, status: :unprocessable_content } end end authorize! diff --git a/spec/controllers/code_ocean/files_controller_spec.rb b/spec/controllers/code_ocean/files_controller_spec.rb index 3285f7fc..9ba96965 100644 --- a/spec/controllers/code_ocean/files_controller_spec.rb +++ b/spec/controllers/code_ocean/files_controller_spec.rb @@ -58,7 +58,7 @@ RSpec.describe CodeOcean::FilesController do expect_assigns(file: CodeOcean::File) expect_json - expect_http_status(:unprocessable_entity) + expect_http_status(:unprocessable_content) end end diff --git a/spec/controllers/events_controller_spec.rb b/spec/controllers/events_controller_spec.rb index e2f3da99..5f3b75e6 100644 --- a/spec/controllers/events_controller_spec.rb +++ b/spec/controllers/events_controller_spec.rb @@ -29,13 +29,13 @@ RSpec.describe EventsController do before { post :create, params: {event: {exercise_id: 847_482}} } expect_assigns(event: Event) - expect_http_status(:unprocessable_entity) + expect_http_status(:unprocessable_content) end context 'with no event' do before { post :create } - expect_http_status(:unprocessable_entity) + expect_http_status(:unprocessable_content) end end end diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index 1d346dca..f929062e 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -36,7 +36,7 @@ RSpec.describe SubmissionsController do expect_assigns(submission: Submission) expect_json - expect_http_status(:unprocessable_entity) + expect_http_status(:unprocessable_content) end end