2023-03-06 15:51:08 +01:00
|
|
|
describe 'administrateurs/experts_procedures/index', type: :view do
|
2020-12-18 09:16:41 +01:00
|
|
|
let!(:procedure) { create(:procedure, :published) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
assign(:procedure, procedure)
|
|
|
|
assign(:procedure_lien, commencer_url(path: procedure.path))
|
|
|
|
allow(view).to receive(:current_administrateur).and_return(procedure.administrateurs.first)
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { render }
|
|
|
|
|
|
|
|
context 'when the procedure has 0 avis' do
|
|
|
|
let!(:dossier) { create(:dossier, procedure: procedure) }
|
|
|
|
before do
|
2021-02-11 20:30:40 +01:00
|
|
|
@invited_experts = procedure.experts_procedures
|
2020-12-18 09:16:41 +01:00
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has 0 experts into the page' do
|
2021-02-11 20:30:40 +01:00
|
|
|
expect(@invited_experts.count).to eq(0)
|
|
|
|
expect(@invited_experts).to eq([])
|
2020-12-18 09:16:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the procedure has 3 avis from 2 experts and 1 unasigned' do
|
|
|
|
let!(:dossier) { create(:dossier, procedure: procedure) }
|
2021-03-23 12:25:57 +01:00
|
|
|
let!(:avis) { create(:avis, dossier: dossier) }
|
|
|
|
let!(:avis2) { create(:avis, dossier: dossier) }
|
2020-12-18 09:16:41 +01:00
|
|
|
|
|
|
|
before do
|
2021-02-11 20:30:40 +01:00
|
|
|
@invited_experts = procedure.experts_procedures
|
2020-12-18 09:16:41 +01:00
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
2021-01-25 13:02:22 +01:00
|
|
|
it 'has 2 experts and match array' do
|
2021-02-11 20:30:40 +01:00
|
|
|
expect(@invited_experts.count).to eq(2)
|
2021-03-23 12:25:57 +01:00
|
|
|
expect(@invited_experts).to match_array([avis.experts_procedure, avis2.experts_procedure])
|
2020-12-18 09:16:41 +01:00
|
|
|
end
|
|
|
|
end
|
2021-04-16 11:22:37 +02:00
|
|
|
|
|
|
|
context 'when the experts_require_administrateur_invitation is false' do
|
|
|
|
it 'authorize instructors to invite any expert' do
|
2024-05-28 16:40:15 +02:00
|
|
|
expect(rendered).not_to have_content "Entrez les adresses emails des experts que vous souhaitez ajouter à la liste prédéfinie"
|
2021-04-16 11:22:37 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the experts_require_administrateur_invitation is true' do
|
|
|
|
let!(:procedure) { create(:procedure, :published, experts_require_administrateur_invitation: true) }
|
|
|
|
before do
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
it 'does not authorize instructors to invite any expert but only those presents in admin list' do
|
2024-05-28 16:40:15 +02:00
|
|
|
expect(rendered).to have_content "Entrez les adresses emails des experts que vous souhaitez ajouter à la liste prédéfinie"
|
2021-04-16 11:22:37 +02:00
|
|
|
end
|
|
|
|
end
|
2020-12-18 09:16:41 +01:00
|
|
|
end
|