Merge branch 'staging'
This commit is contained in:
commit
48c7c03b6a
8 changed files with 64 additions and 8 deletions
|
@ -86,7 +86,8 @@ class Users::DossiersController < UsersController
|
||||||
end
|
end
|
||||||
rescue RestClient::ResourceNotFound, RestClient::BadRequest
|
rescue RestClient::ResourceNotFound, RestClient::BadRequest
|
||||||
errors_valid_siret
|
errors_valid_siret
|
||||||
|
rescue RestClient::ServiceUnavailable
|
||||||
|
render '/dossiers/degraded', formats: 'js'
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
flash.alert = t('errors.messages.dossier_not_found')
|
flash.alert = t('errors.messages.dossier_not_found')
|
||||||
redirect_to url_for users_dossiers_path
|
redirect_to url_for users_dossiers_path
|
||||||
|
|
|
@ -7,10 +7,14 @@ class DossierService
|
||||||
end
|
end
|
||||||
|
|
||||||
def dossier_informations!
|
def dossier_informations!
|
||||||
@entreprise_adapter = SIADE::EntrepriseAdapter.new(DossierService.siren @siret)
|
@entreprise_adapter = SIADE::EntrepriseAdapter.new(DossierService.siren @siret).to_params
|
||||||
|
|
||||||
if @entreprise_adapter.to_params.nil?
|
if @entreprise_adapter[:http_code] == 404
|
||||||
raise RestClient::ResourceNotFound
|
raise RestClient::ResourceNotFound
|
||||||
|
elsif @entreprise_adapter[:http_code] == 503 ||
|
||||||
|
@entreprise_adapter[:http_code] == 500 ||
|
||||||
|
@entreprise_adapter[:http_code] == 400
|
||||||
|
raise RestClient::ServiceUnavailable
|
||||||
end
|
end
|
||||||
|
|
||||||
@etablissement_adapter = SIADE::EtablissementAdapter.new(@siret)
|
@etablissement_adapter = SIADE::EtablissementAdapter.new(@siret)
|
||||||
|
@ -34,7 +38,6 @@ class DossierService
|
||||||
@dossier
|
@dossier
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.siren siret
|
def self.siren siret
|
||||||
siret[0..8]
|
siret[0..8]
|
||||||
end
|
end
|
||||||
|
|
13
app/views/dossiers/degraded.js.erb
Normal file
13
app/views/dossiers/degraded.js.erb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<% if flash.empty? %>
|
||||||
|
$('.row.etape.etape_2').hide(300, render_new_siret);
|
||||||
|
$('.row.etape.etape_2').slideDown(400, the_terms);
|
||||||
|
toggle_etape_1();
|
||||||
|
<% else %>
|
||||||
|
error_form_siret('<%= invalid_siret %>');
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% flash.clear %>
|
||||||
|
|
||||||
|
function render_new_siret(){
|
||||||
|
$('.row.etape.etape_2').html("<%= escape_javascript(render partial: '/dossiers/etapes/etape2_degraded', locals: { facade: @facade } ) %>");
|
||||||
|
}
|
1
app/views/dossiers/etapes/_etape2_degraded.html.haml
Normal file
1
app/views/dossiers/etapes/_etape2_degraded.html.haml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
= render partial: 'dossiers/etapes/etape_2/degraded'
|
23
app/views/dossiers/etapes/etape_2/_degraded.html.haml
Normal file
23
app/views/dossiers/etapes/etape_2/_degraded.html.haml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
.etape.etapes_menu.col-md-3.col-lg-3
|
||||||
|
%h3
|
||||||
|
Mes informations
|
||||||
|
%br
|
||||||
|
|
||||||
|
.etape.etapes_informations.col-md-9.col-lg-9
|
||||||
|
.row
|
||||||
|
#recap_info_entreprise
|
||||||
|
%h3.text-warning
|
||||||
|
INSEE Indisponible
|
||||||
|
|
||||||
|
%p
|
||||||
|
%b
|
||||||
|
Notre partenaire l'INSEE est actuellement indisponible. Nous ne pouvons donc pas récupérer les informations de votre entreprise. Une fois de retour, vos informations seront automatiquement ajoutées à votre dossier.
|
||||||
|
|
||||||
|
%br
|
||||||
|
= form_for @facade.dossier, url: { controller: '/users/dossiers', action: :update } do |f|
|
||||||
|
= f.hidden_field :id
|
||||||
|
%label{ style:'font-weight:normal' }
|
||||||
|
= f.check_box :autorisation_donnees
|
||||||
|
J'autorise les décideurs publics à vérifier les informations de mon organisation auprès des administrations concernées. Ces informations resteront strictement confidentielles.
|
||||||
|
%br
|
||||||
|
= f.submit 'Etape suivante', class: "btn btn btn-info", style: 'float:right', id: 'etape_suivante', disabled: :disabled
|
|
@ -4,9 +4,19 @@ class SIADE::EntrepriseAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def data_source
|
def data_source
|
||||||
@data_source ||= JSON.parse(SIADE::API.entreprise(@siren), symbolize_names: true)
|
@data_source ||= JSON.parse(SIADE::API.entreprise(@siren), symbolize_names: true).merge(http_code: 200)
|
||||||
rescue
|
rescue RestClient::ServiceUnavailable
|
||||||
@data_source = nil
|
@data_source = {http_code: 503}
|
||||||
|
rescue RestClient::ResourceNotFound
|
||||||
|
@data_source = {http_code: 404}
|
||||||
|
rescue RestClient::InternalServerError
|
||||||
|
@data_source = {http_code: 500}
|
||||||
|
rescue => e
|
||||||
|
if e.http_code == 400
|
||||||
|
@data_source = {http_code: 400}
|
||||||
|
else
|
||||||
|
@data_source = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_params
|
def to_params
|
||||||
|
@ -19,7 +29,7 @@ class SIADE::EntrepriseAdapter
|
||||||
|
|
||||||
params
|
params
|
||||||
rescue
|
rescue
|
||||||
nil
|
data_source
|
||||||
end
|
end
|
||||||
|
|
||||||
def attr_to_fetch
|
def attr_to_fetch
|
||||||
|
|
|
@ -15,6 +15,9 @@ describe SIADE::API do
|
||||||
it 'raises RestClient::ResourceNotFound' do
|
it 'raises RestClient::ResourceNotFound' do
|
||||||
expect { subject }.to raise_error(RestClient::ResourceNotFound)
|
expect { subject }.to raise_error(RestClient::ResourceNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it { expect(subject.http_code).to eq status }
|
||||||
|
|
||||||
end
|
end
|
||||||
context 'when siret exist' do
|
context 'when siret exist' do
|
||||||
let(:siren) { '418166096' }
|
let(:siren) { '418166096' }
|
||||||
|
|
|
@ -12,6 +12,8 @@ describe SIADE::EntrepriseAdapter do
|
||||||
expect(subject).to be_an_instance_of(Hash)
|
expect(subject).to be_an_instance_of(Hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it { expect(described_class.new('418166096').data_source[:http_code]).to eq 200 }
|
||||||
|
|
||||||
context 'Attributs Entreprises' do
|
context 'Attributs Entreprises' do
|
||||||
it 'L\'entreprise contient bien un siren' do
|
it 'L\'entreprise contient bien un siren' do
|
||||||
expect(subject[:siren]).to eq('418166096')
|
expect(subject[:siren]).to eq('418166096')
|
||||||
|
|
Loading…
Reference in a new issue