factories: ensure that dossiers with_individual are consistent

This commit is contained in:
Pierre de La Morinerie 2020-01-07 17:45:39 +01:00
parent 724ff50363
commit 0efb62f03a
3 changed files with 6 additions and 2 deletions

View file

@ -43,6 +43,9 @@ FactoryBot.define do
if evaluator.procedure.nil?
dossier.procedure.update(for_individual: true)
end
if !dossier.procedure.for_individual?
raise 'Inconsistent factory: attempting to create a dossier :with_individual on a procedure that is not `for_individual?`'
end
dossier.individual = create(:individual)
end
end

View file

@ -573,7 +573,7 @@ describe Dossier do
end
describe '#owner_name' do
let!(:procedure) { create(:procedure) }
let(:procedure) { create(:procedure) }
subject { dossier.owner_name }
context 'when there is no entreprise or individual' do
@ -589,6 +589,7 @@ describe Dossier do
end
context 'when there is an individual' do
let(:procedure) { create(:procedure, :for_individual) }
let(:dossier) { create(:dossier, :with_individual, procedure: procedure) }
it { is_expected.to eq("#{dossier.individual.nom} #{dossier.individual.prenom}") }

View file

@ -3,7 +3,7 @@ require 'rails_helper'
RSpec.describe 'commencer/show.html.haml', type: :view do
include Rails.application.routes.url_helpers
let(:procedure) { create(:procedure, :with_service, :published) }
let(:procedure) { create(:procedure, :published, :for_individual, :with_service) }
before do
assign(:procedure, procedure)