feat: do not suggest unconfirmed experts
This commit is contained in:
parent
1502635327
commit
8d95df2250
2 changed files with 6 additions and 4 deletions
|
@ -33,6 +33,7 @@ class Expert < ApplicationRecord
|
||||||
experts = Expert
|
experts = Expert
|
||||||
.joins(:experts_procedures, :user)
|
.joins(:experts_procedures, :user)
|
||||||
.where(experts_procedures: { procedure: procedure })
|
.where(experts_procedures: { procedure: procedure })
|
||||||
|
.where.not(users: { confirmed_at: nil })
|
||||||
|
|
||||||
if procedure.experts_require_administrateur_invitation?
|
if procedure.experts_require_administrateur_invitation?
|
||||||
experts = experts
|
experts = experts
|
||||||
|
|
|
@ -101,16 +101,17 @@ RSpec.describe Expert, type: :model do
|
||||||
let(:procedure) { create(:procedure, experts_require_administrateur_invitation: true) }
|
let(:procedure) { create(:procedure, experts_require_administrateur_invitation: true) }
|
||||||
let(:expert) { create(:expert) }
|
let(:expert) { create(:expert) }
|
||||||
let(:revoked_expert) { create(:expert) }
|
let(:revoked_expert) { create(:expert) }
|
||||||
|
let(:unconfirmed_expert) { create(:expert) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
procedure.experts << expert << revoked_expert
|
procedure.experts << expert << revoked_expert << unconfirmed_expert
|
||||||
ExpertsProcedure.find_by(expert: revoked_expert, procedure: procedure)
|
ExpertsProcedure.find_by(expert: revoked_expert, procedure: procedure)
|
||||||
.update!(revoked_at: 1.day.ago)
|
.update!(revoked_at: 1.day.ago)
|
||||||
|
unconfirmed_expert.user.update!(confirmed_at: nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when procedure experts need administrateur invitation' do
|
context 'when procedure experts need administrateur invitation' do
|
||||||
|
it 'returns only confirmed not revoked experts' do
|
||||||
it 'returns only not revoked experts' do
|
|
||||||
expect(subject).to eq([expert.user.email])
|
expect(subject).to eq([expert.user.email])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -118,7 +119,7 @@ RSpec.describe Expert, type: :model do
|
||||||
context 'when procedure experts can be anyone' do
|
context 'when procedure experts can be anyone' do
|
||||||
let(:procedure) { create(:procedure, experts_require_administrateur_invitation: false) }
|
let(:procedure) { create(:procedure, experts_require_administrateur_invitation: false) }
|
||||||
|
|
||||||
it 'prefill autocomplete with all experts in the procedure' do
|
it 'prefill autocomplete with all confirmed experts in the procedure' do
|
||||||
expect(subject).to eq([expert.user.email, revoked_expert.user.email])
|
expect(subject).to eq([expert.user.email, revoked_expert.user.email])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue