Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correctif(expert.invite-autre-expert): ETQ expert, je ne pouvais pas demander d'autres avis d'expert #9487

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/controllers/experts/avis_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def avis_list

def avis_new
@new_avis = Avis.new
if @dossier.procedure.experts_require_administrateur_invitation?
@experts_emails = @dossier.procedure.experts_procedures.where(revoked_at: nil).map { _1.expert.email }.sort
else
@experts_emails = @dossier.procedure.experts.map(&:email).sort
end
end

def create_avis
Expand Down
23 changes: 23 additions & 0 deletions spec/controllers/experts/avis_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,29 @@
end
end

describe '#avis_new' do
let!(:revoked_expert) { create(:experts_procedure, revoked_at: 2.days.ago, procedure: procedure, expert: create(:expert)).expert }
before do
get :avis_new, params: { procedure_id: procedure.id, id: avis_without_answer.id }
end
context 'when procedure experts need administrateur invitation' do
let!(:procedure) { create(:procedure, experts_require_administrateur_invitation: true) }

it 'limit invited email list to not revoked experts' do
expect(assigns(:experts_emails)).to include(experts_procedure.expert.user.email)
expect(assigns(:experts_emails)).not_to include(revoked_expert.user.email)
end
end
context 'when procedure experts can be anyone' do
let!(:procedure) { create(:procedure, experts_require_administrateur_invitation: false) }

it 'prefill autocomplete with all experts in the procedure' do
expect(assigns(:experts_emails)).to include(experts_procedure.expert.user.email)
expect(assigns(:experts_emails)).to include(revoked_expert.user.email)
end
end
end

describe '#create_avis' do
let(:previous_avis_confidentiel) { false }
let(:previous_revoked_at) { nil }
Expand Down