specs: improve avis factory

The instructeur, dossier and claimant where created regardless of
wether they already existed or not.

With this commit:

- Associations are declarated in a more idiomatic way
- They are correctly not created if they are provided when creating the
object.
This commit is contained in:
Pierre de La Morinerie 2019-10-21 09:45:03 +00:00
parent a56dc0f653
commit ec6ec6f4aa
2 changed files with 11 additions and 20 deletions

View file

@ -1,9 +1,11 @@
describe 'instructeurs/avis/instruction.html.haml', type: :view do
let(:avis) { create(:avis, confidentiel: confidentiel) }
let(:expert) { create(:instructeur) }
let(:avis) { create(:avis, confidentiel: confidentiel, email: expert.email) }
before do
assign(:avis, avis)
@dossier = create(:dossier, :accepte)
assign(:new_avis, Avis.new)
assign(:dossier, avis.dossier)
allow(view).to receive(:current_instructeur).and_return(avis.instructeur)
end