Merge pull request #4540 from maatinito/issue/bad_closing_hour

Prise en compte des fuseaux horaires pour la fermeture des procédures
This commit is contained in:
LeSim 2019-11-26 16:56:19 +01:00 committed by GitHub
commit 44f28241c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 12 additions and 12 deletions

View file

@ -163,8 +163,8 @@ class StatsController < ApplicationController
def contact_percentage def contact_percentage
number_of_months = 13 number_of_months = 13
from = Date.today.prev_month(number_of_months) from = Time.zone.today.prev_month(number_of_months)
to = Date.today.prev_month to = Time.zone.today.prev_month
adapter = Helpscout::UserConversationsAdapter.new(from, to) adapter = Helpscout::UserConversationsAdapter.new(from, to)
if !adapter.can_fetch_reports? if !adapter.can_fetch_reports?

View file

@ -18,7 +18,7 @@ module CommentaireHelper
end end
def commentaire_date(commentaire) def commentaire_date(commentaire)
is_current_year = (commentaire.created_at.year == Date.current.year) is_current_year = (commentaire.created_at.year == Time.zone.today.year)
template = is_current_year ? :message_date : :message_date_with_year template = is_current_year ? :message_date : :message_date_with_year
I18n.l(commentaire.created_at, format: template) I18n.l(commentaire.created_at, format: template)
end end

View file

@ -2,7 +2,7 @@ class AutoArchiveProcedureJob < ApplicationJob
queue_as :cron queue_as :cron
def perform(*args) def perform(*args)
Procedure.publiees.where("auto_archive_on <= ?", Date.today).each do |procedure| Procedure.publiees.where("auto_archive_on <= ?", Time.zone.today).each do |procedure|
procedure procedure
.dossiers .dossiers
.state_en_construction .state_en_construction

View file

@ -35,7 +35,7 @@ class Helpscout::UserConversationsAdapter
end end
def fetch_productivity_report(year, month) def fetch_productivity_report(year, month)
if year == Date.today.year && month == Date.today.month if year == Time.zone.today.year && month == Time.zone.today.month
raise ArgumentError, 'The report for the current month will change in the future, and cannot be cached.' raise ArgumentError, 'The report for the current month will change in the future, and cannot be cached.'
end end

View file

@ -6,11 +6,11 @@ class Champs::DateChamp < Champ
end end
def to_s def to_s
value.present? ? I18n.l(Date.parse(value)) : "" value.present? ? I18n.l(Time.zone.parse(value), format: '%d %B %Y') : ""
end end
def for_tag def for_tag
value.present? ? I18n.l(Date.parse(value)) : "" value.present? ? I18n.l(Time.zone.parse(value), format: '%d %B %Y') : ""
end end
private private
@ -18,7 +18,7 @@ class Champs::DateChamp < Champ
def format_before_save def format_before_save
self.value = self.value =
begin begin
Date.parse(value).iso8601 Time.zone.parse(value).to_date.iso8601
rescue rescue
nil nil
end end

View file

@ -107,7 +107,7 @@ describe FranceConnect::ParticulierController, type: :controller do
before { subject } before { subject }
it { expect(stored_fci).to have_attributes(user_info.merge(birthdate: Date.parse(birthdate))) } it { expect(stored_fci).to have_attributes(user_info.merge(birthdate: Time.zone.parse(birthdate).to_datetime)) }
end end
it { is_expected.to redirect_to(root_path) } it { is_expected.to redirect_to(root_path) }

View file

@ -3,7 +3,7 @@ require 'rails_helper'
RSpec.describe AutoArchiveProcedureJob, type: :job do RSpec.describe AutoArchiveProcedureJob, type: :job do
let!(:procedure) { create(:procedure, :published, :with_instructeur, auto_archive_on: nil) } let!(:procedure) { create(:procedure, :published, :with_instructeur, auto_archive_on: nil) }
let!(:procedure_hier) { create(:procedure, :published, :with_instructeur, auto_archive_on: 1.day.ago) } let!(:procedure_hier) { create(:procedure, :published, :with_instructeur, auto_archive_on: 1.day.ago) }
let!(:procedure_aujourdhui) { create(:procedure, :published, :with_instructeur, auto_archive_on: Date.today) } let!(:procedure_aujourdhui) { create(:procedure, :published, :with_instructeur, auto_archive_on: Time.zone.today) }
let!(:procedure_demain) { create(:procedure, :published, :with_instructeur, auto_archive_on: 1.day.from_now) } let!(:procedure_demain) { create(:procedure, :published, :with_instructeur, auto_archive_on: 1.day.from_now) }
subject { AutoArchiveProcedureJob.new.perform } subject { AutoArchiveProcedureJob.new.perform }

View file

@ -4,7 +4,7 @@ describe BillSignatureService do
describe ".grouped_unsigned_operation_until" do describe ".grouped_unsigned_operation_until" do
subject { BillSignatureService.grouped_unsigned_operation_until(date).length } subject { BillSignatureService.grouped_unsigned_operation_until(date).length }
let(:date) { Date.today } let(:date) { Time.zone.today }
context "when operations of several days need to be signed" do context "when operations of several days need to be signed" do
before do before do

View file

@ -33,7 +33,7 @@ describe FranceConnectService do
expect(subject).to have_attributes({ expect(subject).to have_attributes({
given_name: given_name, given_name: given_name,
family_name: family_name, family_name: family_name,
birthdate: Date.parse(birthdate), birthdate: Time.zone.parse(birthdate).to_date,
birthplace: birthplace, birthplace: birthplace,
gender: gender, gender: gender,
email_france_connect: email, email_france_connect: email,