Merge pull request #6642 from betagouv/fix_merge_pb

Merge des comptes avec des fichiers cachés
This commit is contained in:
Paul Chavard 2021-11-16 01:32:34 +03:00 committed by GitHub
commit a46dd59f3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -201,7 +201,7 @@ class User < ApplicationRecord
def merge(old_user)
transaction do
old_user.dossiers.update_all(user_id: id)
old_user.dossiers.with_discarded.update_all(user_id: id)
old_user.invites.update_all(user_id: id)
old_user.merge_logs.update_all(user_id: id)

View file

@ -426,13 +426,14 @@ describe User, type: :model do
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_at: Time.zone.now) }
let!(:invite) { create(:invite, user: old_user) }
let!(:merge_log) { MergeLog.create(user: old_user, from_user_id: 1, from_user_email: 'a') }
it 'transfers the dossier' do
subject
expect(targeted_user.dossiers).to match([dossier])
expect(targeted_user.dossiers.with_discarded).to match([dossier, hidden_dossier])
expect(targeted_user.invites).to match([invite])
expect(targeted_user.merge_logs.first).to eq(merge_log)