Merge pull request #10358 from demarches-simplifiees/allow_unsigned_expert
Instructeur: autocomplete les experts ne s'étant pas connectés si la liste est controllée par l'administrateur
This commit is contained in:
commit
696c8458d7
2 changed files with 12 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue