diff --git a/app/decorators/dossier_decorator.rb b/app/decorators/dossier_decorator.rb index 53fd8a718..e39477d51 100644 --- a/app/decorators/dossier_decorator.rb +++ b/app/decorators/dossier_decorator.rb @@ -2,7 +2,7 @@ class DossierDecorator < Draper::Decorator delegate :current_page, :per_page, :offset, :total_entries, :total_pages delegate_all - def date_fr + def display_date date_previsionnelle.to_date.strftime('%d/%m/%Y') rescue 'dd/mm/YYYY' @@ -12,7 +12,7 @@ class DossierDecorator < Draper::Decorator updated_at.localtime.strftime('%d/%m/%Y %H:%M') end - def state_fr + def display_state DossierDecorator.case_state_fr state end @@ -27,23 +27,6 @@ class DossierDecorator < Draper::Decorator end def self.case_state_fr state=self.state - case state - when 'draft' - 'Brouillon' - when 'initiated' - 'Soumis' - when 'replied' - 'Répondu' - when 'updated' - 'Mis à jour' - when 'validated' - 'Validé' - when 'submitted' - 'Déposé' - when 'closed' - 'Traité' - else - fail 'State not valid' - end + h.t("activerecord.attributes.dossier.state.#{state}") end end diff --git a/app/views/admin/procedures/show.html.haml b/app/views/admin/procedures/show.html.haml index 3cffe702b..d41e6b199 100644 --- a/app/views/admin/procedures/show.html.haml +++ b/app/views/admin/procedures/show.html.haml @@ -73,7 +73,7 @@ %ul - @facade.dossiers_archived_by_state_total.each do |dossier| %li - = dossier.state_fr + = dossier.display_state \: = dossier.total - else diff --git a/app/views/backoffice/dossiers/_list.html.haml b/app/views/backoffice/dossiers/_list.html.haml index 786d6f70f..0aaed6c52 100644 --- a/app/views/backoffice/dossiers/_list.html.haml +++ b/app/views/backoffice/dossiers/_list.html.haml @@ -9,7 +9,7 @@ %td= dossier.procedure.libelle %td = link_to(dossier.nom_projet, "/backoffice/dossiers/#{dossier.id}") - %td= dossier.state_fr + %td= dossier.display_state %td= dossier.last_update .pagination diff --git a/app/views/backoffice/dossiers/search.html.haml b/app/views/backoffice/dossiers/search.html.haml index 9b92de0ad..d55850ae2 100644 --- a/app/views/backoffice/dossiers/search.html.haml +++ b/app/views/backoffice/dossiers/search.html.haml @@ -19,7 +19,7 @@ %td.col-md-2.col-lg-2 = @dossier.etablissement.siret %td.col-md-1.col-lg-1{class: @dossier.state_color_class} - = @dossier.state_fr + = @dossier.display_state %br - if @dossiers_search.empty? && @dossier.nil? @@ -44,7 +44,7 @@ %td= dossier.entreprise.raison_sociale %td= dossier.user.email %td= dossier.etablissement.siret - %td{class: dossier.state_color_class}= dossier.state_fr + %td{class: dossier.state_color_class}= dossier.display_state .pagination = will_paginate @dossiers_search, renderer: BootstrapPagination::Rails \ No newline at end of file diff --git a/app/views/backoffice/dossiers/show.html.haml b/app/views/backoffice/dossiers/show.html.haml index 6b0ea506e..fbac06342 100644 --- a/app/views/backoffice/dossiers/show.html.haml +++ b/app/views/backoffice/dossiers/show.html.haml @@ -3,7 +3,7 @@ = "Dossier n°#{@facade.dossier.id}" %h3{:class => 'text-success', :style => 'text-align:right'} - = @facade.dossier.state_fr + = @facade.dossier.display_state = render partial: '/dossiers/infos_entreprise' diff --git a/app/views/users/dossiers/_list.html.haml b/app/views/users/dossiers/_list.html.haml index b2842eafe..7ae47cb38 100644 --- a/app/views/users/dossiers/_list.html.haml +++ b/app/views/users/dossiers/_list.html.haml @@ -10,7 +10,7 @@ = dossier.procedure.libelle %td = link_to(dossier.nom_projet, users_dossier_recapitulatif_path(dossier)) - %td{id: "dossier_#{dossier.id}_state"}= dossier.state_fr + %td{id: "dossier_#{dossier.id}_state"}= dossier.display_state %td= dossier.last_update .pagination diff --git a/app/views/users/recapitulatif/show.html.haml b/app/views/users/recapitulatif/show.html.haml index ac396b3d9..15d51d543 100644 --- a/app/views/users/recapitulatif/show.html.haml +++ b/app/views/users/recapitulatif/show.html.haml @@ -30,7 +30,7 @@ = 'Déposer mon dossier' -else %h3{:class => 'text-success', :style => 'text-align:right'} - = @facade.dossier.state_fr + = @facade.dossier.display_state %br diff --git a/config/locales/models/dossier/fr.yml b/config/locales/models/dossier/fr.yml index 56faa910b..37b811618 100644 --- a/config/locales/models/dossier/fr.yml +++ b/config/locales/models/dossier/fr.yml @@ -9,6 +9,15 @@ fr: montant_projet: 'Le montant du projet' montant_aide_demande: "Le montant d'aide demandée" date_previsionnelle: "La date de début prévisionnelle" + state: + draft: "Brouillon" + initiated: "Soumis" + replied: "Répondu" + updated: "Mis à jour" + validated: "Validé" + submitted: "Déposé" + closed: "Traité" + errors: models: dossier: diff --git a/spec/decorators/dossier_decorator_spec.rb b/spec/decorators/dossier_decorator_spec.rb index 38bad1cf0..202c9f788 100644 --- a/spec/decorators/dossier_decorator_spec.rb +++ b/spec/decorators/dossier_decorator_spec.rb @@ -10,7 +10,7 @@ describe DossierDecorator do end describe 'state_fr' do - subject{ super().state_fr } + subject{ super().display_state } it 'draft is brouillon' do dossier.draft! diff --git a/spec/lib/siade/api_spec.rb b/spec/lib/siade/api_spec.rb index 800492b11..090dc3bdf 100644 --- a/spec/lib/siade/api_spec.rb +++ b/spec/lib/siade/api_spec.rb @@ -109,9 +109,7 @@ describe SIADE::API do let(:status) { 200 } let(:body) { File.read('spec/support/files/rna.json') } - it 'raises RestClient::Unauthorized' do - expect(subject).to eq(body) - end + it{ expect(subject).to eq(body) } end end end diff --git a/spec/lib/siade/rna_adapter_spec.rb b/spec/lib/siade/rna_adapter_spec.rb index dfbaf8d19..e9bb306f0 100644 --- a/spec/lib/siade/rna_adapter_spec.rb +++ b/spec/lib/siade/rna_adapter_spec.rb @@ -4,6 +4,7 @@ describe SIADE::RNAAdapter do let(:siret) { '50480511000013' } let(:body) { File.read('spec/support/files/rna.json') } let(:status) { 200 } + subject { described_class.new(siret).to_params } before do @@ -15,36 +16,23 @@ describe SIADE::RNAAdapter do let(:siret) { '234567' } let(:body) { '' } let(:status) { '404' } + it { is_expected.to eq(nil) } end - it '#to_params class est une Hash ?' do - expect(subject).to be_an_instance_of(Hash) - end + it { expect(subject).to be_an_instance_of(Hash) } - context 'Attributs Associations' do - it 'L\'associations contient bien un id' do - expect(subject[:association_id]).to eq('W595001988') - end + describe 'Attributs Associations' do + it { expect(subject[:association_id]).to eq('W595001988') } - it 'L\'associations contient bien un titre' do - expect(subject[:titre]).to eq('UN SUR QUATRE') - end + it { expect(subject[:titre]).to eq('UN SUR QUATRE') } - it 'L\'associations contient bien un objet' do - expect(subject[:objet]).to eq("valoriser, transmettre et partager auprès des publics les plus larges possibles, les bienfaits de l'immigration, la richesse de la diversité et la curiosité de l'autre autrement") - end + it { expect(subject[:objet]).to eq("valoriser, transmettre et partager auprès des publics les plus larges possibles, les bienfaits de l'immigration, la richesse de la diversité et la curiosité de l'autre autrement") } - it 'L\'associations contient bien une date de creation' do - expect(subject[:date_creation]).to eq('2014-01-23') - end + it { expect(subject[:date_creation]).to eq('2014-01-23') } - it 'L\'associations contient bien une date de de declaration' do - expect(subject[:date_declaration]).to eq('2014-01-24') - end + it { expect(subject[:date_declaration]).to eq('2014-01-24') } - it 'L\'associations contient bien une date de publication' do - expect(subject[:date_publication]).to eq('2014-02-08') - end + it { expect(subject[:date_publication]).to eq('2014-02-08') } end end diff --git a/spec/views/backoffice/dossiers/index_html.haml_spec.rb b/spec/views/backoffice/dossiers/index_html.haml_spec.rb index 7e29d3014..8137df6be 100644 --- a/spec/views/backoffice/dossiers/index_html.haml_spec.rb +++ b/spec/views/backoffice/dossiers/index_html.haml_spec.rb @@ -22,7 +22,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do it { is_expected.to have_css('#backoffice_index') } it { is_expected.to have_content(procedure.libelle) } it { is_expected.to have_content(decorate_dossier_initiated.nom_projet) } - it { is_expected.to have_content(decorate_dossier_initiated.state_fr) } + it { is_expected.to have_content(decorate_dossier_initiated.display_state) } it { is_expected.to have_content(decorate_dossier_initiated.last_update) } it { is_expected.not_to have_content(decorate_dossier_replied.nom_projet) } @@ -47,7 +47,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do it { is_expected.to have_css('#backoffice_index') } it { is_expected.to have_content(procedure.libelle) } it { is_expected.to have_content(decorate_dossier_replied.nom_projet) } - it { is_expected.to have_content(decorate_dossier_replied.state_fr) } + it { is_expected.to have_content(decorate_dossier_replied.display_state) } it { is_expected.to have_content(decorate_dossier_replied.last_update) } it { is_expected.not_to have_content(decorate_dossier_initiated.nom_projet) } @@ -70,7 +70,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do it { is_expected.to have_css('#backoffice_index') } it { is_expected.to have_content(procedure.libelle) } it { is_expected.to have_content(decorate_dossier_closed.nom_projet) } - it { is_expected.to have_content(decorate_dossier_closed.state_fr) } + it { is_expected.to have_content(decorate_dossier_closed.display_state) } it { is_expected.to have_content(decorate_dossier_closed.last_update) } it { is_expected.not_to have_content(decorate_dossier_initiated.nom_projet) } diff --git a/spec/views/users/dossiers/index_html.haml_spec.rb b/spec/views/users/dossiers/index_html.haml_spec.rb index 54cce502d..0462948f7 100644 --- a/spec/views/users/dossiers/index_html.haml_spec.rb +++ b/spec/views/users/dossiers/index_html.haml_spec.rb @@ -25,7 +25,7 @@ describe 'users/dossiers/index.html.haml', type: :view do describe 'dossier replied is present' do it { is_expected.to have_content(dossier_2.procedure.libelle) } it { is_expected.to have_content(dossier_2.nom_projet) } - it { is_expected.to have_content(dossier_2.state_fr) } + it { is_expected.to have_content(dossier_2.display_state) } it { is_expected.to have_content(dossier_2.last_update) } end @@ -53,7 +53,7 @@ describe 'users/dossiers/index.html.haml', type: :view do describe 'dossier initiated is present' do it { is_expected.to have_content(dossier.procedure.libelle) } it { is_expected.to have_content(dossier.nom_projet) } - it { is_expected.to have_content(dossier.state_fr) } + it { is_expected.to have_content(dossier.display_state) } it { is_expected.to have_content(dossier.last_update) } end @@ -81,7 +81,7 @@ describe 'users/dossiers/index.html.haml', type: :view do describe 'dossier termine is present' do it { is_expected.to have_content(dossier_termine.procedure.libelle) } it { is_expected.to have_content(dossier_termine.nom_projet) } - it { is_expected.to have_content(dossier_termine.state_fr) } + it { is_expected.to have_content(dossier_termine.display_state) } it { is_expected.to have_content(dossier_termine.last_update) } end