From a0c0520502a53e67dc815c2c1e319efc46492945 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Mon, 29 Nov 2021 13:47:45 +0100 Subject: [PATCH] avoid redirection to a deleted user --- app/controllers/manager/users_controller.rb | 5 +++-- spec/controllers/manager/users_controller_spec.rb | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/manager/users_controller.rb b/app/controllers/manager/users_controller.rb index 7b3a376fe..934b37683 100644 --- a/app/controllers/manager/users_controller.rb +++ b/app/controllers/manager/users_controller.rb @@ -13,13 +13,14 @@ module Manager else flash[:error] = user.errors.full_messages.to_sentence end + + redirect_to edit_manager_user_path(user) else targeted_user.merge(user) flash[:notice] = "Le compte « #{targeted_email} » a absorbé le compte « #{user.email} »." + redirect_to edit_manager_user_path(targeted_user) end - - redirect_to edit_manager_user_path(user) end def resend_confirmation_instructions diff --git a/spec/controllers/manager/users_controller_spec.rb b/spec/controllers/manager/users_controller_spec.rb index 602ad70eb..14bebcc1b 100644 --- a/spec/controllers/manager/users_controller_spec.rb +++ b/spec/controllers/manager/users_controller_spec.rb @@ -29,6 +29,7 @@ describe Manager::UsersController, type: :controller do subject expect(User.find_by(id: user.id).email).to eq(nouvel_email) + expect(response).to redirect_to(edit_manager_user_path(user)) end end @@ -54,6 +55,7 @@ describe Manager::UsersController, type: :controller do subject expect(flash[:notice]).to match("Le compte « email.existant@domaine.fr » a absorbé le compte « ancien.email@domaine.fr ».") + expect(response).to redirect_to(edit_manager_user_path(targeted_user)) end end end