commit
1cfedb2bce
2 changed files with 7 additions and 1 deletions
|
@ -537,7 +537,7 @@ class Dossier < ApplicationRecord
|
||||||
def avis_for_expert(expert)
|
def avis_for_expert(expert)
|
||||||
Avis
|
Avis
|
||||||
.where(dossier_id: id, confidentiel: false)
|
.where(dossier_id: id, confidentiel: false)
|
||||||
.or(Avis.where(id: expert.avis))
|
.or(Avis.where(id: expert.avis, dossier_id: id))
|
||||||
.order(created_at: :asc)
|
.order(created_at: :asc)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -363,6 +363,12 @@ describe Dossier do
|
||||||
it { expect(dossier.avis_for_instructeur(instructeur)).to match([avis_2, avis_1, avis_3]) }
|
it { expect(dossier.avis_for_instructeur(instructeur)).to match([avis_2, avis_1, avis_3]) }
|
||||||
it { expect(dossier.avis_for_expert(expert_1)).to match([avis_2, avis_1, avis_3]) }
|
it { expect(dossier.avis_for_expert(expert_1)).to match([avis_2, avis_1, avis_3]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when they are a advice published on another dossier' do
|
||||||
|
let!(:avis) { create(:avis, dossier: create(:dossier, procedure: procedure), claimant: instructeur, experts_procedure: experts_procedure, confidentiel: false, created_at: Time.zone.parse('9/01/2010')) }
|
||||||
|
|
||||||
|
it { expect(dossier.avis_for_expert(expert_1)).to match([]) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#update_state_dates' do
|
describe '#update_state_dates' do
|
||||||
|
|
Loading…
Reference in a new issue