merge move invite as well

This commit is contained in:
simon lehericey 2021-10-28 12:09:35 +02:00
parent f2ccb39912
commit 3328c9a132
2 changed files with 4 additions and 1 deletions

View file

@ -196,6 +196,7 @@ class User < ApplicationRecord
def merge(old_user)
old_user.dossiers.update_all(user_id: id)
old_user.invites.update_all(user_id: id)
[
[old_user.instructeur, instructeur],

View file

@ -424,13 +424,15 @@ describe User, type: :model do
subject { targeted_user.merge(old_user) }
context 'and the old account has a dossier' do
context 'and the old account has some stuff' do
let!(:dossier) { create(:dossier, user: old_user) }
let!(:invite) { create(:invite, user: old_user) }
it 'transfers the dossier' do
subject
expect(targeted_user.dossiers).to match([dossier])
expect(targeted_user.invites).to match([invite])
end
end