Merge pull request #9439 from demarches-simplifiees/fix_missing_procedure_in_expert_merge

instructeurs: corrige un merge de compte dans le cas de procédure supprimée
This commit is contained in:
LeSim 2023-08-31 13:20:46 +00:00 committed by GitHub
commit b378b24794
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -34,6 +34,7 @@ class Expert < ApplicationRecord
procedure_with_new, procedure_without_new = old_expert
.procedures
.with_discarded
.partition { |p| p.experts.exists?(id) }
ExpertsProcedure

View file

@ -38,6 +38,19 @@ RSpec.describe Expert, type: :model do
end
end
context 'when an old expert access a hidden procedure' do
let(:procedure) { create(:procedure, hidden_at: 1.month.ago) }
before do
procedure.experts << old_expert
subject
end
it 'transfers the access to the new expert' do
expect(procedure.reload.experts).to match_array(new_expert)
end
end
context 'when both expert access a procedure' do
let(:procedure) { create(:procedure) }