Render with status: :unprocessable_entity

This commit is contained in:
Oliver Günther
2024-08-28 12:43:09 +02:00
parent 7045e836b0
commit fa99c5bef6
55 changed files with 106 additions and 145 deletions
@@ -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
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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
@@ -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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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
@@ -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
@@ -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
@@ -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
+3 -3
View File
@@ -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
+2 -2
View File
@@ -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
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 }
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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')}")
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
+1 -1
View File
@@ -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
@@ -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"])
@@ -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
+15 -54
View File
@@ -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
+3 -3
View File
@@ -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" }
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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