Merge pull request #6642 from betagouv/fix_merge_pb
Merge des comptes avec des fichiers cachés
This commit is contained in:
commit
a46dd59f3f
2 changed files with 3 additions and 2 deletions
|
@ -201,7 +201,7 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
def merge(old_user)
|
def merge(old_user)
|
||||||
transaction do
|
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.invites.update_all(user_id: id)
|
||||||
old_user.merge_logs.update_all(user_id: id)
|
old_user.merge_logs.update_all(user_id: id)
|
||||||
|
|
||||||
|
|
|
@ -426,13 +426,14 @@ describe User, type: :model do
|
||||||
|
|
||||||
context 'and the old account has some stuff' do
|
context 'and the old account has some stuff' do
|
||||||
let!(:dossier) { create(:dossier, user: old_user) }
|
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!(:invite) { create(:invite, user: old_user) }
|
||||||
let!(:merge_log) { MergeLog.create(user: old_user, from_user_id: 1, from_user_email: 'a') }
|
let!(:merge_log) { MergeLog.create(user: old_user, from_user_id: 1, from_user_email: 'a') }
|
||||||
|
|
||||||
it 'transfers the dossier' do
|
it 'transfers the dossier' do
|
||||||
subject
|
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.invites).to match([invite])
|
||||||
expect(targeted_user.merge_logs.first).to eq(merge_log)
|
expect(targeted_user.merge_logs.first).to eq(merge_log)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue