From 8c6733929910d63971365706e36b206a1a745970 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 17 Oct 2017 14:58:34 +0200 Subject: [PATCH] If date_publication is missing on rna_information, do not crash --- .../dossiers/_identite_entreprise.html.haml | 2 +- .../_identite_entreprise.html.haml_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 spec/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml_spec.rb diff --git a/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml b/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml index 0e090bac5..d3669980b 100644 --- a/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml +++ b/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml @@ -62,7 +62,7 @@ %td= entreprise.rna_information.date_creation.strftime("%d/%m/%Y") %tr %th Date de publication : - %td= entreprise.rna_information.date_publication.strftime("%d/%m/%Y") + %td= entreprise.rna_information.date_publication.try(:strftime, "%d/%m/%Y") %tr %th Date de déclaration : %td= entreprise.rna_information.date_declaration.strftime("%d/%m/%Y") diff --git a/spec/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml_spec.rb b/spec/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml_spec.rb new file mode 100644 index 000000000..73830217c --- /dev/null +++ b/spec/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml_spec.rb @@ -0,0 +1,16 @@ +describe 'new_gestionnaire/dossiers/identite_entreprise.html.haml', type: :view do + before { render 'new_gestionnaire/dossiers/identite_entreprise.html.haml', entreprise: entreprise } + + context "there is an association" do + let(:rna_information) { create(:rna_information) } + let(:entreprise) { rna_information.entreprise } + + context "date_publication is missing on rna" do + before { rna_information.update_attributes(date_publication: nil) } + + it "can render without error" do + expect(rendered).to include("Date de publication :") + end + end + end +end