Time.now => Time.zone.now
This commit is contained in:
parent
13ffa61435
commit
2238e5bd9f
21 changed files with 55 additions and 55 deletions
|
@ -13,7 +13,7 @@ module NewUser
|
|||
.select("procedures.*, COUNT(*) AS procedures_count")
|
||||
.joins(:dossiers)
|
||||
.publiees
|
||||
.where(dossiers: { created_at: 7.days.ago..Time.now })
|
||||
.where(dossiers: { created_at: 7.days.ago..Time.zone.now })
|
||||
.group("procedures.id")
|
||||
.order("procedures_count DESC")
|
||||
.limit(5)
|
||||
|
|
|
@ -82,7 +82,7 @@ class StatsController < ApplicationController
|
|||
|
||||
def procedures_numbers(procedures)
|
||||
total = procedures.count
|
||||
last_30_days_count = procedures.where(published_at: 1.month.ago..Time.now).count
|
||||
last_30_days_count = procedures.where(published_at: 1.month.ago..Time.zone.now).count
|
||||
previous_count = procedures.where(published_at: 2.months.ago..1.month.ago).count
|
||||
if previous_count != 0
|
||||
evolution = (((last_30_days_count.to_f / previous_count) - 1) * 100).round(0)
|
||||
|
@ -100,7 +100,7 @@ class StatsController < ApplicationController
|
|||
|
||||
def dossiers_numbers(dossiers)
|
||||
total = dossiers.count
|
||||
last_30_days_count = dossiers.where(en_construction_at: 1.month.ago..Time.now).count
|
||||
last_30_days_count = dossiers.where(en_construction_at: 1.month.ago..Time.zone.now).count
|
||||
previous_count = dossiers.where(en_construction_at: 2.months.ago..1.month.ago).count
|
||||
if previous_count != 0
|
||||
evolution = (((last_30_days_count.to_f / previous_count) - 1) * 100).round(0)
|
||||
|
@ -178,9 +178,9 @@ class StatsController < ApplicationController
|
|||
|
||||
def max_date
|
||||
if administration_signed_in?
|
||||
Time.now.to_date
|
||||
Time.zone.now.to_date
|
||||
else
|
||||
Time.now.beginning_of_month - 1.second
|
||||
Time.zone.now.beginning_of_month - 1.second
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -232,7 +232,7 @@ class StatsController < ApplicationController
|
|||
# and then computing the average for all the procedures
|
||||
|
||||
min_date = 11.months.ago
|
||||
max_date = Time.now.to_date
|
||||
max_date = Time.zone.now.to_date
|
||||
|
||||
processed_dossiers = dossiers
|
||||
.where(:processed_at => min_date..max_date)
|
||||
|
@ -273,7 +273,7 @@ class StatsController < ApplicationController
|
|||
# for a 24 champs form (the current form mean length)
|
||||
|
||||
min_date = 11.months.ago
|
||||
max_date = Time.now.to_date
|
||||
max_date = Time.zone.now.to_date
|
||||
|
||||
processed_dossiers = dossiers
|
||||
.where(:processed_at => min_date..max_date)
|
||||
|
|
|
@ -13,7 +13,7 @@ class AntiVirusJob < ApplicationJob
|
|||
else
|
||||
status = VirusScan.statuses.fetch(:infected)
|
||||
end
|
||||
virus_scan.update(scanned_at: Time.now, status: status)
|
||||
virus_scan.update(scanned_at: Time.zone.now, status: status)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class ApplicationJob < ActiveJob::Base
|
||||
before_perform do |job|
|
||||
Rails.logger.info("#{job.class.name} started at #{Time.now}")
|
||||
Rails.logger.info("#{job.class.name} started at #{Time.zone.now}")
|
||||
end
|
||||
|
||||
after_perform do |job|
|
||||
Rails.logger.info("#{job.class.name} ended at #{Time.now}")
|
||||
Rails.logger.info("#{job.class.name} ended at #{Time.zone.now}")
|
||||
end
|
||||
|
||||
def error(job, exception)
|
||||
|
|
|
@ -79,7 +79,7 @@ class AttestationTemplate < ApplicationRecord
|
|||
body: replace_tags(body, dossier),
|
||||
signature: signature,
|
||||
footer: footer,
|
||||
created_at: Time.now)
|
||||
created_at: Time.zone.now)
|
||||
|
||||
attestation_view = action_view.render(file: 'admin/attestation_templates/show',
|
||||
formats: [:pdf])
|
||||
|
|
|
@ -275,7 +275,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def delete_and_keep_track
|
||||
now = Time.now
|
||||
now = Time.zone.now
|
||||
deleted_dossier = DeletedDossier.create!(dossier_id: id, procedure: procedure, state: state, deleted_at: now)
|
||||
update(hidden_at: now)
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ class Procedure < ApplicationRecord
|
|||
|
||||
def export_filename
|
||||
procedure_identifier = path || "procedure-#{id}"
|
||||
"dossiers_#{procedure_identifier}_#{Time.now.strftime('%Y-%m-%d_%H-%M')}"
|
||||
"dossiers_#{procedure_identifier}_#{Time.zone.now.strftime('%Y-%m-%d_%H-%M')}"
|
||||
end
|
||||
|
||||
def generate_export
|
||||
|
@ -344,24 +344,24 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
|
||||
def after_publish(path)
|
||||
update!(published_at: Time.now)
|
||||
update!(published_at: Time.zone.now)
|
||||
|
||||
publish_with_path!(path)
|
||||
end
|
||||
|
||||
def after_archive
|
||||
update!(archived_at: Time.now, path: nil)
|
||||
update!(archived_at: Time.zone.now, path: nil)
|
||||
end
|
||||
|
||||
def after_hide
|
||||
now = Time.now
|
||||
now = Time.zone.now
|
||||
update!(hidden_at: now, path: nil)
|
||||
procedure_path&.hide!
|
||||
dossiers.update_all(hidden_at: now)
|
||||
end
|
||||
|
||||
def after_reopen(path)
|
||||
update!(published_at: Time.now, archived_at: nil)
|
||||
update!(published_at: Time.zone.now, archived_at: nil)
|
||||
|
||||
publish_with_path!(path)
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#footer
|
||||
%p{ class: "copyright col-md-push-#{12-main_container_size} col-md-#{main_container_size} col-lg-push-#{12-main_container_size} col-lg-#{main_container_size} text-muted small" }
|
||||
= link_to 'DINSIC', "http://etatplateforme.modernisation.gouv.fr"
|
||||
= Time.now.year
|
||||
= Time.zone.now.year
|
||||
\-
|
||||
= link_to 'Nouveautés', 'https://github.com/betagouv/tps/releases', target: '_blank'
|
||||
\-
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class AddTimeStampToDossier < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :dossiers, :created_at, :datetime, default: Time.now
|
||||
add_column :dossiers, :updated_at, :datetime, default: Time.now
|
||||
add_column :dossiers, :created_at, :datetime, default: Time.zone.now
|
||||
add_column :dossiers, :updated_at, :datetime, default: Time.zone.now
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Cellar
|
|||
end
|
||||
|
||||
def sign(request, key)
|
||||
date = Time.now.httpdate
|
||||
date = Time.zone.now.httpdate
|
||||
sig = signature(
|
||||
method: request.method,
|
||||
key: key,
|
||||
|
|
|
@ -16,12 +16,12 @@ namespace :'2018_09_12_fix_templates' do
|
|||
|
||||
dossiers_with_invalid_template_ids = Dossier
|
||||
.where(procedure_id: invalid_procedures_ids)
|
||||
.where(processed_at: DEPLOY_DATETIME..Time.now)
|
||||
.where(processed_at: DEPLOY_DATETIME..Time.zone.now)
|
||||
.pluck(:id)
|
||||
|
||||
Attestation
|
||||
.includes(:dossier)
|
||||
.where(created_at: DEPLOY_DATETIME..Time.now)
|
||||
.where(created_at: DEPLOY_DATETIME..Time.zone.now)
|
||||
.where(dossier_id: dossiers_with_invalid_template_ids)
|
||||
.map(&:dossier)
|
||||
end
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace :cloudstorage do
|
|||
|
||||
@cont.objects_detail.each { |object, details|
|
||||
last_modified = DateTime.parse(details[:last_modified])
|
||||
@cont.delete_object(object) if last_modified.utc <= (Time.now - 2.years).utc
|
||||
@cont.delete_object(object) if last_modified.utc <= (Time.zone.now - 2.years).utc
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ describe Admin::AttestationTemplatesController, type: :controller do
|
|||
|
||||
before do
|
||||
sign_in admin
|
||||
Timecop.freeze(Time.now)
|
||||
Timecop.freeze(Time.zone.now)
|
||||
end
|
||||
|
||||
after { Timecop.return }
|
||||
|
|
|
@ -96,8 +96,8 @@ describe Admin::ProceduresController, type: :controller do
|
|||
|
||||
describe 'DELETE #destroy' do
|
||||
let(:procedure_draft) { create :procedure, administrateur: admin, published_at: nil, archived_at: nil }
|
||||
let(:procedure_published) { create :procedure, administrateur: admin, aasm_state: :publiee, published_at: Time.now, archived_at: nil }
|
||||
let(:procedure_archived) { create :procedure, administrateur: admin, aasm_state: :archivee, published_at: nil, archived_at: Time.now }
|
||||
let(:procedure_published) { create :procedure, administrateur: admin, aasm_state: :publiee, published_at: Time.zone.now, archived_at: nil }
|
||||
let(:procedure_archived) { create :procedure, administrateur: admin, aasm_state: :archivee, published_at: nil, archived_at: Time.zone.now }
|
||||
|
||||
subject { delete :destroy, params: { id: procedure.id } }
|
||||
|
||||
|
@ -164,7 +164,7 @@ describe Admin::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when procedure is published' do
|
||||
let(:published_at) { Time.now }
|
||||
let(:published_at) { Time.zone.now }
|
||||
it { is_expected.to have_http_status(:success) }
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ describe StatsController, type: :controller do
|
|||
FactoryBot.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago)
|
||||
FactoryBot.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago)
|
||||
FactoryBot.create(:procedure, :created_at => 2.months.ago, :updated_at => 31.days.ago)
|
||||
FactoryBot.create(:procedure, :created_at => 2.months.ago, :updated_at => Time.now)
|
||||
FactoryBot.create(:procedure, :created_at => 2.months.ago, :updated_at => Time.zone.now)
|
||||
@controller = StatsController.new
|
||||
|
||||
allow(@controller).to receive(:administration_signed_in?).and_return(false)
|
||||
|
@ -102,18 +102,18 @@ describe StatsController, type: :controller do
|
|||
|
||||
before do
|
||||
3.times do
|
||||
create(:procedure, published_at: Time.now, administrateur: administrateur_1)
|
||||
create(:procedure, published_at: Time.zone.now, administrateur: administrateur_1)
|
||||
end
|
||||
|
||||
2.times do
|
||||
create(:procedure, published_at: Time.now, administrateur: administrateur_2)
|
||||
create(:procedure, published_at: Time.zone.now, administrateur: administrateur_2)
|
||||
end
|
||||
|
||||
8.times do
|
||||
create(:procedure, published_at: Time.now, administrateur: administrateur_3)
|
||||
create(:procedure, published_at: Time.zone.now, administrateur: administrateur_3)
|
||||
end
|
||||
|
||||
create(:procedure, published_at: Time.now, administrateur: administrateur_4)
|
||||
create(:procedure, published_at: Time.zone.now, administrateur: administrateur_4)
|
||||
end
|
||||
|
||||
let(:association){ Procedure.all }
|
||||
|
@ -234,7 +234,7 @@ describe StatsController, type: :controller do
|
|||
let!(:avis_with_dossier) { create(:avis) }
|
||||
let!(:dossier2) { create(:dossier) }
|
||||
|
||||
before { Timecop.freeze(Time.now) }
|
||||
before { Timecop.freeze(Time.zone.now) }
|
||||
after { Timecop.return }
|
||||
|
||||
subject { StatsController.new.send(:avis_usage) }
|
||||
|
@ -244,7 +244,7 @@ describe StatsController, type: :controller do
|
|||
|
||||
describe "#avis_average_answer_time" do
|
||||
before do
|
||||
Timecop.freeze(Time.now)
|
||||
Timecop.freeze(Time.zone.now)
|
||||
|
||||
# 1 week ago
|
||||
create(:avis, answer: "voila ma réponse", created_at: 1.week.ago + 1.day, updated_at: 1.week.ago + 2.days) # 1 day
|
||||
|
@ -278,7 +278,7 @@ describe StatsController, type: :controller do
|
|||
|
||||
subject { StatsController.new.send(:avis_answer_percentages) }
|
||||
|
||||
before { Timecop.freeze(Time.now) }
|
||||
before { Timecop.freeze(Time.zone.now) }
|
||||
after { Timecop.return }
|
||||
|
||||
it { is_expected.to match [[3.weeks.ago.to_i, 0], [2.weeks.ago.to_i, 0], [1.week.ago.to_i, 66.67]] }
|
||||
|
@ -289,7 +289,7 @@ describe StatsController, type: :controller do
|
|||
let!(:dossier2) { create(:dossier, processed_at: 1.week.ago) }
|
||||
let!(:dossier3) { create(:dossier, processed_at: 1.week.ago) }
|
||||
|
||||
before { Timecop.freeze(Time.now) }
|
||||
before { Timecop.freeze(Time.zone.now) }
|
||||
after { Timecop.return }
|
||||
|
||||
subject { StatsController.new.send(:motivation_usage_dossier) }
|
||||
|
@ -303,7 +303,7 @@ describe StatsController, type: :controller do
|
|||
let!(:dossier2) { create(:dossier, processed_at: 1.week.ago) }
|
||||
let!(:dossier3) { create(:dossier, processed_at: 1.week.ago) }
|
||||
|
||||
before { Timecop.freeze(Time.now) }
|
||||
before { Timecop.freeze(Time.zone.now) }
|
||||
after { Timecop.return }
|
||||
|
||||
subject { StatsController.new.send(:motivation_usage_procedure) }
|
||||
|
@ -316,7 +316,7 @@ describe StatsController, type: :controller do
|
|||
let!(:procedure2) { create(:procedure, created_at: 2.weeks.ago) }
|
||||
let!(:procedure3) { create(:procedure, created_at: 2.weeks.ago, cloned_from_library: true) }
|
||||
|
||||
before { Timecop.freeze(Time.now) }
|
||||
before { Timecop.freeze(Time.zone.now) }
|
||||
after { Timecop.return }
|
||||
|
||||
subject { StatsController.new.send(:cloned_from_library_procedures_ratio) }
|
||||
|
|
|
@ -19,7 +19,7 @@ describe 'Dossier details:' do
|
|||
describe "the user can see the mean time they are expected to wait" do
|
||||
context "when the dossier is in construction" do
|
||||
before do
|
||||
other_dossier = create(:dossier, :accepte, :for_individual, procedure: procedure, en_construction_at: 10.days.ago, en_instruction_at: Time.now)
|
||||
other_dossier = create(:dossier, :accepte, :for_individual, procedure: procedure, en_construction_at: 10.days.ago, en_instruction_at: Time.zone.now)
|
||||
visit dossier_path(dossier)
|
||||
end
|
||||
|
||||
|
@ -30,7 +30,7 @@ describe 'Dossier details:' do
|
|||
let(:dossier) { create(:dossier, :en_instruction, :for_individual, :with_commentaires, user: user, procedure: procedure) }
|
||||
|
||||
before do
|
||||
other_dossier = create(:dossier, :accepte, :for_individual, procedure: procedure, en_instruction_at: 2.months.ago, processed_at: Time.now)
|
||||
other_dossier = create(:dossier, :accepte, :for_individual, procedure: procedure, en_instruction_at: 2.months.ago, processed_at: Time.zone.now)
|
||||
visit dossier_path(dossier)
|
||||
end
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ describe 'AmazonV2RequestSigner' do
|
|||
|
||||
before { request_signer.sign(subject, 'fichier') }
|
||||
|
||||
it { expect(subject['date']).to eq(Time.now.httpdate) }
|
||||
it { expect(subject['date']).to eq(Time.zone.now.httpdate) }
|
||||
it { expect(subject['authorization']).to eq('AWS AKIAJFTRSGRH3RXX6D5Q:nkvviwZYb1V9HDrKyJZmY3Z8sSA=') }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -115,7 +115,7 @@ describe AttestationTemplate, type: :model do
|
|||
before do
|
||||
@logo = File.open('spec/fixtures/files/white.png')
|
||||
@signature = File.open('spec/fixtures/files/black.png')
|
||||
Timecop.freeze(Time.now)
|
||||
Timecop.freeze(Time.zone.now)
|
||||
end
|
||||
|
||||
after do
|
||||
|
|
|
@ -32,7 +32,7 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
let(:etablissement) { create(:etablissement) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, individual: individual, etablissement: etablissement) }
|
||||
|
||||
before { Timecop.freeze(Time.now) }
|
||||
before { Timecop.freeze(Time.zone.now) }
|
||||
|
||||
subject { template_concern.send(:replace_tags, template, dossier) }
|
||||
|
||||
|
|
|
@ -491,7 +491,7 @@ describe Dossier do
|
|||
describe '#update_state_dates' do
|
||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
let(:dossier) { create(:dossier, state: state) }
|
||||
let(:beginning_of_day) { Time.now.beginning_of_day }
|
||||
let(:beginning_of_day) { Time.zone.now.beginning_of_day }
|
||||
|
||||
before { Timecop.freeze(beginning_of_day) }
|
||||
after { Timecop.return }
|
||||
|
|
|
@ -429,7 +429,7 @@ describe Procedure do
|
|||
|
||||
describe '#publish!' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:now) { Time.now.beginning_of_minute }
|
||||
let(:now) { Time.zone.now.beginning_of_minute }
|
||||
|
||||
before do
|
||||
Timecop.freeze(now)
|
||||
|
@ -446,8 +446,8 @@ describe Procedure do
|
|||
|
||||
describe "#brouillon?" do
|
||||
let(:procedure_brouillon) { Procedure.new() }
|
||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_at: Time.now) }
|
||||
let(:procedure_archivee) { Procedure.new(aasm_state: :archivee, published_at: Time.now, archived_at: Time.now) }
|
||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_at: Time.zone.now) }
|
||||
let(:procedure_archivee) { Procedure.new(aasm_state: :archivee, published_at: Time.zone.now, archived_at: Time.zone.now) }
|
||||
|
||||
it { expect(procedure_brouillon.brouillon?).to be_truthy }
|
||||
it { expect(procedure_publiee.brouillon?).to be_falsey }
|
||||
|
@ -456,8 +456,8 @@ describe Procedure do
|
|||
|
||||
describe "#publiee?" do
|
||||
let(:procedure_brouillon) { Procedure.new() }
|
||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_at: Time.now) }
|
||||
let(:procedure_archivee) { Procedure.new(aasm_state: :archivee, published_at: Time.now, archived_at: Time.now) }
|
||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_at: Time.zone.now) }
|
||||
let(:procedure_archivee) { Procedure.new(aasm_state: :archivee, published_at: Time.zone.now, archived_at: Time.zone.now) }
|
||||
|
||||
it { expect(procedure_brouillon.publiee?).to be_falsey }
|
||||
it { expect(procedure_publiee.publiee?).to be_truthy }
|
||||
|
@ -466,8 +466,8 @@ describe Procedure do
|
|||
|
||||
describe "#archivee?" do
|
||||
let(:procedure_brouillon) { Procedure.new() }
|
||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_at: Time.now) }
|
||||
let(:procedure_archivee) { Procedure.new(aasm_state: :archivee, published_at: Time.now, archived_at: Time.now) }
|
||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_at: Time.zone.now) }
|
||||
let(:procedure_archivee) { Procedure.new(aasm_state: :archivee, published_at: Time.zone.now, archived_at: Time.zone.now) }
|
||||
|
||||
it { expect(procedure_brouillon.archivee?).to be_falsey }
|
||||
it { expect(procedure_publiee.archivee?).to be_falsey }
|
||||
|
@ -476,8 +476,8 @@ describe Procedure do
|
|||
|
||||
describe "#publiee_ou_archivee?" do
|
||||
let(:procedure_brouillon) { Procedure.new() }
|
||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_at: Time.now) }
|
||||
let(:procedure_archivee) { Procedure.new(aasm_state: :archivee, published_at: Time.now, archived_at: Time.now) }
|
||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_at: Time.zone.now) }
|
||||
let(:procedure_archivee) { Procedure.new(aasm_state: :archivee, published_at: Time.zone.now, archived_at: Time.zone.now) }
|
||||
|
||||
it { expect(procedure_brouillon.publiee_ou_archivee?).to be_falsey }
|
||||
it { expect(procedure_publiee.publiee_ou_archivee?).to be_truthy }
|
||||
|
@ -487,7 +487,7 @@ describe Procedure do
|
|||
describe 'archive' do
|
||||
let(:procedure) { create(:procedure, :published) }
|
||||
let(:procedure_path) { ProcedurePath.find(procedure.procedure_path.id) }
|
||||
let(:now) { Time.now.beginning_of_minute }
|
||||
let(:now) { Time.zone.now.beginning_of_minute }
|
||||
before do
|
||||
Timecop.freeze(now)
|
||||
procedure.archive!
|
||||
|
|
Loading…
Reference in a new issue