refactor(user): rename delete_and_keep_track_dossiers

This commit is contained in:
simon lehericey 2022-11-14 16:45:32 +01:00
parent b70cbf0ba1
commit fcfe09f05a
5 changed files with 8 additions and 8 deletions

View file

@ -49,7 +49,7 @@ module Manager
if !user.can_be_deleted?
fail "Impossible de supprimer cet utilisateur. Il a des dossiers en instruction ou il est administrateur."
end
user.delete_and_keep_track_dossiers(current_super_admin)
user.delete_and_keep_track_dossiers_also_delete_user(current_super_admin)
logger.info("L'utilisateur #{user.id} est supprimé par #{current_super_admin.id}")
flash[:notice] = "L'utilisateur #{user.id} est supprimé"

View file

@ -186,7 +186,7 @@ class User < ApplicationRecord
!administrateur? && !instructeur? && !expert?
end
def delete_and_keep_track_dossiers(administration)
def delete_and_keep_track_dossiers_also_delete_user(administration)
if !can_be_deleted?
raise "Cannot delete this user because they are also instructeur, expert or administrateur"
end

View file

@ -15,7 +15,7 @@ namespace :support do
user = User.find_by!(email: user_email)
administration = Administration.find_by!(email: administration_email)
user.delete_and_keep_track_dossiers(administration)
user.delete_and_keep_track_dossiers_also_delete_user(administration)
user.destroy
end

View file

@ -91,7 +91,7 @@ RSpec.describe NotificationMailer, type: :mailer do
context 'when dossier user is deleted' do
before do
dossier.user.delete_and_keep_track_dossiers(administrateur)
dossier.user.delete_and_keep_track_dossiers_also_delete_user(administrateur)
dossier.reload
end

View file

@ -298,7 +298,7 @@ describe User, type: :model do
end
end
describe '#delete_and_keep_track_dossiers' do
describe '#delete_and_keep_track_dossiers_also_delete_user' do
let(:super_admin) { create(:super_admin) }
let(:user) { create(:user) }
@ -308,7 +308,7 @@ describe User, type: :model do
context 'without a discarded dossier' do
it "keep track of dossiers and delete user" do
user.delete_and_keep_track_dossiers(super_admin)
user.delete_and_keep_track_dossiers_also_delete_user(super_admin)
expect(DeletedDossier.find_by(dossier_id: dossier_en_construction)).to be_present
expect(DeletedDossier.find_by(dossier_id: dossier_brouillon)).to be_nil
@ -322,7 +322,7 @@ describe User, type: :model do
it "keep track of dossiers and delete user" do
dossier_to_delete.hide_and_keep_track!(user, :user_request)
user.delete_and_keep_track_dossiers(super_admin)
user.delete_and_keep_track_dossiers_also_delete_user(super_admin)
expect(DeletedDossier.find_by(dossier_id: dossier_en_construction)).to be_present
expect(DeletedDossier.find_by(dossier_id: dossier_brouillon)).to be_nil
@ -337,7 +337,7 @@ describe User, type: :model do
let!(:dossier_termine) { create(:dossier, :accepte, user: user) }
it "keep track of dossiers and delete user" do
user.delete_and_keep_track_dossiers(super_admin)
user.delete_and_keep_track_dossiers_also_delete_user(super_admin)
expect(dossier_en_instruction.reload).to be_present
expect(dossier_en_instruction.user).to be_nil