From bd89688346c9a07f7ea3989c2639546694d1f7d8 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Fri, 16 Sep 2016 17:08:50 +0200 Subject: [PATCH] Fix test INSEE v2 get etablissement view --- app/assets/javascripts/dossiers.js | 7 ++++++- app/services/dossier_service.rb | 6 +++++- lib/siade/etablissement_adapter.rb | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/dossiers.js b/app/assets/javascripts/dossiers.js index 0307b5a63..e65a0da9e 100644 --- a/app/assets/javascripts/dossiers.js +++ b/app/assets/javascripts/dossiers.js @@ -23,7 +23,12 @@ function the_terms() { } function error_form_siret(invalid_siret){ - $("input[type='submit']").removeClass('btn-success').addClass('btn-danger').val('Erreur SIRET'); + setTimeout(function(){ + $("input[type='submit']").val('Erreur SIRET'); + }, 10); + + $("input[type='submit']").removeClass('btn-success').addClass('btn-danger'); + $("#dossier_siret").addClass('input-error').val(invalid_siret).on('input', reset_form_siret); } diff --git a/app/services/dossier_service.rb b/app/services/dossier_service.rb index e086c3657..01c1fc6a0 100644 --- a/app/services/dossier_service.rb +++ b/app/services/dossier_service.rb @@ -13,9 +13,13 @@ class DossierService raise RestClient::ResourceNotFound end - @dossier.create_entreprise(@entreprise_adapter.to_params) @etablissement_adapter = SIADE::EtablissementAdapter.new(@siret) + if @etablissement_adapter.to_params.nil? + raise RestClient::ResourceNotFound + end + + @dossier.create_entreprise(@entreprise_adapter.to_params) @dossier.create_etablissement(@etablissement_adapter.to_params) @rna_adapter = SIADE::RNAAdapter.new(@siret) diff --git a/lib/siade/etablissement_adapter.rb b/lib/siade/etablissement_adapter.rb index b03c3d821..72c0052e0 100644 --- a/lib/siade/etablissement_adapter.rb +++ b/lib/siade/etablissement_adapter.rb @@ -18,6 +18,8 @@ class SIADE::EtablissementAdapter params[k] = v if address_attribut_to_fetch.include?(k) end params + rescue + nil end def attr_to_fetch