diff --git a/app/models/user.rb b/app/models/user.rb index cb4432cab..ef7f230aa 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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], diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9b78c1475..5dc6b9c47 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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