fix: allow unsigned expert when restricted list

This commit is contained in:
simon lehericey 2024-04-19 13:03:09 +02:00
parent efc1fafaab
commit 9e33b1ee6d
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
2 changed files with 12 additions and 8 deletions

View file

@ -34,15 +34,13 @@ class Expert < ApplicationRecord
.joins(:experts_procedures, :user)
.where(experts_procedures: { procedure: procedure })
new_or_confirmed_experts = procedure_experts
.where.not(users: { last_sign_in_at: nil })
.or(procedure_experts.where(users: { created_at: 1.day.ago.. }))
suggested_expert = if procedure.experts_require_administrateur_invitation?
new_or_confirmed_experts
procedure_experts
.where(experts_procedures: { revoked_at: nil })
else
new_or_confirmed_experts
procedure_experts
.where.not(users: { last_sign_in_at: nil })
.or(procedure_experts.where(users: { created_at: 1.day.ago.. }))
end
suggested_expert

View file

@ -113,8 +113,14 @@ RSpec.describe Expert, type: :model do
end
context 'when procedure experts need administrateur invitation' do
it 'returns only confirmed not revoked experts' do
expect(subject).to eq([expert.user.email, new_unsigned_expert.user.email].sort)
it 'returns only not revoked experts' do
expect(subject).to eq([
expert,
unsigned_expert,
new_unsigned_expert
]
.map { _1.user.email }
.sort)
end
end