correctif(usager.fusion): leve une erreur quand on essaie de fusionner un compte sur lui même
This commit is contained in:
parent
654d38626b
commit
d09c47f5ce
2 changed files with 6 additions and 1 deletions
|
@ -214,6 +214,7 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
def merge(old_user)
|
||||
raise "Merging same user, no way" if old_user.id == self.id
|
||||
transaction do
|
||||
old_user.dossiers.update_all(user_id: id)
|
||||
old_user.invites.update_all(user_id: id)
|
||||
|
|
|
@ -423,7 +423,11 @@ describe User, type: :model do
|
|||
let(:targeted_user) { create(:user) }
|
||||
|
||||
subject { targeted_user.merge(old_user) }
|
||||
|
||||
context 'merge myself' do
|
||||
it 'fails' do
|
||||
expect { old_user.merge(old_user) }.to raise_error 'Merging same user, no way'
|
||||
end
|
||||
end
|
||||
context 'and the old account has some stuff' do
|
||||
let!(:dossier) { create(:dossier, user: old_user) }
|
||||
let!(:hidden_dossier) { create(:dossier, user: old_user, hidden_by_user_at: 1.hour.ago) }
|
||||
|
|
Loading…
Reference in a new issue