From cebb197994a677b975a7f84efe448cdd133c0533 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 11 May 2017 12:46:42 +0200 Subject: [PATCH] Fix #171 : add localtime to a bunch of date --- app/models/concerns/mail_template_concern.rb | 2 +- app/models/dossier.rb | 2 +- app/views/admin/procedures/_informations.html.haml | 2 +- app/views/administrations/_list.html.haml | 2 +- app/views/dossiers/_infos_entreprise.html.haml | 2 +- ..._left_panel_backoffice_dossierscontroller_index.html.haml | 2 +- .../_left_panel_backoffice_dossierscontroller_show.html.haml | 2 +- spec/controllers/backoffice/dossiers_controller_spec.rb | 1 + spec/decorators/commentaire_decorator_spec.rb | 5 +++-- 9 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/models/concerns/mail_template_concern.rb b/app/models/concerns/mail_template_concern.rb index f5a41a156..f64de99d8 100644 --- a/app/models/concerns/mail_template_concern.rb +++ b/app/models/concerns/mail_template_concern.rb @@ -85,7 +85,7 @@ module MailTemplateConcern when :libelle_procedure dossier.procedure.libelle when :date_de_decision - dossier.processed_at.present? ? dossier.processed_at.strftime("%d/%m/%Y") : "" + dossier.processed_at.present? ? dossier.processed_at.localtime.strftime("%d/%m/%Y") : "" else '--BALISE_NON_RECONNUE--' end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index ed875bceb..c6eee566f 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -289,7 +289,7 @@ class Dossier < ActiveRecord::Base else parts = [ "Dossier déposé le ", - initiated_at.strftime("%d/%m/%Y"), + initiated_at.localtime.strftime("%d/%m/%Y"), " sur la procédure ", procedure.libelle, " gérée par l'organisme ", diff --git a/app/views/admin/procedures/_informations.html.haml b/app/views/admin/procedures/_informations.html.haml index 253ee6729..cb2c4aa2e 100644 --- a/app/views/admin/procedures/_informations.html.haml +++ b/app/views/admin/procedures/_informations.html.haml @@ -84,7 +84,7 @@ %h4 Options avancées %label{ for: :auto_archive_on } Archivage automatique le - = f.text_field :auto_archive_on, id: 'auto_archive_on', value: @procedure.auto_archive_on.try{ |d| d.strftime("%d-%m-%Y") }, data: { provide: 'datepicker', 'date-language' => 'fr', 'date-format' => 'dd/mm/yyyy' } + = f.text_field :auto_archive_on, id: 'auto_archive_on', value: @procedure.auto_archive_on.try{ |d| d.localtime.strftime("%d-%m-%Y") }, data: { provide: 'datepicker', 'date-language' => 'fr', 'date-format' => 'dd/mm/yyyy' } (à 00h00) %p.help-block %i.fa.fa-info-circle diff --git a/app/views/administrations/_list.html.haml b/app/views/administrations/_list.html.haml index 3af742c9c..171418756 100644 --- a/app/views/administrations/_list.html.haml +++ b/app/views/administrations/_list.html.haml @@ -15,7 +15,7 @@ - unless admin.last_sign_in_at.nil? = time_ago_in_words(l(admin.last_sign_in_at, format: "%d/%m/%Y %H:%M UTC +02:00")) ( - = admin.last_sign_in_at.to_date.strftime('%d/%m/%Y') + = admin.last_sign_in_at.to_date.localtime.strftime('%d/%m/%Y') ) %td = admin.procedures.where(published: true).count diff --git a/app/views/dossiers/_infos_entreprise.html.haml b/app/views/dossiers/_infos_entreprise.html.haml index 661634697..6594bffec 100644 --- a/app/views/dossiers/_infos_entreprise.html.haml +++ b/app/views/dossiers/_infos_entreprise.html.haml @@ -24,7 +24,7 @@ .col-xs-8.entreprise-info= @facade.etablissement.naf .row .col-xs-4.entreprise-label Date de création : - .col-xs-8.entreprise-info= Time.at(@facade.entreprise.date_creation).strftime "%d-%m-%Y" + .col-xs-8.entreprise-info= Time.at(@facade.entreprise.date_creation).localtime.strftime "%d-%m-%Y" .row .col-xs-4.entreprise-label Effectif organisation : .col-xs-8.entreprise-info= @facade.entreprise.effectif diff --git a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml index 5d6e6c9d7..cdbc2b329 100644 --- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml +++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml @@ -40,5 +40,5 @@ = link_to backoffice_dossier_path(dossier.id) do .notification .dossier-index= "Dossier nº #{dossier.id}" - .updated-at-index= dossier.first_unread_notification.created_at.strftime('%d/%m %H:%M') + .updated-at-index= dossier.first_unread_notification.created_at.localtime.strftime('%d/%m %H:%M') .count= dossier.unreaded_notifications.count diff --git a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml index 8ffd1196e..ccc0aaa36 100644 --- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml +++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml @@ -45,7 +45,7 @@ %i.fa.fa-bell-o - @facade.last_notifications.each do |notification| .notification - .updated-at= notification.updated_at.strftime('%d/%m/%Y %H:%M') + .updated-at= notification.updated_at.localtime.strftime('%d/%m/%Y %H:%M') = render partial: "layouts/left_panels/type_notif_fa", locals: { notification: notification } - if ['champs'].include?(notification.type_notif) - if notification.liste.size > 1 diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 7ba92db57..91f0b7173 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -188,6 +188,7 @@ describe Backoffice::DossiersController, type: :controller do end it 'returns nothing' do + expect(assigns(:dossiers).count).to eq(0) end end diff --git a/spec/decorators/commentaire_decorator_spec.rb b/spec/decorators/commentaire_decorator_spec.rb index 5a6cc6231..06b821416 100644 --- a/spec/decorators/commentaire_decorator_spec.rb +++ b/spec/decorators/commentaire_decorator_spec.rb @@ -1,14 +1,15 @@ require 'spec_helper' describe CommentaireDecorator do - let(:commentaire) { Timecop.freeze(Time.utc(2008, 9, 1, 10, 5, 0)) {create :commentaire} } + let(:time) { Time.utc(2008, 9, 1, 10, 5, 0) } + let(:commentaire) { Timecop.freeze(time) { create :commentaire } } let(:decorator) { commentaire.decorate } describe 'created_at_fr' do subject { decorator.created_at_fr } context 'when created_at have a value' do - it { is_expected.to eq '01/09/2008 - 10:05' } + it { is_expected.to eq time.localtime.strftime('%d/%m/%Y - %H:%M') } end end end