build cerfa on create new dossier
This commit is contained in:
parent
8273438910
commit
892484b494
2 changed files with 20 additions and 0 deletions
|
@ -10,7 +10,16 @@ class Dossier < ActiveRecord::Base
|
|||
delegate :siret, to: :etablissement
|
||||
delegate :types_piece_jointe, to: :formulaire
|
||||
|
||||
before_create :build_default_cerfa
|
||||
|
||||
def get_pj piece_jointe_id
|
||||
pieces_jointes.where(type_piece_jointe_id: piece_jointe_id).last
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_default_cerfa
|
||||
build_cerfa
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -52,4 +52,15 @@ describe Dossier do
|
|||
expect(subject).to include(TypePieceJointe.find(103))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'creation' do
|
||||
it 'create default cerfa' do
|
||||
expect{Dossier.create}.to change{ Cerfa.count }.by(1)
|
||||
end
|
||||
|
||||
it 'link cerfa to dossier' do
|
||||
dossier = Dossier.create
|
||||
expect(dossier.cerfa).to eq(Cerfa.last)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue