avoid redirection to a deleted user

This commit is contained in:
simon lehericey 2021-11-29 13:47:45 +01:00
parent 8e2122cb62
commit a0c0520502
2 changed files with 5 additions and 2 deletions

View file

@ -13,13 +13,14 @@ module Manager
else else
flash[:error] = user.errors.full_messages.to_sentence flash[:error] = user.errors.full_messages.to_sentence
end end
redirect_to edit_manager_user_path(user)
else else
targeted_user.merge(user) targeted_user.merge(user)
flash[:notice] = "Le compte « #{targeted_email} » a absorbé le compte « #{user.email} »." flash[:notice] = "Le compte « #{targeted_email} » a absorbé le compte « #{user.email} »."
redirect_to edit_manager_user_path(targeted_user)
end end
redirect_to edit_manager_user_path(user)
end end
def resend_confirmation_instructions def resend_confirmation_instructions

View file

@ -29,6 +29,7 @@ describe Manager::UsersController, type: :controller do
subject subject
expect(User.find_by(id: user.id).email).to eq(nouvel_email) expect(User.find_by(id: user.id).email).to eq(nouvel_email)
expect(response).to redirect_to(edit_manager_user_path(user))
end end
end end
@ -54,6 +55,7 @@ describe Manager::UsersController, type: :controller do
subject subject
expect(flash[:notice]).to match("Le compte « email.existant@domaine.fr » a absorbé le compte « ancien.email@domaine.fr ».") 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 end
end end