merge destroys the old role and account

This commit is contained in:
simon lehericey 2021-10-28 12:09:30 +02:00
parent 1401d163ba
commit f2ccb39912
2 changed files with 7 additions and 0 deletions

View file

@ -208,6 +208,8 @@ class User < ApplicationRecord
targeted_role.merge(old_role)
end
end
old_user.destroy
end
private

View file

@ -459,6 +459,11 @@ describe User, type: :model do
expect(targeted_administrateur).to receive(:merge).with(administrateur)
subject
expect { instructeur.reload }.to raise_error(ActiveRecord::RecordNotFound)
expect { expert.reload }.to raise_error(ActiveRecord::RecordNotFound)
expect { administrateur.reload }.to raise_error(ActiveRecord::RecordNotFound)
expect { old_user.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end