Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Render with status: :unprocessable_entity

Oliver Güntherfa99c5bef6d0
diff --git a/app/controllers/attribute_help_texts_controller.rb b/app/controllers/attribute_help_texts_controller.rb
index 44aa15e6085..87637eed4bb 100644
--- a/app/controllers/attribute_help_texts_controller.rb
+++ b/app/controllers/attribute_help_texts_controller.rb
@@ -54,8 +54,8 @@ class AttributeHelpTextsController < ApplicationController
redirect_to attribute_help_texts_path(tab: call.result.attribute_scope)
else
@attribute_help_text = call.result
- flash[:error] = call.message || I18n.t("notice_internal_server_error")
- render action: "new"
+ flash.now[:error] = call.message || I18n.t("notice_internal_server_error")
+ render action: "new", status: :unprocessable_entity
end
end
@@ -68,8 +68,8 @@ class AttributeHelpTextsController < ApplicationController
flash[:notice] = t(:notice_successful_update)
redirect_to attribute_help_texts_path(tab: @attribute_help_text.attribute_scope)
else
- flash[:error] = call.message || I18n.t("notice_internal_server_error")
- render action: "edit"
+ flash.now[:error] = call.message || I18n.t("notice_internal_server_error")
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb
index b41f73c4759..0d8db7a9324 100644
--- a/app/controllers/categories_controller.rb
+++ b/app/controllers/categories_controller.rb
@@ -55,7 +55,7 @@ class CategoriesController < ApplicationController
else
respond_to do |format|
format.html do
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
format.js do
render(:update) { |page| page.alert(@category.errors.full_messages.join('\n')) }
@@ -70,7 +70,7 @@ class CategoriesController < ApplicationController
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to project_settings_categories_path(@project)
else
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/colors_controller.rb b/app/controllers/colors_controller.rb
index ed553c1ce1c..9aba619dff5 100644
--- a/app/controllers/colors_controller.rb
+++ b/app/controllers/colors_controller.rb
@@ -69,7 +69,7 @@ class ColorsController < ApplicationController
redirect_to colors_path
else
flash.now[:error] = I18n.t(:error_color_could_not_be_saved)
- render action: "new"
+ render action: :new, status: :unprocessable_entity
end
end
@@ -81,7 +81,7 @@ class ColorsController < ApplicationController
redirect_to colors_path
else
flash.now[:error] = I18n.t(:error_color_could_not_be_saved)
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/concerns/custom_fields/shared_actions.rb b/app/controllers/concerns/custom_fields/shared_actions.rb
index 44928935ff0..6ef1aee1df7 100644
--- a/app/controllers/concerns/custom_fields/shared_actions.rb
+++ b/app/controllers/concerns/custom_fields/shared_actions.rb
@@ -58,7 +58,7 @@ module CustomFields
redirect_to index_path(call.result, tab: call.result.class.name)
else
@custom_field = call.result || new_custom_field
- render action: "new"
+ render action: :new, status: :unprocessable_entity
end
end
@@ -76,7 +76,7 @@ module CustomFields
call_hook(:controller_custom_fields_edit_after_save, custom_field: @custom_field)
redirect_back_or_default(edit_path(@custom_field, id: @custom_field.id))
else
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/custom_actions_controller.rb b/app/controllers/custom_actions_controller.rb
index a7296b63959..a2ec48df759 100644
--- a/app/controllers/custom_actions_controller.rb
+++ b/app/controllers/custom_actions_controller.rb
@@ -77,7 +77,7 @@ class CustomActionsController < ApplicationController
call.on_failure do
@custom_action = call.result
- render action: render_action
+ render action: render_action, status: :unprocessable_entity
end
}
end
diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb
index a011ec00375..1c3dffe176e 100644
--- a/app/controllers/enterprises_controller.rb
+++ b/app/controllers/enterprises_controller.rb
@@ -64,7 +64,7 @@ class EnterprisesController < ApplicationController
@current_token = @token || EnterpriseToken.new
end
respond_to do |format|
- format.html { render action: :show }
+ format.html { render action: :show, status: :unprocessable_entity }
format.json { render json: { description: @token.errors.full_messages.join(", ") }, status: :bad_request }
end
end
diff --git a/app/controllers/enumerations_controller.rb b/app/controllers/enumerations_controller.rb
index e9dfc358734..c1b2be5ec7d 100644
--- a/app/controllers/enumerations_controller.rb
+++ b/app/controllers/enumerations_controller.rb
@@ -58,7 +58,7 @@ class EnumerationsController < ApplicationController
flash[:notice] = I18n.t(:notice_successful_create)
redirect_to action: "index", type: @enumeration.type
else
- render action: "new"
+ render action: :new, status: :unprocessable_entity
end
end
@@ -70,7 +70,7 @@ class EnumerationsController < ApplicationController
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to enumerations_path(type: @enumeration.type)
else
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
@@ -96,7 +96,7 @@ class EnumerationsController < ApplicationController
redirect_to enumerations_path
else
flash.now[:error] = I18n.t(:error_type_could_not_be_saved)
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb
index 1def837243c..434b7686ffd 100644
--- a/app/controllers/forums_controller.rb
+++ b/app/controllers/forums_controller.rb
@@ -111,7 +111,7 @@ class ForumsController < ApplicationController
flash[:notice] = t(:notice_successful_update)
else
flash.now[:error] = t("forum_could_not_be_saved")
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
redirect_to action: "index"
end
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 1694553a9fc..82de14c39b8 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -64,7 +64,7 @@ class GroupsController < ApplicationController
flash[:notice] = I18n.t(:notice_successful_create)
redirect_to(groups_path)
else
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
end
@@ -77,7 +77,7 @@ class GroupsController < ApplicationController
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to(groups_path)
else
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index d9e44f4aa30..ee25591af6a 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -89,7 +89,7 @@ class MessagesController < ApplicationController
redirect_to topic_path(@message)
else
- render action: "new"
+ render action: :new, status: :unprocessable_entity
end
end
@@ -118,7 +118,7 @@ class MessagesController < ApplicationController
@message.reload
redirect_to topic_path(@message.root, r: @message.parent_id && @message.id)
else
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index 1a36644447a..4e851f18bb9 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -82,7 +82,7 @@ class NewsController < ApplicationController
redirect_to controller: "/news", action: "index", project_id: @project
else
@news = call.result
- render action: "new"
+ render action: :new, status: :unprocessable_entity
end
end
@@ -96,7 +96,7 @@ class NewsController < ApplicationController
redirect_to action: "show", id: @news
else
@news = call.result
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb
index 0d32225d584..04686f9e908 100644
--- a/app/controllers/oauth/applications_controller.rb
+++ b/app/controllers/oauth/applications_controller.rb
@@ -61,7 +61,7 @@ module OAuth
redirect_to action: :show, id: result.id
else
@application = result
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
end
@@ -79,7 +79,7 @@ module OAuth
redirect_to action: :index
else
flash[:error] = call.errors.full_messages.join('\n')
- render action: :edit
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/placeholder_users_controller.rb b/app/controllers/placeholder_users_controller.rb
index 82d6660e274..809fd062e27 100644
--- a/app/controllers/placeholder_users_controller.rb
+++ b/app/controllers/placeholder_users_controller.rb
@@ -94,7 +94,7 @@ class PlaceholderUsersController < ApplicationController
else
respond_to do |format|
format.html do
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
end
end
@@ -118,7 +118,7 @@ class PlaceholderUsersController < ApplicationController
respond_to do |format|
format.html do
- render action: :edit
+ render action: :edit, status: :unprocessable_entity
end
end
end
diff --git a/app/controllers/projects/identifier_controller.rb b/app/controllers/projects/identifier_controller.rb
index 57462a5a531..f8527c7d4ba 100644
--- a/app/controllers/projects/identifier_controller.rb
+++ b/app/controllers/projects/identifier_controller.rb
@@ -42,7 +42,7 @@ class Projects::IdentifierController < ApplicationController
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to project_settings_general_path(@project)
else
- render action: "show"
+ render action: "show", status: :unprocessable_entity
end
end
end
diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb
index d4c2e0d08fb..33d2bcbd23f 100644
--- a/app/controllers/roles_controller.rb
+++ b/app/controllers/roles_controller.rb
@@ -65,7 +65,7 @@ class RolesController < ApplicationController
else
@roles = roles_scope
- render action: "new"
+ render action: :new, status: :unprocessable_entity
end
end
@@ -77,7 +77,7 @@ class RolesController < ApplicationController
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to action: "index"
else
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
@@ -111,7 +111,7 @@ class RolesController < ApplicationController
else
@calls = calls
@permissions = visible_permissions
- render action: "report"
+ render action: "report", status: :unprocessable_entity
end
end
diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb
index fa15c4ef341..cd097715a84 100644
--- a/app/controllers/statuses_controller.rb
+++ b/app/controllers/statuses_controller.rb
@@ -54,7 +54,7 @@ class StatusesController < ApplicationController
flash[:notice] = I18n.t(:notice_successful_create)
redirect_to action: "index"
else
- render action: "new"
+ render action: :new, status: :unprocessable_entity
end
end
@@ -65,7 +65,7 @@ class StatusesController < ApplicationController
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to action: "index"
else
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb
index 31c8ad25cd7..caa766f881e 100644
--- a/app/controllers/types_controller.rb
+++ b/app/controllers/types_controller.rb
@@ -73,7 +73,7 @@ class TypesController < ApplicationController
call.on_failure do |result|
flash[:error] = result.errors.full_messages.join("\n")
load_projects_and_types
- render action: "new"
+ render action: :new, status: :unprocessable_entity
end
end
end
@@ -99,7 +99,7 @@ class TypesController < ApplicationController
redirect_to types_path
else
flash.now[:error] = I18n.t(:error_type_could_not_be_saved)
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
@@ -144,7 +144,7 @@ class TypesController < ApplicationController
@projects = Project.all
@type = type
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
def show_local_breadcrumb
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 006335e2d3c..30fced4ded5 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -93,7 +93,7 @@ class UsersController < ApplicationController
flash[:notice] = I18n.t(:notice_successful_create)
redirect_to(params[:continue] ? new_user_path : helpers.allowed_management_user_profile_path(@user))
else
- render action: "new"
+ render action: :new, status: :unprocessable_entity
end
end
diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb
index 87d25fe223d..15d5ea200f5 100644
--- a/app/controllers/versions_controller.rb
+++ b/app/controllers/versions_controller.rb
@@ -159,7 +159,7 @@ class VersionsController < ApplicationController
flash[:notice] = t(success_message)
redirect_back_or_version_settings
else
- render action: failure_action
+ render action: failure_action, status: :unprocessable_entity
end
end
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 95538c1a28c..a61732e9fdb 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -144,7 +144,7 @@ class WikiController < ApplicationController
flash[:notice] = I18n.t(:notice_successful_create)
redirect_to_show
else
- render action: "new"
+ render action: :new, status: :unprocessable_entity
end
end
@@ -170,12 +170,12 @@ class WikiController < ApplicationController
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to_show
else
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
rescue ActiveRecord::StaleObjectError
# Optimistic locking exception
flash.now[:error] = I18n.t(:notice_locking_conflict)
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
# rename a page
diff --git a/app/controllers/wiki_menu_items_controller.rb b/app/controllers/wiki_menu_items_controller.rb
index 1a035cc1da6..94ac13da4a1 100644
--- a/app/controllers/wiki_menu_items_controller.rb
+++ b/app/controllers/wiki_menu_items_controller.rb
@@ -105,7 +105,7 @@ class WikiMenuItemsController < ApplicationController
else
respond_to do |format|
format.html do
- render action: "edit", id: @page
+ render action: :edit, id: @page, status: :unprocessable_entity
end
end
end
diff --git a/app/controllers/work_packages/bulk_controller.rb b/app/controllers/work_packages/bulk_controller.rb
index 8030b41f7ce..f2938d63a95 100644
--- a/app/controllers/work_packages/bulk_controller.rb
+++ b/app/controllers/work_packages/bulk_controller.rb
@@ -52,7 +52,7 @@ class WorkPackages::BulkController < ApplicationController
else
flash[:error] = bulk_error_message(@work_packages, @call)
setup_edit
- render action: :edit
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/modules/auth_saml/app/controllers/saml/providers_controller.rb b/modules/auth_saml/app/controllers/saml/providers_controller.rb
index ab8a43a11fe..b1da54f8a66 100644
--- a/modules/auth_saml/app/controllers/saml/providers_controller.rb
+++ b/modules/auth_saml/app/controllers/saml/providers_controller.rb
@@ -63,7 +63,7 @@ module Saml
@edit_state = :metadata
flash.now[:error] = call.message
- render action: :edit
+ render action: :edit, status: :unprocessable_entity
end
end
@@ -78,7 +78,7 @@ module Saml
successful_save_response
else
flash.now[:error] = call.message
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
end
diff --git a/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb b/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb
index c80963a7d60..32d47c39c97 100644
--- a/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb
+++ b/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb
@@ -149,7 +149,7 @@ module Bim
flash[:notice] = t("ifc_models.flash_messages.upload_successful")
redirect_to action: :index
else
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
end
@@ -168,7 +168,7 @@ module Bim
flash[:notice] = t(:notice_successful_update)
redirect_to action: :index
else
- render action: :edit
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/modules/boards/app/controllers/boards/boards_controller.rb b/modules/boards/app/controllers/boards/boards_controller.rb
index b9a271d5d53..a39108f49f6 100644
--- a/modules/boards/app/controllers/boards/boards_controller.rb
+++ b/modules/boards/app/controllers/boards/boards_controller.rb
@@ -40,7 +40,7 @@ module ::Boards
flash[:notice] = I18n.t(:notice_successful_create)
redirect_to project_work_package_board_path(@project, @board_grid)
else
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
end
diff --git a/modules/budgets/app/controllers/budgets_controller.rb b/modules/budgets/app/controllers/budgets_controller.rb
index e9b626e2792..7f01d8adf16 100644
--- a/modules/budgets/app/controllers/budgets_controller.rb
+++ b/modules/budgets/app/controllers/budgets_controller.rb
@@ -111,7 +111,7 @@ class BudgetsController < ApplicationController
flash[:notice] = t(:notice_successful_create)
redirect_to(params[:continue] ? { action: "new" } : { action: "show", id: @budget })
else
- render action: "new", layout: !request.xhr?
+ render action: "new", status: :unprocessable_entity, layout: !request.xhr?
end
end
@@ -129,7 +129,7 @@ class BudgetsController < ApplicationController
redirect_to(@budget)
else
@budget = call.result
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
rescue ActiveRecord::StaleObjectError
# Optimistic locking exception
diff --git a/modules/calendar/app/controllers/calendar/calendars_controller.rb b/modules/calendar/app/controllers/calendar/calendars_controller.rb
index 5b8280d60d1..373cb2bec67 100644
--- a/modules/calendar/app/controllers/calendar/calendars_controller.rb
+++ b/modules/calendar/app/controllers/calendar/calendars_controller.rb
@@ -61,7 +61,7 @@ module ::Calendar
flash[:notice] = I18n.t(:notice_successful_create)
redirect_to project_calendar_path(@project, @view.query)
else
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
end
diff --git a/modules/costs/app/controllers/cost_types_controller.rb b/modules/costs/app/controllers/cost_types_controller.rb
index 3706912993e..07db5d36403 100644
--- a/modules/costs/app/controllers/cost_types_controller.rb
+++ b/modules/costs/app/controllers/cost_types_controller.rb
@@ -62,7 +62,7 @@ class CostTypesController < ApplicationController
end
def edit
- render action: "edit", layout: !request.xhr?
+ render action: :edit, layout: !request.xhr?
end
def update
@@ -72,7 +72,7 @@ class CostTypesController < ApplicationController
flash[:notice] = t(:notice_successful_update)
redirect_back_or_default(action: "index")
else
- render action: "edit", layout: !request.xhr?
+ render action: :edit, status: :unprocessable_entity, layout: !request.xhr?
end
rescue ActiveRecord::StaleObjectError
# Optimistic locking exception
@@ -84,7 +84,7 @@ class CostTypesController < ApplicationController
@cost_type.rates.build(valid_from: Date.today) if @cost_type.rates.empty?
- render action: "edit", layout: !request.xhr?
+ render action: :edit, layout: !request.xhr?
end
def create
@@ -95,7 +95,7 @@ class CostTypesController < ApplicationController
redirect_back_or_default(action: "index")
else
@cost_type.rates.build(valid_from: Date.today) if @cost_type.rates.empty?
- render action: "edit", layout: !request.xhr?
+ render action: :edit, status: :unprocessable_entity, layout: !request.xhr?
end
rescue ActiveRecord::StaleObjectError
# Optimistic locking exception
diff --git a/modules/costs/app/controllers/costlog_controller.rb b/modules/costs/app/controllers/costlog_controller.rb
index d0cf40f823b..386ff243689 100644
--- a/modules/costs/app/controllers/costlog_controller.rb
+++ b/modules/costs/app/controllers/costlog_controller.rb
@@ -57,7 +57,7 @@ class CostlogController < ApplicationController
flash[:notice] = t(:notice_cost_logged_successfully)
redirect_back_or_default work_package_path(@cost_entry.work_package)
else
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/modules/costs/app/controllers/hourly_rates_controller.rb b/modules/costs/app/controllers/hourly_rates_controller.rb
index c9077d4ad5c..768bf891d99 100644
--- a/modules/costs/app/controllers/hourly_rates_controller.rb
+++ b/modules/costs/app/controllers/hourly_rates_controller.rb
@@ -78,7 +78,7 @@ class HourlyRatesController < ApplicationController
@rates << @user.rates.build(valid_from: Date.today, project: @project) if @rates.empty?
end
- render action: "edit", layout: !request.xhr?
+ render action: :edit, layout: !request.xhr?
end
current_menu_item :edit do
@@ -123,7 +123,7 @@ class HourlyRatesController < ApplicationController
.sort { |a, b| b.valid_from || Date.today <=> a.valid_from || Date.today }
@rates << @user.rates.build(valid_from: Date.today, project: @project) if @rates.empty?
end
- render action: "edit", layout: !request.xhr?
+ render action: :edit, layout: !request.xhr?
end
end
diff --git a/modules/costs/spec/controllers/costlog_controller_spec.rb b/modules/costs/spec/controllers/costlog_controller_spec.rb
index bdd5e0b97d4..b3f78082d94 100644
--- a/modules/costs/spec/controllers/costlog_controller_spec.rb
+++ b/modules/costs/spec/controllers/costlog_controller_spec.rb
@@ -303,7 +303,7 @@ RSpec.describe CostlogController do
post :create, params:
end
- it { expect(response).to be_successful }
+ it { expect(response).to have_http_status(:unprocessable_entity) }
it_behaves_like "assigns"
it { expect(flash[:notice]).to be_nil }
diff --git a/modules/documents/app/controllers/documents_controller.rb b/modules/documents/app/controllers/documents_controller.rb
index 7222cb7ea03..db5b2133fa8 100644
--- a/modules/documents/app/controllers/documents_controller.rb
+++ b/modules/documents/app/controllers/documents_controller.rb
@@ -71,7 +71,7 @@ class DocumentsController < ApplicationController
redirect_to project_documents_path(@project)
else
@document = call.result
- render action: "new"
+ render action: :new, status: :unprocessable_entity
end
end
@@ -89,7 +89,7 @@ class DocumentsController < ApplicationController
redirect_to action: "show", id: @document
else
@document = call.result
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/modules/ldap_groups/app/controllers/ldap_groups/synchronized_filters_controller.rb b/modules/ldap_groups/app/controllers/ldap_groups/synchronized_filters_controller.rb
index 1226a9cc37f..2b6882dac60 100644
--- a/modules/ldap_groups/app/controllers/ldap_groups/synchronized_filters_controller.rb
+++ b/modules/ldap_groups/app/controllers/ldap_groups/synchronized_filters_controller.rb
@@ -24,7 +24,7 @@ module LdapGroups
flash[:notice] = I18n.t(:notice_successful_create)
redirect_to ldap_groups_synchronized_groups_path
else
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
rescue ActionController::ParameterMissing
render_400
@@ -35,7 +35,7 @@ module LdapGroups
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to action: :show
else
- render action: :edit
+ render action: :edit, status: :unprocessable_entity
end
rescue ActionController::ParameterMissing
render_400
diff --git a/modules/ldap_groups/app/controllers/ldap_groups/synchronized_groups_controller.rb b/modules/ldap_groups/app/controllers/ldap_groups/synchronized_groups_controller.rb
index 11276c1a3e1..ec7dd07cb07 100644
--- a/modules/ldap_groups/app/controllers/ldap_groups/synchronized_groups_controller.rb
+++ b/modules/ldap_groups/app/controllers/ldap_groups/synchronized_groups_controller.rb
@@ -28,7 +28,7 @@ module LdapGroups
flash[:notice] = I18n.t(:notice_successful_create)
redirect_to action: :index
else
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
rescue ActionController::ParameterMissing
render_400
diff --git a/modules/ldap_groups/spec/controllers/synchronized_groups_controller_spec.rb b/modules/ldap_groups/spec/controllers/synchronized_groups_controller_spec.rb
index a600b3218ae..0ed0521fe7b 100644
--- a/modules/ldap_groups/spec/controllers/synchronized_groups_controller_spec.rb
+++ b/modules/ldap_groups/spec/controllers/synchronized_groups_controller_spec.rb
@@ -135,7 +135,7 @@ RSpec.describe LdapGroups::SynchronizedGroupsController, with_ee: %i[ldap_groups
context "and saving fails" do
it "renders new page" do
- expect(response).to have_http_status(:ok)
+ expect(response).to have_http_status(:unprocessable_entity)
expect(response).to render_template :new
end
end
diff --git a/modules/meeting/app/controllers/meeting_contents_controller.rb b/modules/meeting/app/controllers/meeting_contents_controller.rb
index 43335a4ebb3..a4c29b88831 100644
--- a/modules/meeting/app/controllers/meeting_contents_controller.rb
+++ b/modules/meeting/app/controllers/meeting_contents_controller.rb
@@ -69,7 +69,7 @@ class MeetingContentsController < ApplicationController
else
flash.now[:error] = call.message
params[:tab] ||= "minutes" if @meeting.agenda.present? && @meeting.agenda.locked?
- render "meetings/show"
+ render "meetings/show", status: :unprocessable_entity
end
end
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index 5fb9334eb5c..4cdcb3a5832 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -122,7 +122,7 @@ class MeetingsController < ApplicationController
.call(save: false)
@meeting = call.result
- render action: "new", project_id: @project, locals: { copy_from: }
+ render action: :new, status: :unprocessable_entity, project_id: @project, locals: { copy_from: }
end
def destroy
@@ -167,7 +167,7 @@ class MeetingsController < ApplicationController
redirect_to action: "show", id: @meeting
else
@meeting = call.result
- render action: "edit"
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/modules/meeting/spec/controllers/meetings_controller_spec.rb b/modules/meeting/spec/controllers/meetings_controller_spec.rb
index 3987e81a9f8..ede030d0bc6 100644
--- a/modules/meeting/spec/controllers/meetings_controller_spec.rb
+++ b/modules/meeting/spec/controllers/meetings_controller_spec.rb
@@ -164,7 +164,7 @@ RSpec.describe MeetingsController do
end
it "renders an error" do
- expect(response).to have_http_status :ok
+ expect(response).to have_http_status :unprocessable_entity
expect(response).to render_template :new
expect(response.body)
.to have_text("Date #{I18n.t('activerecord.errors.messages.not_an_iso_date')}")
@@ -177,7 +177,7 @@ RSpec.describe MeetingsController do
end
it "renders an error" do
- expect(response).to have_http_status :ok
+ expect(response).to have_http_status :unprocessable_entity
expect(response).to render_template :new
expect(response.body)
.to have_text("Start time #{I18n.t('activerecord.errors.messages.invalid_time_format')}")
@@ -189,7 +189,7 @@ RSpec.describe MeetingsController do
let(:project) { nil }
it "renders an error" do
- expect(response).to have_http_status :ok
+ expect(response).to have_http_status :unprocessable_entity
expect(response).to render_template :new
expect(response.body)
.to have_text("Project #{I18n.t('activerecord.errors.messages.blank')}")
@@ -201,7 +201,7 @@ RSpec.describe MeetingsController do
let(:project) { nil }
it "renders an error" do
- expect(response).to have_http_status :ok
+ expect(response).to have_http_status :unprocessable_entity
expect(response).to render_template :new
expect(response.body)
.to have_text("Project #{I18n.t('activerecord.errors.messages.blank')}")
diff --git a/modules/openid_connect/app/controllers/openid_connect/providers_controller.rb b/modules/openid_connect/app/controllers/openid_connect/providers_controller.rb
index ac436d6418f..1d7c6a3e003 100644
--- a/modules/openid_connect/app/controllers/openid_connect/providers_controller.rb
+++ b/modules/openid_connect/app/controllers/openid_connect/providers_controller.rb
@@ -24,7 +24,7 @@ module OpenIDConnect
flash[:notice] = I18n.t(:notice_successful_create)
redirect_to action: :index
else
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
end
@@ -38,7 +38,7 @@ module OpenIDConnect
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to action: :index
else
- render action: :edit
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
index a2e08ebef42..6b04456e264 100644
--- a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
+++ b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
@@ -30,7 +30,7 @@ module ::TeamPlanner
flash[:notice] = I18n.t(:notice_successful_create)
redirect_to project_team_planner_path(@project, @view.query)
else
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
end
diff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb
index 91918c4199e..a48d1f42934 100644
--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb
+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb
@@ -54,7 +54,7 @@ module ::TwoFactorAuthentication
end
else
Rails.logger.warn { "User ##{target_user.id} forced to register failed for #{@device_type}." }
- render "two_factor_authentication/two_factor_devices/new"
+ render "two_factor_authentication/two_factor_devices/new", status: :unprocessable_entity
end
end
diff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb
index 37210741f3e..8577a42b784 100644
--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb
+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb
@@ -67,7 +67,7 @@ module ::TwoFactorAuthentication
end
else
Rails.logger.warn { "User ##{current_user.id} failed to register a device #{@device_type}." }
- render "two_factor_authentication/two_factor_devices/new"
+ render "two_factor_authentication/two_factor_devices/new", status: :unprocessable_entity
end
end
diff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/users/two_factor_devices_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/users/two_factor_devices_controller.rb
index 7d438e05e25..3f04b5085c2 100644
--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/users/two_factor_devices_controller.rb
+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/users/two_factor_devices_controller.rb
@@ -34,7 +34,7 @@ module ::TwoFactorAuthentication
redirect_to index_path
else
Rails.logger.info "Admin ##{current_user.id} failed to register a new device #{@device_type} for #{@user.id}."
- render "two_factor_authentication/two_factor_devices/new"
+ render "two_factor_authentication/two_factor_devices/new", status: :unprocessable_entity
end
end
diff --git a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller_spec.rb b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller_spec.rb
index 7822efd1f35..0cf89ac791e 100644
--- a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller_spec.rb
+++ b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller_spec.rb
@@ -98,7 +98,7 @@ RSpec.describe TwoFactorAuthentication::ForcedRegistration::TwoFactorDevicesCont
let(:params) { { identifier: "foo" } }
it "renders action new" do
- expect(response).to be_successful
+ expect(response).to have_http_status :unprocessable_entity
expect(response).to render_template "new"
expect(assigns[:device]).to be_invalid
end
diff --git a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb
index 08560809f19..24b4d4200fc 100644
--- a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb
+++ b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb
@@ -92,7 +92,7 @@ RSpec.describe TwoFactorAuthentication::My::TwoFactorDevicesController do
let(:params) { { identifier: "foo" } }
it "renders action new" do
- expect(response).to be_successful
+ expect(response).to have_http_status :unprocessable_entity
expect(response).to render_template "new"
expect(assigns[:device]).to be_invalid
end
diff --git a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb
index a843d38dc37..ee7f4cdee9e 100644
--- a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb
+++ b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb
@@ -108,7 +108,7 @@ RSpec.describe TwoFactorAuthentication::Users::TwoFactorDevicesController do
it "renders action new" do
post :register, params: { id: user.id, key: :sms, device: params }
- expect(response).to be_successful
+ expect(response).to have_http_status :unprocessable_entity
expect(response).to render_template "new"
expect(assigns[:device]).to be_invalid
end
diff --git a/modules/webhooks/app/controllers/webhooks/outgoing/admin_controller.rb b/modules/webhooks/app/controllers/webhooks/outgoing/admin_controller.rb
index b6dfbde6517..688c61eae9a 100644
--- a/modules/webhooks/app/controllers/webhooks/outgoing/admin_controller.rb
+++ b/modules/webhooks/app/controllers/webhooks/outgoing/admin_controller.rb
@@ -28,7 +28,7 @@ module Webhooks
redirect_to action: :index
else
@webhook = action.result
- render action: :new
+ render action: :new, status: :unprocessable_entity
end
end
@@ -40,7 +40,7 @@ module Webhooks
redirect_to action: :index
else
@webhook = action.result
- render action: :edit
+ render action: :edit, status: :unprocessable_entity
end
end
diff --git a/spec/controllers/attribute_help_texts_controller_spec.rb b/spec/controllers/attribute_help_texts_controller_spec.rb
index 061db98398f..cba0cef13b1 100644
--- a/spec/controllers/attribute_help_texts_controller_spec.rb
+++ b/spec/controllers/attribute_help_texts_controller_spec.rb
@@ -98,7 +98,7 @@ RSpec.describe AttributeHelpTextsController do
end
it "fails to update the announcement" do
- expect(response).to be_successful
+ expect(response).to have_http_status(:unprocessable_entity)
expect(response).to render_template "edit"
end
end
diff --git a/spec/controllers/news_controller_spec.rb b/spec/controllers/news_controller_spec.rb
index d4cc219016a..ba594072e1e 100644
--- a/spec/controllers/news_controller_spec.rb
+++ b/spec/controllers/news_controller_spec.rb
@@ -128,7 +128,7 @@ RSpec.describe NewsController do
}
}
- expect(response).to be_successful
+ expect(response).to have_http_status(:unprocessable_entity)
expect(response).to render_template "new"
expect(assigns(:news)).not_to be_nil
expect(assigns(:news)).to be_new_record
diff --git a/spec/controllers/placeholder_users_controller_spec.rb b/spec/controllers/placeholder_users_controller_spec.rb
index 6ef8a294ec1..adfd9a2e9af 100644
--- a/spec/controllers/placeholder_users_controller_spec.rb
+++ b/spec/controllers/placeholder_users_controller_spec.rb
@@ -103,7 +103,7 @@ RSpec.describe PlaceholderUsersController do
context "without ee" do
it "returns with an error" do
expect { post :create, params: }.not_to change { PlaceholderUser.count }
- expect(response).to be_successful
+ expect(response).to have_http_status(:unprocessable_entity)
expect(assigns(:placeholder_user).errors.details[:base])
.to eq([error: :error_enterprise_only, action: "Placeholder Users"])
diff --git a/spec/controllers/projects/identifier_controller_spec.rb b/spec/controllers/projects/identifier_controller_spec.rb
index 72203ecc119..db259be2f06 100644
--- a/spec/controllers/projects/identifier_controller_spec.rb
+++ b/spec/controllers/projects/identifier_controller_spec.rb
@@ -48,7 +48,7 @@ RSpec.describe Projects::IdentifierController do
previous_identifier = project.identifier
put :update, params: { project_id: project.id, project: { identifier: "bad identifier" } }
- expect(response).to have_http_status(:ok)
+ expect(response).to have_http_status(:unprocessable_entity)
expect(response.body).to include("Identifier is invalid")
expect(project.reload.identifier).to eq(previous_identifier)
end
diff --git a/spec/controllers/roles_controller_spec.rb b/spec/controllers/roles_controller_spec.rb
index 23313eb6c27..ab4cfe89ddb 100644
--- a/spec/controllers/roles_controller_spec.rb
+++ b/spec/controllers/roles_controller_spec.rb
@@ -123,24 +123,11 @@ RSpec.describe RolesController do
context "failure" do
let(:service_call) { ServiceResult.failure(result: new_role) }
- it "returns a 200 OK" do
- expect(response)
- .to have_http_status(:ok)
- end
-
- it "renders the new template" do
- expect(response)
- .to render_template("roles/new")
- end
-
- it "has the service call assigned" do
- expect(assigns[:call])
- .to eql service_call
- end
-
- it "has the role assigned" do
- expect(assigns[:role])
- .to eql new_role
+ it "renders the new form again", :aggregate_failures do
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(response).to render_template("roles/new")
+ expect(assigns[:call]).to eql service_call
+ expect(assigns[:role]).to eql new_role
end
end
end
@@ -206,24 +193,11 @@ RSpec.describe RolesController do
context "failure" do
let(:service_call) { ServiceResult.failure(result: role) }
- it "returns a 200 OK" do
- expect(response)
- .to have_http_status(:ok)
- end
-
- it "renders the edit template" do
- expect(response)
- .to render_template("roles/edit")
- end
-
- it "has the service call assigned" do
- expect(assigns[:call])
- .to eql service_call
- end
-
- it "has the role assigned" do
- expect(assigns[:role])
- .to eql role
+ it "renders edit again", :aggregate_failures do
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(response).to render_template("roles/edit")
+ expect(assigns[:call]).to eql service_call
+ expect(assigns[:role]).to eql role
end
end
end
@@ -349,24 +323,11 @@ RSpec.describe RolesController do
context "failure" do
let(:service_call2) { ServiceResult.failure(result: role2) }
- it "returns a 200 OK" do
- expect(response)
- .to have_http_status(:ok)
- end
-
- it "renders the report template" do
- expect(response)
- .to render_template("roles/report")
- end
-
- it "has the service call assigned" do
- expect(assigns[:calls])
- .to contain_exactly(service_call0, service_call1, service_call2, service_call3)
- end
-
- it "has the roles assigned" do
- expect(assigns[:roles])
- .to match_array roles
+ it "renders the report again" do
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(response).to render_template("roles/report")
+ expect(assigns[:calls]).to contain_exactly(service_call0, service_call1, service_call2, service_call3)
+ expect(assigns[:roles]).to match_array roles
end
end
end
diff --git a/spec/controllers/types_controller_spec.rb b/spec/controllers/types_controller_spec.rb
index 02320fe53c0..5130db3b52b 100644
--- a/spec/controllers/types_controller_spec.rb
+++ b/spec/controllers/types_controller_spec.rb
@@ -161,7 +161,7 @@ RSpec.describe TypesController do
post :create, params:
end
- it { expect(response).to have_http_status(:ok) }
+ it { expect(response).to have_http_status(:unprocessable_entity) }
it "shows an error message" do
expect(response.body).to have_content("Name can't be blank")
@@ -214,7 +214,7 @@ RSpec.describe TypesController do
get "edit", params: { id: type.id, tab: :settings }
end
- it { expect(response).to be_successful }
+ it { expect(response).to have_http_status(:unprocessable_entity) }
it { expect(response).to render_template "edit" }
it { expect(response).to render_template "types/form/_settings" }
it { expect(response.body).to have_css "input[@name='type[name]'][@value='My type']" }
@@ -233,7 +233,7 @@ RSpec.describe TypesController do
get "edit", params: { id: type.id, tab: :projects }
end
- it { expect(response).to be_successful }
+ it { expect(response).to have_http_status(:unprocessable_entity) }
it { expect(response).to render_template "edit" }
it { expect(response).to render_template "types/form/_projects" }
diff --git a/spec/controllers/versions_controller_spec.rb b/spec/controllers/versions_controller_spec.rb
index 597092fb749..086eca8a86a 100644
--- a/spec/controllers/versions_controller_spec.rb
+++ b/spec/controllers/versions_controller_spec.rb
@@ -340,7 +340,7 @@ RSpec.describe VersionsController do
}
end
- it { expect(response).to be_successful }
+ it { expect(response).to have_http_status(:unprocessable_entity) }
it { expect(response).to render_template("edit") }
it { expect(assigns(:version).errors.symbols_for(:name)).to contain_exactly(:blank) }
end
diff --git a/spec/requests/statuses_spec.rb b/spec/requests/statuses_spec.rb
index d74758cf330..62482dabeaa 100644
--- a/spec/requests/statuses_spec.rb
+++ b/spec/requests/statuses_spec.rb
@@ -47,7 +47,7 @@ RSpec.describe "Statuses", :skip_csrf, type: :rails_request do
it "displays an error" do
post statuses_path, params: { status: { name: "New status", default_done_ratio: "" } }
- expect(response).to have_http_status(:success)
+ expect(response).to have_http_status(:unprocessable_entity)
expect(response).to render_template("new")
expect(response.body).to include("% Complete must be between 0 and 100.")
end