experts_procedure should not be optional
This commit is contained in:
parent
25c85dd0f9
commit
0b22788d60
18 changed files with 59 additions and 53 deletions
|
@ -18,8 +18,8 @@ module CreateAvisConcern
|
|||
|
||||
create_results = Avis.create(
|
||||
expert_emails.flat_map do |email|
|
||||
expert = User.create_or_promote_to_expert(email, SecureRandom.hex).expert
|
||||
experts_procedure = ExpertsProcedure.find_or_create_by(procedure: dossier.procedure, expert: expert)
|
||||
user = User.create_or_promote_to_expert(email, SecureRandom.hex)
|
||||
experts_procedure = user.valid? ? ExpertsProcedure.find_or_create_by(procedure: dossier.procedure, expert: user.expert) : nil
|
||||
allowed_dossiers.map do |dossier|
|
||||
{
|
||||
email: email,
|
||||
|
@ -54,7 +54,7 @@ module CreateAvisConcern
|
|||
if failed.any?
|
||||
flash.now.alert = failed
|
||||
.filter { |avis| avis.errors.present? }
|
||||
.map { |avis| "#{avis.email} : #{avis.errors.full_messages.join(', ')}" }
|
||||
.map { |avis| "#{avis.email} : #{avis.errors.full_messages_for(:email).join(', ')}" }
|
||||
|
||||
# When an error occurs, return the avis back to the controller
|
||||
# to give the user a chance to correct and resubmit
|
||||
|
|
|
@ -22,7 +22,7 @@ class Avis < ApplicationRecord
|
|||
|
||||
belongs_to :dossier, inverse_of: :avis, touch: true, optional: false
|
||||
belongs_to :instructeur, optional: true
|
||||
belongs_to :experts_procedure, optional: true
|
||||
belongs_to :experts_procedure, optional: false
|
||||
belongs_to :claimant, class_name: 'Instructeur', optional: false
|
||||
|
||||
has_one_attached :piece_justificative_file
|
||||
|
|
|
@ -9,9 +9,9 @@ describe Experts::AvisController, type: :controller do
|
|||
let(:procedure) { create(:procedure, :published, instructeurs: [instructeur]) }
|
||||
let(:another_procedure) { create(:procedure, :published, instructeurs: [instructeur]) }
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
let!(:avis_without_answer) { Avis.create(dossier: dossier, claimant: claimant, experts_procedure: experts_procedure) }
|
||||
let!(:avis_with_answer) { Avis.create(dossier: dossier, claimant: claimant, experts_procedure: experts_procedure, answer: 'yop') }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
let!(:avis_without_answer) { create(:avis, dossier: dossier, claimant: claimant, experts_procedure: experts_procedure) }
|
||||
let!(:avis_with_answer) { create(:avis, dossier: dossier, claimant: claimant, experts_procedure: experts_procedure, answer: 'yop') }
|
||||
|
||||
before do
|
||||
sign_in(expert.user)
|
||||
|
@ -155,7 +155,7 @@ describe Experts::AvisController, type: :controller do
|
|||
end
|
||||
|
||||
describe '#expert_cannot_invite_another_expert' do
|
||||
let!(:previous_avis) { Avis.create(dossier: dossier, claimant: claimant, experts_procedure: experts_procedure, confidentiel: previous_avis_confidentiel) }
|
||||
let!(:previous_avis) { create(:avis, dossier: dossier, claimant: claimant, experts_procedure: experts_procedure, confidentiel: previous_avis_confidentiel) }
|
||||
let(:previous_avis_confidentiel) { false }
|
||||
let(:asked_confidentiel) { false }
|
||||
let(:intro) { 'introduction' }
|
||||
|
@ -175,7 +175,7 @@ describe Experts::AvisController, type: :controller do
|
|||
end
|
||||
|
||||
describe '#create_avis' do
|
||||
let!(:previous_avis) { Avis.create(dossier: dossier, claimant: claimant, experts_procedure: experts_procedure, confidentiel: previous_avis_confidentiel) }
|
||||
let!(:previous_avis) { create(:avis, dossier: dossier, claimant: claimant, experts_procedure: experts_procedure, confidentiel: previous_avis_confidentiel) }
|
||||
let(:emails) { ['a@b.com'] }
|
||||
let(:intro) { 'introduction' }
|
||||
let(:created_avis) { Avis.last }
|
||||
|
@ -271,9 +271,9 @@ describe Experts::AvisController, type: :controller do
|
|||
|
||||
context 'when the expert also shares the linked dossiers' do
|
||||
context 'and the expert can access the linked dossiers' do
|
||||
let(:created_avis) { Avis.create(dossier: dossier, claimant: claimant, email: "toto3@gmail.com") }
|
||||
let(:created_avis) { create(:avis, dossier: dossier, claimant: claimant, email: "toto3@gmail.com") }
|
||||
let(:linked_dossier) { Dossier.find_by(id: dossier.reload.champs.filter(&:dossier_link?).map(&:value).compact) }
|
||||
let(:linked_avis) { Avis.create(dossier: linked_dossier, claimant: claimant) }
|
||||
let(:linked_avis) { create(:avis, dossier: linked_dossier, claimant: claimant) }
|
||||
let(:invite_linked_dossiers) { true }
|
||||
|
||||
it 'sends one avis for the main dossier' do
|
||||
|
@ -304,7 +304,7 @@ describe Experts::AvisController, type: :controller do
|
|||
let(:invited_email) { 'invited@avis.com' }
|
||||
let(:claimant) { create(:instructeur) }
|
||||
let(:expert) { create(:expert) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:procedure) { dossier.procedure }
|
||||
let!(:avis) { create(:avis, experts_procedure: experts_procedure, claimant: claimant, dossier: dossier) }
|
||||
|
|
|
@ -5,12 +5,12 @@ describe Instructeurs::AvisController, type: :controller do
|
|||
let(:now) { Time.zone.parse('01/02/2345') }
|
||||
let(:expert) { create(:expert) }
|
||||
let(:claimant) { create(:instructeur) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
let(:instructeur) { create(:instructeur) }
|
||||
let(:procedure) { create(:procedure, :published, instructeurs: [instructeur]) }
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
let!(:avis) { Avis.create(dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure) }
|
||||
let!(:avis_without_answer) { Avis.create(dossier: dossier, claimant: claimant, experts_procedure: experts_procedure) }
|
||||
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure) }
|
||||
let!(:avis_without_answer) { create(:avis, dossier: dossier, claimant: claimant, experts_procedure: experts_procedure) }
|
||||
|
||||
before { sign_in(instructeur.user) }
|
||||
|
||||
|
|
|
@ -435,7 +435,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
|
||||
describe "#create_avis" do
|
||||
let(:expert) { create(:expert) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: dossier.procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: dossier.procedure) }
|
||||
let(:invite_linked_dossiers) { false }
|
||||
let(:saved_avis) { dossier.avis.first }
|
||||
let!(:old_avis_count) { Avis.count }
|
||||
|
@ -556,7 +556,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
let(:instructeur) { create(:instructeur) }
|
||||
let(:expert) { create(:expert) }
|
||||
let(:procedure) { create(:procedure, :published, instructeurs: instructeurs) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
let(:dossier) do
|
||||
create(:dossier,
|
||||
:accepte,
|
||||
|
|
|
@ -3,7 +3,7 @@ describe InvitesController, type: :controller do
|
|||
let(:email) { 'plop@octo.com' }
|
||||
let(:expert) { create(:expert) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
|
||||
describe '#POST create' do
|
||||
let(:invite) { Invite.last }
|
||||
|
@ -26,7 +26,7 @@ describe InvitesController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when instructeur is invited for avis on dossier' do
|
||||
before { Avis.create(experts_procedure: experts_procedure, claimant: create(:instructeur), dossier: dossier) }
|
||||
before { create(:avis, experts_procedure: experts_procedure, claimant: create(:instructeur), dossier: dossier) }
|
||||
|
||||
it_behaves_like "he can not create invitation"
|
||||
end
|
||||
|
|
|
@ -536,14 +536,14 @@ describe NewAdministrateur::ProceduresController, type: :controller do
|
|||
describe 'PUT #update_allow_decision_access' do
|
||||
let!(:procedure) { create :procedure, :with_service, administrateur: admin }
|
||||
let(:expert) { create(:expert) }
|
||||
let(:expert_procedure) { ExpertsProcedure.create(procedure: procedure, expert: expert) }
|
||||
let(:expert_procedure) { create(:experts_procedure, procedure: procedure, expert: expert) }
|
||||
|
||||
subject do
|
||||
put :update_allow_decision_access, params: { procedure_id: procedure.id, experts_procedure: { allow_decision_access: !expert_procedure.allow_decision_access }, expert_procedure: expert_procedure }, format: :js
|
||||
end
|
||||
|
||||
context 'when the experts_procedure is true' do
|
||||
let(:expert_procedure) { ExpertsProcedure.create(procedure: procedure, expert: expert, allow_decision_access: true) }
|
||||
let(:expert_procedure) { create(:experts_procedure, procedure: procedure, expert: expert, allow_decision_access: true) }
|
||||
|
||||
before do
|
||||
subject
|
||||
|
|
|
@ -9,6 +9,10 @@ FactoryBot.define do
|
|||
association :dossier
|
||||
association :claimant, factory: :instructeur
|
||||
|
||||
after(:build) do |avis, _evaluator|
|
||||
avis.experts_procedure ||= build(:experts_procedure, procedure: avis.dossier.procedure)
|
||||
end
|
||||
|
||||
trait :with_instructeur do
|
||||
email { nil }
|
||||
instructeur { association :instructeur, email: generate(:expert_email) }
|
||||
|
|
6
spec/factories/experts_procedure.rb
Normal file
6
spec/factories/experts_procedure.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
FactoryBot.define do
|
||||
factory :experts_procedure do
|
||||
association :expert
|
||||
association :procedure
|
||||
end
|
||||
end
|
|
@ -6,7 +6,7 @@ feature 'Inviting an expert:' do
|
|||
let(:expert) { create(:expert) }
|
||||
let(:instructeur) { create(:instructeur) }
|
||||
let(:procedure) { create(:procedure, :published, instructeurs: [instructeur]) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
let(:dossier) { create(:dossier, :en_construction, :with_dossier_link, procedure: procedure) }
|
||||
let(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true) }
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ feature 'Inviting an expert:' do
|
|||
end
|
||||
|
||||
context 'when experts submitted their answer' do
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
let!(:answered_avis) { create(:avis, :with_answer, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure) }
|
||||
|
||||
scenario 'I can read the expert answer' do
|
||||
|
|
|
@ -3,8 +3,8 @@ RSpec.describe AvisMailer, type: :mailer do
|
|||
let(:claimant) { create(:instructeur) }
|
||||
let(:expert) { create(:expert) }
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: dossier.procedure) }
|
||||
let(:avis) { Avis.create(dossier: dossier, claimant: claimant, experts_procedure: experts_procedure, introduction: 'intro') }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: dossier.procedure) }
|
||||
let(:avis) { create(:avis, dossier: dossier, claimant: claimant, experts_procedure: experts_procedure, introduction: 'intro') }
|
||||
|
||||
subject { described_class.avis_invitation(avis) }
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ RSpec.describe Avis, type: :model do
|
|||
let(:invited_email) { 'invited@avis.com' }
|
||||
let(:expert) { create(:expert) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
|
||||
subject { avis.email_to_display }
|
||||
|
||||
|
@ -31,7 +31,7 @@ RSpec.describe Avis, type: :model do
|
|||
describe "an avis is linked to an expert_procedure" do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:expert) { create(:expert) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(procedure: procedure, expert: expert) }
|
||||
let(:experts_procedure) { create(:experts_procedure, procedure: procedure, expert: expert) }
|
||||
|
||||
context 'an avis is linked to an experts_procedure' do
|
||||
let!(:avis) { create(:avis, email: nil, experts_procedure: experts_procedure) }
|
||||
|
@ -77,8 +77,8 @@ RSpec.describe Avis, type: :model do
|
|||
describe "email sanitization" do
|
||||
let(:expert) { create(:expert) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
let!(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
subject { Avis.create(claimant: claimant, email: email, experts_procedure: experts_procedure, dossier: create(:dossier)) }
|
||||
let!(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
subject { create(:avis, claimant: claimant, email: email, experts_procedure: experts_procedure, dossier: create(:dossier)) }
|
||||
|
||||
context "when there is no email" do
|
||||
let(:email) { nil }
|
||||
|
@ -147,7 +147,7 @@ RSpec.describe Avis, type: :model do
|
|||
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||
let(:claimant_expert) { create(:instructeur) }
|
||||
let(:expert) { create(:expert) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
let(:another_expert) { create(:expert) }
|
||||
|
||||
context "when avis claimed by an expert" do
|
||||
|
@ -164,8 +164,8 @@ RSpec.describe Avis, type: :model do
|
|||
let(:expert) { create(:expert) }
|
||||
let(:expert_2) { create(:expert) }
|
||||
let!(:procedure) { create(:procedure, :published, instructeurs: instructeurs) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure_2) { ExpertsProcedure.create(expert: expert_2, procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure_2) { create(:experts_procedure, expert: expert_2, procedure: procedure) }
|
||||
let(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure) }
|
||||
let(:another_avis) { create(:avis, dossier: dossier, claimant: expert, experts_procedure: experts_procedure_2) }
|
||||
let(:another_instructeur) { create(:instructeur) }
|
||||
|
|
|
@ -307,13 +307,13 @@ describe Dossier do
|
|||
let!(:instructeur) { create(:instructeur) }
|
||||
let!(:procedure) { create(:procedure, :published, instructeurs: [instructeur]) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_construction)) }
|
||||
let!(:experts_procedure) { ExpertsProcedure.create(expert: expert_1, procedure: procedure) }
|
||||
let!(:experts_procedure_2) { ExpertsProcedure.create(expert: expert_2, procedure: procedure) }
|
||||
let!(:experts_procedure) { create(:experts_procedure, expert: expert_1, procedure: procedure) }
|
||||
let!(:experts_procedure_2) { create(:experts_procedure, expert: expert_2, procedure: procedure) }
|
||||
let!(:expert_1) { create(:expert) }
|
||||
let!(:expert_2) { create(:expert) }
|
||||
|
||||
context 'when there is a public advice asked from the dossiers instructeur' do
|
||||
let!(:avis) { Avis.create(dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: false) }
|
||||
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: false) }
|
||||
|
||||
it { expect(dossier.avis_for_instructeur(instructeur)).to match([avis]) }
|
||||
it { expect(dossier.avis_for_expert(expert_1)).to match([avis]) }
|
||||
|
@ -321,7 +321,7 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context 'when there is a private advice asked from the dossiers instructeur' do
|
||||
let!(:avis) { Avis.create(dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true) }
|
||||
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true) }
|
||||
|
||||
it { expect(dossier.avis_for_instructeur(instructeur)).to match([avis]) }
|
||||
it { expect(dossier.avis_for_expert(expert_1)).to match([avis]) }
|
||||
|
@ -329,7 +329,7 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context 'when there is a public advice asked from one expert to another' do
|
||||
let!(:avis) { Avis.create(dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure_2, confidentiel: false) }
|
||||
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure_2, confidentiel: false) }
|
||||
|
||||
it { expect(dossier.avis_for_instructeur(instructeur)).to match([avis]) }
|
||||
it { expect(dossier.avis_for_expert(expert_1)).to match([avis]) }
|
||||
|
@ -337,7 +337,7 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context 'when there is a private advice asked from one expert to another' do
|
||||
let!(:avis) { Avis.create(dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure_2, confidentiel: true) }
|
||||
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure_2, confidentiel: true) }
|
||||
|
||||
it { expect(dossier.avis_for_instructeur(instructeur)).to match([avis]) }
|
||||
it { expect(dossier.avis_for_expert(expert_1)).not_to match([avis]) }
|
||||
|
@ -345,9 +345,9 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context 'when they are a lot of advice' do
|
||||
let!(:avis_1) { Avis.create(dossier: dossier, claimant: expert_1, experts_procedure: experts_procedure_2, confidentiel: false, created_at: Time.zone.parse('10/01/2010'), tmp_expert_migrated: true) }
|
||||
let!(:avis_2) { Avis.create(dossier: dossier, claimant: expert_1, experts_procedure: experts_procedure_2, confidentiel: false, created_at: Time.zone.parse('9/01/2010'), tmp_expert_migrated: true) }
|
||||
let!(:avis_3) { Avis.create(dossier: dossier, claimant: expert_1, experts_procedure: experts_procedure_2, confidentiel: false, created_at: Time.zone.parse('11/01/2010'), tmp_expert_migrated: true) }
|
||||
let!(:avis_1) { create(:avis, dossier: dossier, claimant: expert_1, experts_procedure: experts_procedure_2, confidentiel: false, created_at: Time.zone.parse('10/01/2010'), tmp_expert_migrated: true) }
|
||||
let!(:avis_2) { create(:avis, dossier: dossier, claimant: expert_1, experts_procedure: experts_procedure_2, confidentiel: false, created_at: Time.zone.parse('9/01/2010'), tmp_expert_migrated: true) }
|
||||
let!(:avis_3) { create(:avis, dossier: dossier, claimant: expert_1, experts_procedure: experts_procedure_2, confidentiel: false, created_at: Time.zone.parse('11/01/2010'), tmp_expert_migrated: true) }
|
||||
|
||||
it { expect(dossier.avis_for_instructeur(instructeur)).to match([avis_2, avis_1, avis_3]) }
|
||||
it { expect(dossier.avis_for_expert(expert_1)).to match([avis_2, avis_1, avis_3]) }
|
||||
|
|
|
@ -5,9 +5,9 @@ RSpec.describe ExpertsProcedure, type: :model do
|
|||
let(:expert) { create(:expert) }
|
||||
let(:expert2) { create(:expert) }
|
||||
let(:expert3) { create(:expert) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure2) { ExpertsProcedure.create(expert: expert2, procedure: procedure) }
|
||||
let(:experts_procedure3) { ExpertsProcedure.create(expert: expert3, procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure2) { create(:experts_procedure, expert: expert2, procedure: procedure) }
|
||||
let(:experts_procedure3) { create(:experts_procedure, expert: expert3, procedure: procedure) }
|
||||
subject { procedure.experts_procedures }
|
||||
|
||||
context 'when there is one dossier' do
|
||||
|
|
|
@ -3,7 +3,7 @@ describe 'experts/avis/instruction.html.haml', type: :view do
|
|||
let(:claimant) { create(:instructeur) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
let!(:avis) { create(:avis, confidentiel: confidentiel, claimant: claimant, experts_procedure: experts_procedure) }
|
||||
let!(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||
let!(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
|
||||
before do
|
||||
assign(:avis, avis)
|
||||
|
|
|
@ -6,7 +6,7 @@ describe 'instructeurs/shared/avis/_list.html.haml', type: :view do
|
|||
let(:instructeur) { create(:instructeur) }
|
||||
let(:expert) { create(:expert) }
|
||||
let!(:dossier) { create(:dossier) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(expert: expert, procedure: dossier.procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: dossier.procedure) }
|
||||
let(:avis) { [create(:avis, claimant: instructeur, experts_procedure: experts_procedure)] }
|
||||
let(:seen_at) { avis.first.created_at + 1.hour }
|
||||
|
||||
|
|
|
@ -24,12 +24,8 @@ describe 'new_administrateur/procedures/invited_expert_list.html.haml', type: :v
|
|||
|
||||
context 'when the procedure has 3 avis from 2 experts and 1 unasigned' do
|
||||
let!(:dossier) { create(:dossier, procedure: procedure) }
|
||||
let(:expert) { create(:expert) }
|
||||
let(:expert2) { create(:expert) }
|
||||
let(:experts_procedure) { ExpertsProcedure.create(procedure: procedure, expert: expert) }
|
||||
let(:experts_procedure2) { ExpertsProcedure.create(procedure: procedure, expert: expert2) }
|
||||
let!(:avis) { create(:avis, dossier: dossier, experts_procedure: experts_procedure) }
|
||||
let!(:avis2) { create(:avis, dossier: dossier, experts_procedure: experts_procedure2) }
|
||||
let!(:avis) { create(:avis, dossier: dossier) }
|
||||
let!(:avis2) { create(:avis, dossier: dossier) }
|
||||
|
||||
before do
|
||||
@invited_experts = procedure.experts_procedures
|
||||
|
@ -38,7 +34,7 @@ describe 'new_administrateur/procedures/invited_expert_list.html.haml', type: :v
|
|||
|
||||
it 'has 2 experts and match array' do
|
||||
expect(@invited_experts.count).to eq(2)
|
||||
expect(@invited_experts).to match_array([experts_procedure, experts_procedure2])
|
||||
expect(@invited_experts).to match_array([avis.experts_procedure, avis2.experts_procedure])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue