diff --git a/app/models/expert.rb b/app/models/expert.rb index d86b69194..3809a7e27 100644 --- a/app/models/expert.rb +++ b/app/models/expert.rb @@ -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 diff --git a/spec/models/expert_spec.rb b/spec/models/expert_spec.rb index 90c8f346b..8f187b5e1 100644 --- a/spec/models/expert_spec.rb +++ b/spec/models/expert_spec.rb @@ -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) }