Dossier Factory: link procedure by defaut_groupe_instructeur
Oblige to create procedure or dossier to access groupe_instructeur
This commit is contained in:
parent
74096b6b3a
commit
6cbdba2665
3 changed files with 33 additions and 27 deletions
|
@ -4,11 +4,17 @@ FactoryBot.define do
|
|||
state { Dossier.states.fetch(:brouillon) }
|
||||
association :user, factory: [:user]
|
||||
|
||||
before(:create) do |dossier, _evaluator|
|
||||
if !dossier.procedure
|
||||
procedure = create(:procedure, :published, :with_type_de_champ, :with_type_de_champ_private)
|
||||
dossier.procedure = procedure
|
||||
transient do
|
||||
procedure { nil }
|
||||
end
|
||||
|
||||
after(:build) do |dossier, evaluator|
|
||||
if evaluator.procedure.present?
|
||||
procedure = evaluator.procedure
|
||||
else
|
||||
procedure = create(:procedure, :published, :with_type_de_champ, :with_type_de_champ_private)
|
||||
end
|
||||
dossier.groupe_instructeur = procedure.defaut_groupe_instructeur
|
||||
end
|
||||
|
||||
trait :with_entreprise do
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
describe IndividualSerializer do
|
||||
describe '#attributes' do
|
||||
let(:procedure) { build(:procedure) }
|
||||
let(:dossier) { build(:dossier, procedure: procedure) }
|
||||
let(:individual) { build(:individual, gender: 'M.', nom: 'nom', prenom: 'prenom', birthdate: Date.new(2001, 8, 27), dossier: dossier) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||
let(:individual) { create(:individual, gender: 'M.', nom: 'nom', prenom: 'prenom', birthdate: Date.new(2001, 8, 27), dossier: dossier) }
|
||||
|
||||
subject { IndividualSerializer.new(individual).serializable_hash }
|
||||
|
||||
|
@ -12,7 +12,7 @@ describe IndividualSerializer do
|
|||
it { is_expected.not_to have_key(:date_naissance) }
|
||||
|
||||
context 'when the procedure asks for a birthdate' do
|
||||
let(:procedure) { build(:procedure, ask_birthday: true) }
|
||||
before { procedure.update(ask_birthday: true) }
|
||||
|
||||
it { is_expected.to include(date_naissance: Date.new(2001, 8, 27)) }
|
||||
end
|
||||
|
|
|
@ -90,13 +90,13 @@ describe AdministrateurUsageStatisticsService do
|
|||
end
|
||||
|
||||
context 'with a procedure archivee' do
|
||||
let(:procedure) { create(:procedure, aasm_state: 'archivee', dossiers: dossiers) }
|
||||
let(:dossiers) do
|
||||
let(:procedure) { create(:procedure, aasm_state: 'archivee') }
|
||||
let!(:dossiers) do
|
||||
(1..7).flat_map do
|
||||
[
|
||||
create(:dossier, :en_construction),
|
||||
create(:dossier, :en_instruction),
|
||||
create(:dossier, :accepte)
|
||||
create(:dossier, :en_construction, procedure: procedure),
|
||||
create(:dossier, :en_instruction, procedure: procedure),
|
||||
create(:dossier, :accepte, procedure: procedure)
|
||||
]
|
||||
end
|
||||
end
|
||||
|
@ -141,13 +141,13 @@ describe AdministrateurUsageStatisticsService do
|
|||
end
|
||||
|
||||
context 'with a procedure en test' do
|
||||
let(:procedure) { create(:procedure, dossiers: dossiers) }
|
||||
let(:dossiers) do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let!(:dossiers) do
|
||||
(1..7).flat_map do
|
||||
[
|
||||
create(:dossier, :en_construction),
|
||||
create(:dossier, :en_instruction),
|
||||
create(:dossier, :accepte)
|
||||
create(:dossier, :en_construction, procedure: procedure),
|
||||
create(:dossier, :en_instruction, procedure: procedure),
|
||||
create(:dossier, :accepte, procedure: procedure)
|
||||
]
|
||||
end
|
||||
end
|
||||
|
@ -171,12 +171,12 @@ describe AdministrateurUsageStatisticsService do
|
|||
end
|
||||
|
||||
context 'with a procedure en prod' do
|
||||
let(:procedure) { create(:procedure, aasm_state: 'publiee', dossiers: dossiers) }
|
||||
let(:dossiers) do
|
||||
let(:procedure) { create(:procedure, aasm_state: 'publiee') }
|
||||
let!(:dossiers) do
|
||||
[
|
||||
create(:dossier, :en_construction),
|
||||
create(:dossier, :en_instruction),
|
||||
create(:dossier, :accepte)
|
||||
create(:dossier, :en_construction, procedure: procedure),
|
||||
create(:dossier, :en_instruction, procedure: procedure),
|
||||
create(:dossier, :accepte, procedure: procedure)
|
||||
]
|
||||
end
|
||||
|
||||
|
@ -199,13 +199,13 @@ describe AdministrateurUsageStatisticsService do
|
|||
end
|
||||
|
||||
context 'with a procedure en prod and more than 20 dossiers' do
|
||||
let(:procedure) { create(:procedure, aasm_state: 'publiee', dossiers: dossiers) }
|
||||
let(:dossiers) do
|
||||
let(:procedure) { create(:procedure, aasm_state: 'publiee') }
|
||||
let!(:dossiers) do
|
||||
(1..7).flat_map do
|
||||
[
|
||||
create(:dossier, :en_construction),
|
||||
create(:dossier, :en_instruction),
|
||||
create(:dossier, :accepte)
|
||||
create(:dossier, :en_construction, procedure: procedure),
|
||||
create(:dossier, :en_instruction, procedure: procedure),
|
||||
create(:dossier, :accepte, procedure: procedure)
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue