fix: a expert merge transfers hidden procedures

This commit is contained in:
simon lehericey 2023-08-31 14:26:29 +02:00
parent a84efbf70e
commit fdf51b5ea1
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) }