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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix renders after redirect
Oliver Günther47d62ba9df89
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rbindex 3d7f75cceeb..d909312f0d8 100644--- a/app/controllers/account_controller.rb+++ b/app/controllers/account_controller.rb@@ -397,12 +397,15 @@ class AccountController < ApplicationControllershow_user_name: true)elseflash_and_log_invalid_credentials+ render status: :unprocessable_entityendelsif user and user.invited?invited_account_not_activated(user)+ render status: :unprocessable_entityelse# incorrect passwordflash_and_log_invalid_credentials+ render status: :unprocessable_entityendelsif user.new_record?onthefly_creation_failed(user, login: user.login, ldap_auth_source_id: user.ldap_auth_source_id)diff --git a/app/controllers/concerns/accounts/registration.rb b/app/controllers/concerns/accounts/registration.rbindex ca11d39edfc..655b185151f 100644--- a/app/controllers/concerns/accounts/registration.rb+++ b/app/controllers/concerns/accounts/registration.rb@@ -118,7 +118,7 @@ module Accounts::Registrationdef onthefly_creation_failed(user, auth_source_options = {})@user = usersession[:auth_source_registration] = auth_source_options unless auth_source_options.empty?- render action: "register"+ render action: "register", status: :unprocessable_entityenddef self_registration_disableddiff --git a/spec/controllers/account_controller_spec.rb b/spec/controllers/account_controller_spec.rbindex 4753200c817..8cee30868d7 100644--- a/spec/controllers/account_controller_spec.rb+++ b/spec/controllers/account_controller_spec.rb@@ -134,7 +134,7 @@ RSpec.describe AccountController, :skip_2fa_stage dodescribe "wrong password" doit "redirects back to login" dopost :login, params: { username: "admin", password: "bad" }- expect(response).to be_successful+ expect(response).to have_http_status :unprocessable_entityexpect(response).to render_template "login"expect(flash[:error]).to include "Invalid user or password"enddiff --git a/spec/controllers/my_controller_spec.rb b/spec/controllers/my_controller_spec.rbindex e2421ec60af..c7c8f0324ae 100644--- a/spec/controllers/my_controller_spec.rb+++ b/spec/controllers/my_controller_spec.rb@@ -69,7 +69,7 @@ RSpec.describe MyController doendit "shows an error message" do- assert_response :success+ expect(response).to have_http_status :unprocessable_entityassert_template "password"expect(user.errors.attribute_names).to eq([:password_confirmation])expect(user.errors.map(&:message).flatten)@@ -90,7 +90,7 @@ RSpec.describe MyController doendit "shows an error message" do- assert_response :success+ expect(response).to have_http_status :unprocessable_entityassert_template "password"expect(flash[:error]).to eq("Wrong password")enddiff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rbindex 03e95140ee7..eacfa15a254 100644--- a/spec/controllers/users_controller_spec.rb+++ b/spec/controllers/users_controller_spec.rb@@ -642,7 +642,7 @@ RSpec.describe UsersController doendit "redirects to the edit page" do- expect(response).to render_template :edit+ expect(response).to redirect_to(action: :edit)endit "is assigned their new values" do@@ -689,12 +689,9 @@ RSpec.describe UsersController do}end- it "is success" do+ it "renders the edit template with errors", :aggregate_failures doexpect(response)- .to have_http_status(:ok)- end-- it "renders the edit template with errors" do+ .to have_http_status(:unprocessable_entity)expect(response).to have_rendered("edit")expect(assigns(:user).errors.first)diff --git a/spec/features/users/password_change_spec.rb b/spec/features/users/password_change_spec.rbindex e20bf315bb9..5207175054c 100644--- a/spec/features/users/password_change_spec.rb+++ b/spec/features/users/password_change_spec.rb@@ -98,12 +98,15 @@ RSpec.describe "random password generation", :js, :with_cuprite do# Logout and sign in with outdated passwordvisit signout_path+login_with user.login, password+ wait_for_network_idleexpect(page).to have_content "Invalid user or password"# Logout and sign in with new_passworwdvisit signout_pathlogin_with user.login, new_password+ wait_for_network_idlevisit my_account_pathexpect(page).to have_css(".account-menu-item.selected")