fix: allow unsigned expert when restricted list
This commit is contained in:
parent
efc1fafaab
commit
9e33b1ee6d
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