commit
783f2ef4e1
79 changed files with 223 additions and 203 deletions
|
@ -764,7 +764,7 @@ Rails/SkipsModelValidations:
|
|||
Enabled: false
|
||||
|
||||
Rails/TimeZone:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/UniqBeforePluck:
|
||||
Enabled: true
|
||||
|
|
2
Procfile
2
Procfile
|
@ -1,2 +1,2 @@
|
|||
server: bin/rails server
|
||||
server: bin/rails server -p 3000
|
||||
jobs: bin/delayed_job run
|
||||
|
|
|
@ -43,7 +43,7 @@ class Admin::AttestationTemplatesController < AdminController
|
|||
@title = activated_attestation_params[:title]
|
||||
@body = activated_attestation_params[:body]
|
||||
@footer = activated_attestation_params[:footer]
|
||||
@created_at = DateTime.now
|
||||
@created_at = Time.zone.now
|
||||
|
||||
# In a case of a preview, when the user does not change its images,
|
||||
# the images are not uploaded and thus should be retrieved from previous
|
||||
|
|
|
@ -52,7 +52,7 @@ class Admin::GestionnairesController < AdminController
|
|||
if User.exists?(email: @gestionnaire.email)
|
||||
GestionnaireMailer.user_to_gestionnaire(@gestionnaire.email).deliver_later
|
||||
else
|
||||
User.create(email: email, password: password, confirmed_at: DateTime.now)
|
||||
User.create(email: email, password: password, confirmed_at: Time.zone.now)
|
||||
end
|
||||
flash.notice = 'Instructeur ajouté'
|
||||
else
|
||||
|
|
|
@ -15,7 +15,7 @@ class FranceConnect::ParticulierController < ApplicationController
|
|||
if fci.user.nil?
|
||||
user = User.find_or_create_by(email: fci.email_france_connect) do |new_user|
|
||||
new_user.password = Devise.friendly_token[0, 20]
|
||||
new_user.confirmed_at = DateTime.now
|
||||
new_user.confirmed_at = Time.zone.now
|
||||
end
|
||||
|
||||
fci.update_attribute('user_id', user.id)
|
||||
|
|
|
@ -89,7 +89,7 @@ module NewGestionnaire
|
|||
if gestionnaire.save
|
||||
user = User.find_by(email: email)
|
||||
if user.blank?
|
||||
user = User.create(email: email, password: password, confirmed_at: DateTime.now)
|
||||
user = User.create(email: email, password: password, confirmed_at: Time.zone.now)
|
||||
end
|
||||
|
||||
sign_in(user)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -10,6 +10,7 @@ module NewUser
|
|||
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_brouillon, :modifier, :update]
|
||||
before_action :forbid_invite_submission!, only: [:update_brouillon]
|
||||
before_action :forbid_closed_submission!, only: [:update_brouillon]
|
||||
before_action :show_demarche_en_test_banner
|
||||
|
||||
def index
|
||||
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page)
|
||||
|
@ -211,6 +212,12 @@ module NewUser
|
|||
|
||||
private
|
||||
|
||||
def show_demarche_en_test_banner
|
||||
if @dossier.present? && @dossier.procedure.brouillon?
|
||||
flash.now.notice = "Ce dossier est déposé sur une démarche en test. Il sera supprimé lors de la publication de la démarche."
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_dossier_can_be_updated
|
||||
if !dossier.can_be_updated_by_the_user?
|
||||
flash.alert = 'Votre dossier ne peut plus être modifié'
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -24,7 +24,7 @@ class ChampDecorator < Draper::Decorator
|
|||
if type_champ == TypeDeChamp.type_champs.fetch(:date)
|
||||
object.value
|
||||
elsif type_champ == TypeDeChamp.type_champs.fetch(:datetime) && object.value != ' 00:00'
|
||||
DateTime.parse(object.value, "%Y-%m-%d %H:%M").strftime("%Y-%m-%d")
|
||||
Time.zone.strptime(object.value, "%Y-%m-%d %H:%M").strftime("%Y-%m-%d")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,11 +5,11 @@ class DossierDecorator < Draper::Decorator
|
|||
delegate_all
|
||||
|
||||
def first_creation
|
||||
created_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||
created_at.strftime('%d/%m/%Y %H:%M')
|
||||
end
|
||||
|
||||
def last_update
|
||||
updated_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||
updated_at.strftime('%d/%m/%Y %H:%M')
|
||||
end
|
||||
|
||||
def display_state
|
||||
|
|
|
@ -2,12 +2,12 @@ class ProcedureDecorator < Draper::Decorator
|
|||
delegate_all
|
||||
|
||||
def created_at_fr
|
||||
created_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||
created_at.strftime('%d/%m/%Y %H:%M')
|
||||
end
|
||||
|
||||
def published_at_fr
|
||||
if published_at.present?
|
||||
published_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||
published_at.strftime('%d/%m/%Y %H:%M')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ module CommentaireHelper
|
|||
def commentaire_date(commentaire)
|
||||
is_current_year = (commentaire.created_at.year == Date.current.year)
|
||||
template = is_current_year ? :message_date : :message_date_with_year
|
||||
I18n.l(commentaire.created_at.localtime, format: template)
|
||||
I18n.l(commentaire.created_at, format: template)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -7,14 +7,14 @@ class AutoReceiveDossiersForProcedureJob < ApplicationJob
|
|||
when Dossier.states.fetch(:en_instruction)
|
||||
procedure.dossiers.state_en_construction.update_all(
|
||||
state: Dossier.states.fetch(:en_instruction),
|
||||
en_instruction_at: DateTime.now
|
||||
en_instruction_at: Time.zone.now
|
||||
)
|
||||
when Dossier.states.fetch(:accepte)
|
||||
procedure.dossiers.state_en_construction.find_each do |dossier|
|
||||
dossier.update(
|
||||
state: Dossier.states.fetch(:accepte),
|
||||
en_instruction_at: DateTime.now,
|
||||
processed_at: DateTime.now
|
||||
en_instruction_at: Time.zone.now,
|
||||
processed_at: Time.zone.now
|
||||
)
|
||||
dossier.attestation = dossier.build_attestation
|
||||
dossier.save
|
||||
|
|
|
@ -10,7 +10,7 @@ class ApiEntreprise::EntrepriseAdapter < ApiEntreprise::Adapter
|
|||
params = data_source[:entreprise].slice(*attr_to_fetch)
|
||||
|
||||
if valid_params?(params)
|
||||
params[:date_creation] = Time.at(params[:date_creation]).to_datetime
|
||||
params[:date_creation] = Time.zone.at(params[:date_creation]).to_datetime
|
||||
params.transform_keys { |k| :"entreprise_#{k}" }
|
||||
else
|
||||
{}
|
||||
|
|
|
@ -22,7 +22,7 @@ class Administration < ApplicationRecord
|
|||
User.create({
|
||||
email: email,
|
||||
password: password,
|
||||
confirmed_at: DateTime.now
|
||||
confirmed_at: Time.zone.now
|
||||
})
|
||||
end
|
||||
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -25,12 +25,12 @@ class Champs::DatetimeChamp < Champ
|
|||
begin
|
||||
hash_date = YAML.safe_load(value.gsub('=>', ': '))
|
||||
year, month, day, hour, minute = hash_date.values_at(1,2,3,4,5)
|
||||
DateTime.new(year, month, day, hour, minute).strftime("%d/%m/%Y %H:%M")
|
||||
Time.zone.local(year, month, day, hour, minute).strftime("%d/%m/%Y %H:%M")
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
elsif /^\d{2}\/\d{2}\/\d{4}\s\d{2}:\d{2}$/.match?(value) # old browsers can send with dd/mm/yyyy hh:mm format
|
||||
self.value = DateTime.parse(value, "%d/%m/%Y %H:%M").strftime("%Y-%m-%d %H:%M")
|
||||
self.value = Time.zone.strptime(value, "%d/%m/%Y %H:%M").strftime("%Y-%m-%d %H:%M")
|
||||
elsif !(/^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}$/.match?(value)) # a datetime not correctly formatted should not be stored
|
||||
self.value = nil
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ class Commentaire < ApplicationRecord
|
|||
after_create :notify
|
||||
|
||||
def header
|
||||
"#{sender}, #{I18n.l(created_at.localtime, format: '%d %b %Y %H:%M')}"
|
||||
"#{sender}, #{I18n.l(created_at, format: '%d %b %Y %H:%M')}"
|
||||
end
|
||||
|
||||
def sender
|
||||
|
|
|
@ -126,7 +126,7 @@ module TagsSubstitutionConcern
|
|||
|
||||
def format_date(date)
|
||||
if date.present?
|
||||
date.localtime.strftime('%d/%m/%Y')
|
||||
date.strftime('%d/%m/%Y')
|
||||
else
|
||||
''
|
||||
end
|
||||
|
|
|
@ -180,7 +180,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def retention_expired?
|
||||
instruction_commencee? && retention_end_date <= DateTime.now
|
||||
instruction_commencee? && retention_end_date <= Time.zone.now
|
||||
end
|
||||
|
||||
def text_summary
|
||||
|
@ -194,7 +194,7 @@ class Dossier < ApplicationRecord
|
|||
else
|
||||
parts = [
|
||||
"Dossier déposé le ",
|
||||
en_construction_at.localtime.strftime("%d/%m/%Y"),
|
||||
en_construction_at.strftime("%d/%m/%Y"),
|
||||
" sur la démarche ",
|
||||
procedure.libelle,
|
||||
" gérée par l'organisme ",
|
||||
|
@ -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)
|
||||
|
||||
|
@ -309,11 +309,11 @@ class Dossier < ApplicationRecord
|
|||
|
||||
def update_state_dates
|
||||
if en_construction? && !self.en_construction_at
|
||||
self.en_construction_at = DateTime.now
|
||||
self.en_construction_at = Time.zone.now
|
||||
elsif en_instruction? && !self.en_instruction_at
|
||||
self.en_instruction_at = DateTime.now
|
||||
self.en_instruction_at = Time.zone.now
|
||||
elsif TERMINE.include?(state)
|
||||
self.processed_at = DateTime.now
|
||||
self.processed_at = Time.zone.now
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ class Follow < ApplicationRecord
|
|||
private
|
||||
|
||||
def set_default_date
|
||||
self.demande_seen_at ||= DateTime.now
|
||||
self.annotations_privees_seen_at ||= DateTime.now
|
||||
self.avis_seen_at ||= DateTime.now
|
||||
self.messagerie_seen_at ||= DateTime.now
|
||||
self.demande_seen_at ||= Time.zone.now
|
||||
self.annotations_privees_seen_at ||= Time.zone.now
|
||||
self.avis_seen_at ||= Time.zone.now
|
||||
self.messagerie_seen_at ||= Time.zone.now
|
||||
end
|
||||
end
|
||||
|
|
|
@ -64,7 +64,7 @@ class Gestionnaire < ApplicationRecord
|
|||
end
|
||||
|
||||
def last_week_overview
|
||||
start_date = DateTime.now.beginning_of_week
|
||||
start_date = Time.zone.now.beginning_of_week
|
||||
|
||||
active_procedure_overviews = procedures
|
||||
.publiees
|
||||
|
@ -180,7 +180,7 @@ class Gestionnaire < ApplicationRecord
|
|||
|
||||
def mark_tab_as_seen(dossier, tab)
|
||||
attributes = {}
|
||||
attributes["#{tab}_seen_at"] = DateTime.now
|
||||
attributes["#{tab}_seen_at"] = Time.zone.now
|
||||
Follow.where(gestionnaire: self, dossier: dossier).update_all(attributes)
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -305,7 +305,7 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
|
||||
def whitelist!
|
||||
update_attribute('whitelisted_at', DateTime.now)
|
||||
update_attribute('whitelisted_at', Time.zone.now)
|
||||
end
|
||||
|
||||
def closed_mail_template_attestation_inconsistency_state
|
||||
|
@ -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
|
||||
|
|
|
@ -24,7 +24,7 @@ class ProcedureOverview
|
|||
|
||||
@created_dossiers_count = procedure
|
||||
.dossiers
|
||||
.where(created_at: start_date..DateTime.now)
|
||||
.where(created_at: start_date..Time.zone.now)
|
||||
.state_not_brouillon
|
||||
.count
|
||||
end
|
||||
|
|
|
@ -111,8 +111,12 @@ class ProcedurePresentation < ApplicationRecord
|
|||
column = sanitized_column(filter)
|
||||
case table
|
||||
when 'self'
|
||||
date = filter['value'].to_date rescue nil
|
||||
dossiers.where("DATE_TRUNC('day', #{column}) = ?", date)
|
||||
date = Time.zone.parse(filter['value'])
|
||||
if date.present?
|
||||
dossiers.where("#{column} BETWEEN ? AND ?", date, date + 1.day)
|
||||
else
|
||||
[]
|
||||
end
|
||||
when 'type_de_champ', 'type_de_champ_private'
|
||||
relation = table == 'type_de_champ' ? :champs : :champs_private
|
||||
dossiers
|
||||
|
@ -186,7 +190,7 @@ class ProcedurePresentation < ApplicationRecord
|
|||
def get_value(dossier, table, column)
|
||||
case table
|
||||
when 'self'
|
||||
dossier.send(column)
|
||||
dossier.send(column)&.strftime('%d/%m/%Y')
|
||||
when 'user', 'individual', 'etablissement'
|
||||
dossier.send(table)&.send(column)
|
||||
when 'type_de_champ'
|
||||
|
|
|
@ -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'
|
||||
\-
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
%h2.claimant
|
||||
Demandeur :
|
||||
%span.email= @avis.claimant.email
|
||||
%span.date Demande d'avis envoyée le #{I18n.l(@avis.created_at.localtime, format: '%d/%m/%y')}
|
||||
%span.date Demande d'avis envoyée le #{I18n.l(@avis.created_at, format: '%d/%m/%y')}
|
||||
%p.introduction= @avis.introduction
|
||||
|
||||
= form_for @avis, url: gestionnaire_avis_path(@avis), html: { class: 'form' } do |f|
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
confidentiel
|
||||
%span.icon.lock{ title: "Cet avis n'est pas affiché avec les autres experts consultés" }
|
||||
%span.date{ class: highlight_if_unseen_class(avis_seen_at, avis.created_at) }
|
||||
Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y à %H:%M')}
|
||||
Demande d'avis envoyée le #{I18n.l(avis.created_at, format: '%d/%m/%y à %H:%M')}
|
||||
%p= avis.introduction
|
||||
|
||||
.answer.flex.align-start
|
||||
|
@ -25,7 +25,7 @@
|
|||
= (avis.email_to_display == current_gestionnaire.email) ? 'Vous' : avis.email_to_display
|
||||
- if avis.answer.present?
|
||||
%span.date{ class: highlight_if_unseen_class(avis_seen_at, avis.updated_at) }
|
||||
Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y à %H:%M')}
|
||||
Réponse donnée le #{I18n.l(avis.updated_at, format: '%d/%m/%y à %H:%M')}
|
||||
- else
|
||||
%span.waiting En attente de réponse
|
||||
%p= avis.answer
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
= render partial: 'shared/dossiers/status_badge', locals: { dossier: dossier }
|
||||
%td.updated-at-col
|
||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||
= dossier.updated_at.localtime.strftime("%d/%m/%Y")
|
||||
= dossier.updated_at.strftime("%d/%m/%Y")
|
||||
= paginate(@dossiers)
|
||||
|
||||
- if current_user.feedbacks.empty? || current_user.feedbacks.last.created_at < 1.month.ago
|
||||
|
|
|
@ -73,4 +73,4 @@
|
|||
%td.updated-at
|
||||
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
||||
modifié le
|
||||
= c.updated_at.localtime.strftime("%d/%m/%Y à %H:%M")
|
||||
= c.updated_at.strftime("%d/%m/%Y à %H:%M")
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
= link_to pj.content_url, { target: :blank } do
|
||||
%span.filename= display_pj_filename(pj)
|
||||
%span
|
||||
ajoutée le #{pj.created_at.localtime.strftime('%d/%m/%Y à %H:%M')}
|
||||
ajoutée le #{pj.created_at.strftime('%d/%m/%Y à %H:%M')}
|
||||
- else
|
||||
%td Pièce non fournie
|
||||
%td.updated-at
|
||||
- if pj
|
||||
%span{ class: highlight_if_unseen_class(demande_seen_at, pj.updated_at) }
|
||||
modifié le
|
||||
= pj.updated_at.localtime.strftime("%d/%m/%Y à %H:%M")
|
||||
= pj.updated_at.strftime("%d/%m/%Y à %H:%M")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- parsed_value = champ.value.present? ? DateTime.parse(champ.value) : DateTime.now
|
||||
- parsed_value = champ.value.present? ? Time.zone.parse(champ.value) : Time.zone.now
|
||||
|
||||
.datetime
|
||||
= form.datetime_select(:value, selected: parsed_value, start_year: 1950, end_year: 2100, minute_step: 5)
|
||||
|
|
|
@ -16,7 +16,7 @@ module TPS
|
|||
|
||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||
# config.time_zone = 'Central Time (US & Canada)'
|
||||
config.time_zone = 'Paris'
|
||||
|
||||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
||||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||
|
|
|
@ -8,7 +8,7 @@ HELPSCOUT_API_URL = "https://api.helpscout.net/v2"
|
|||
PIPEDRIVE_API_URL = "https://api.pipedrive.com/v1"
|
||||
|
||||
# Internal URLs
|
||||
FOG_BASE_URL = "https://storage.apientreprise.fr"
|
||||
FOG_BASE_URL = "https://static.demarches-simplifiees.fr"
|
||||
|
||||
# External services URLs
|
||||
DOC_URL = "https://doc.demarches-simplifiees.fr"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,7 +7,7 @@ class AddConfirmableToUserDevise < ActiveRecord::Migration[5.2]
|
|||
# User.reset_column_information # Need for some types of updates, but not for update_all.
|
||||
# To avoid a short time window between running the migration and updating all existing
|
||||
# users as confirmed, do the following
|
||||
User.all.update_all confirmed_at: DateTime.now
|
||||
User.all.update_all confirmed_at: Time.zone.now
|
||||
# All existing user accounts should be able to log in after this.
|
||||
end
|
||||
|
||||
|
|
|
@ -12,4 +12,4 @@ puts "Create test user '#{default_user}'"
|
|||
Administration.create!(email: default_user, password: default_password)
|
||||
Administrateur.create!(email: default_user, password: default_password)
|
||||
Gestionnaire.create!(email: default_user, password: default_password)
|
||||
User.create!(email: default_user, password: default_password, confirmed_at: DateTime.now)
|
||||
User.create!(email: default_user, password: default_password, confirmed_at: Time.zone.now)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace :'2017_12_05_initialize_timestamps_for_entreprises' do
|
|||
entreprise.update_columns(created_at: entreprise.dossier.created_at, updated_at: entreprise.dossier.created_at)
|
||||
else
|
||||
rake_puts "dossier #{entreprise.dossier_id} is missing for entreprise #{entreprise.id}"
|
||||
entreprise.update_columns(created_at: DateTime.now, updated_at: DateTime.now)
|
||||
entreprise.update_columns(created_at: Time.zone.now, updated_at: Time.zone.now)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace :'2018_01_18_clean_datetime_in_champs' do
|
|||
|
||||
# Match "dd/mm/YYYY HH:MM" => "YYYY-mm-dd HH:MM"
|
||||
datetime_champs.select { |c| /^\d{2}\/\d{2}\/\d{4}\s\d{2}:\d{2}$/ =~ c.value }.each do |c|
|
||||
formated_date = DateTime.parse(c.value, "%d/%m/%Y %H:%M").strftime("%Y-%m-%d %H:%M")
|
||||
formated_date = Time.zone.strptime(c.value, "%d/%m/%Y %H:%M").strftime("%Y-%m-%d %H:%M")
|
||||
rake_puts "cleaning #{c.value} => #{formated_date}"
|
||||
c.update_columns(value: formated_date)
|
||||
end
|
||||
|
|
|
@ -8,8 +8,8 @@ namespace :'2018_03_08_send_missing_accuse_reception' do
|
|||
# `bug_date` and `fix_date` were determined empirically by looking at the release times,
|
||||
# and checking for dossiers with a missing accusé de réception.
|
||||
|
||||
bug_date = DateTime.new(2018, 3, 1, 9, 50)
|
||||
fix_date = DateTime.new(2018, 3, 5, 18, 40)
|
||||
bug_date = Time.zone.local(2018, 3, 1, 9, 50)
|
||||
fix_date = Time.zone.local(2018, 3, 5, 18, 40)
|
||||
|
||||
# Only send the accusé for dossiers that are still en construction.
|
||||
# For dossiers that have moved on, other mails have been sent since, and a late
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace :'2018_05_30_missed_ar_messages' do
|
|||
end
|
||||
|
||||
def create_commentaires(date_name, template_name, dossiers = Dossier)
|
||||
error_range = DateTime.new(2018, 05, 28, 13, 33)..DateTime.new(2018, 05, 30, 15, 39)
|
||||
error_range = Time.zone.local(2018, 05, 28, 13, 33)..Time.zone.local(2018, 05, 30, 15, 39)
|
||||
|
||||
dossiers.includes(:procedure).where(date_name => error_range).find_each(batch_size: 100) do |dossier|
|
||||
print "#{dossier.id}\n"
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace :'2018_06_06_users_for_admins_and_gestionnaires' do
|
|||
User
|
||||
.joins("INNER JOIN #{table_name} ON #{table_name}.email = users.email")
|
||||
.where(confirmed_at: nil)
|
||||
.update_all(confirmed_at: DateTime.now)
|
||||
.update_all(confirmed_at: Time.zone.now)
|
||||
|
||||
rake_puts "Fixed #{count} #{table_name} with unconfirmed user"
|
||||
end
|
||||
|
|
|
@ -7,7 +7,11 @@ namespace :'2018_09_12_fix_templates' do
|
|||
end
|
||||
|
||||
# 16:15 in Paris -> 14:15 UTC
|
||||
DEPLOY_DATETIME = DateTime.new(2018, 9, 5, 14, 15, 0)
|
||||
|
||||
# rubocop:disable Rails/TimeZone
|
||||
# because we are in a ruby context so Time.zone = nil
|
||||
DEPLOY_DATETIME = Time.local(2018, 9, 5, 14, 15, 0)
|
||||
# rubocop:enable Rails/TimeZone
|
||||
|
||||
def find_dossiers_with_sent_and_invalid_attestations
|
||||
invalid_procedures_ids = AttestationTemplate
|
||||
|
@ -16,12 +20,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
|
||||
|
|
|
@ -104,8 +104,8 @@ namespace :cloudstorage do
|
|||
Rake::Task['cloudstorage:init'].invoke
|
||||
|
||||
@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
|
||||
last_modified = Time.zone.parse(details[:last_modified])
|
||||
@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 }
|
||||
|
@ -47,7 +47,7 @@ describe Admin::AttestationTemplatesController, type: :controller do
|
|||
|
||||
it { expect(subject.status).to eq(200) }
|
||||
it { expect(assigns).to include(upload_params.stringify_keys) }
|
||||
it { expect(assigns[:created_at]).to eq(DateTime.now) }
|
||||
it { expect(assigns[:created_at]).to eq(Time.zone.now) }
|
||||
it { expect(assigns(:logo).read).to eq(logo.read) }
|
||||
it { expect(assigns(:signature).read).to eq(signature.read) }
|
||||
after { procedure.attestation_template.destroy }
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ describe API::V1::DossiersController do
|
|||
|
||||
context 'when procedure is found and belongs to admin' do
|
||||
let(:procedure_id) { procedure.id }
|
||||
let(:date_creation) { Time.utc(2008, 9, 1, 10, 5, 0) }
|
||||
let(:date_creation) { Time.zone.local(2008, 9, 1, 10, 5, 0) }
|
||||
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :en_construction, procedure: procedure) } }
|
||||
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
||||
|
||||
|
@ -75,8 +75,8 @@ describe API::V1::DossiersController do
|
|||
describe 'dossier' do
|
||||
subject { super().first }
|
||||
it { expect(subject[:id]).to eq(dossier.id) }
|
||||
it { expect(subject[:updated_at]).to eq("2008-09-01T10:05:00.000Z") }
|
||||
it { expect(subject[:initiated_at]).to eq("2008-09-01T10:06:00.000Z") }
|
||||
it { expect(subject[:updated_at]).to eq("2008-09-01T10:05:00.000+02:00") }
|
||||
it { expect(subject[:initiated_at]).to eq("2008-09-01T10:06:00.000+02:00") }
|
||||
it { expect(subject[:state]).to eq("initiated") }
|
||||
it { expect(subject.keys.size).to eq(4) }
|
||||
end
|
||||
|
@ -135,7 +135,7 @@ describe API::V1::DossiersController do
|
|||
|
||||
context 'when dossier exists and belongs to procedure' do
|
||||
let(:procedure_id) { procedure.id }
|
||||
let(:date_creation) { Time.utc(2008, 9, 1, 10, 5, 0) }
|
||||
let(:date_creation) { Time.zone.local(2008, 9, 1, 10, 5, 0) }
|
||||
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, motivation: "Motivation") } }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
||||
|
@ -148,8 +148,8 @@ describe API::V1::DossiersController do
|
|||
|
||||
it { expect(subject[:id]).to eq(dossier.id) }
|
||||
it { expect(subject[:state]).to eq(dossier.state) }
|
||||
it { expect(subject[:created_at]).to eq('2008-09-01T10:05:00.000Z') }
|
||||
it { expect(subject[:updated_at]).to eq('2008-09-01T10:05:00.000Z') }
|
||||
it { expect(subject[:created_at]).to eq('2008-09-01T10:05:00.000+02:00') }
|
||||
it { expect(subject[:updated_at]).to eq('2008-09-01T10:05:00.000+02:00') }
|
||||
it { expect(subject[:archived]).to eq(dossier.archived) }
|
||||
|
||||
it { expect(subject.keys).to match_array(field_list) }
|
||||
|
@ -337,7 +337,7 @@ describe API::V1::DossiersController do
|
|||
it { expect(subject.size).to eq 2 }
|
||||
|
||||
it { expect(subject.first[:body]).to eq 'plop' }
|
||||
it { expect(subject.first[:created_at]).to eq '2016-03-14T14:00:00.000Z' }
|
||||
it { expect(subject.first[:created_at]).to eq '2016-03-14T14:00:00.000+01:00' }
|
||||
it { expect(subject.first[:email]).to eq 'plop@plip.com' }
|
||||
end
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ describe FranceConnect::ParticulierController, type: :controller do
|
|||
|
||||
before { subject }
|
||||
|
||||
it { expect(stored_fci).to have_attributes(user_info.merge(birthdate: DateTime.parse(birthdate))) }
|
||||
it { expect(stored_fci).to have_attributes(user_info.merge(birthdate: Date.parse(birthdate))) }
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to(root_path) }
|
||||
|
|
|
@ -250,11 +250,11 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
before do
|
||||
Timecop.freeze(DateTime.now)
|
||||
Timecop.freeze(Time.zone.now)
|
||||
|
||||
expect_any_instance_of(AttestationTemplate)
|
||||
.to receive(:attestation_for)
|
||||
.with(have_attributes(motivation: "Yallah", processed_at: DateTime.now))
|
||||
.with(have_attributes(motivation: "Yallah", processed_at: Time.zone.now))
|
||||
end
|
||||
|
||||
after { Timecop.return }
|
||||
|
|
|
@ -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)
|
||||
|
@ -53,7 +53,7 @@ describe StatsController, type: :controller do
|
|||
|
||||
describe '#cumulative_hash' do
|
||||
before do
|
||||
Timecop.freeze(Time.new(2016, 10, 2))
|
||||
Timecop.freeze(Time.zone.local(2016, 10, 2))
|
||||
FactoryBot.create(:procedure, :created_at => 55.days.ago, :updated_at => 43.days.ago)
|
||||
FactoryBot.create(:procedure, :created_at => 45.days.ago, :updated_at => 40.days.ago)
|
||||
FactoryBot.create(:procedure, :created_at => 45.days.ago, :updated_at => 20.days.ago)
|
||||
|
@ -72,9 +72,9 @@ describe StatsController, type: :controller do
|
|||
|
||||
it do
|
||||
expect(subject).to eq({
|
||||
2.months.ago.beginning_of_month => 2,
|
||||
1.month.ago.beginning_of_month => 4,
|
||||
1.hour.ago.beginning_of_month => 5
|
||||
Time.utc(2016, 8, 1) => 2,
|
||||
Time.utc(2016, 9, 1) => 4,
|
||||
Time.utc(2016, 10, 1) => 5
|
||||
})
|
||||
end
|
||||
end
|
||||
|
@ -86,8 +86,8 @@ describe StatsController, type: :controller do
|
|||
|
||||
it do
|
||||
expect(subject).to eq({
|
||||
2.months.ago.beginning_of_month => 2,
|
||||
1.month.ago.beginning_of_month => 4
|
||||
Time.utc(2016, 8, 1) => 2,
|
||||
Time.utc(2016, 9, 1) => 4
|
||||
})
|
||||
end
|
||||
end
|
||||
|
@ -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) }
|
||||
|
|
|
@ -57,7 +57,7 @@ describe Users::RegistrationsController, type: :controller do
|
|||
end
|
||||
|
||||
context 'and the user is confirmed' do
|
||||
let(:confirmed_at) { DateTime.now }
|
||||
let(:confirmed_at) { Time.zone.now }
|
||||
|
||||
before { subject }
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ require 'spec_helper'
|
|||
|
||||
describe DossierDecorator do
|
||||
let(:dossier) do
|
||||
dossier = create(:dossier, created_at: Time.new(2015, 12, 24, 14, 10))
|
||||
dossier.update_column('updated_at', Time.new(2015, 12, 24, 14, 10))
|
||||
dossier = create(:dossier, created_at: Time.zone.local(2015, 12, 24, 14, 10))
|
||||
dossier.update_column('updated_at', Time.zone.local(2015, 12, 24, 14, 10))
|
||||
dossier
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe ProcedureDecorator do
|
||||
let(:published_at) { Time.new(2017, 12, 24, 14, 12) }
|
||||
let(:procedure) { create(:procedure, published_at: published_at, created_at: Time.new(2015, 12, 24, 14, 10)) }
|
||||
let(:published_at) { Time.zone.local(2017, 12, 24, 14, 12) }
|
||||
let(:procedure) { create(:procedure, published_at: published_at, created_at: Time.zone.local(2015, 12, 24, 14, 10)) }
|
||||
let!(:procedure_path) { create(:procedure_path, administrateur: create(:administrateur), procedure: procedure) }
|
||||
|
||||
subject { procedure.decorate }
|
||||
|
|
|
@ -2,9 +2,9 @@ require 'spec_helper'
|
|||
|
||||
describe ProceduresDecorator do
|
||||
before do
|
||||
create(:procedure, :published, created_at: Time.new(2015, 12, 24, 14, 10))
|
||||
create(:procedure, :published, created_at: Time.new(2015, 12, 24, 14, 10))
|
||||
create(:procedure, :published, created_at: Time.new(2015, 12, 24, 14, 10))
|
||||
create(:procedure, :published, created_at: Time.zone.local(2015, 12, 24, 14, 10))
|
||||
create(:procedure, :published, created_at: Time.zone.local(2015, 12, 24, 14, 10))
|
||||
create(:procedure, :published, created_at: Time.zone.local(2015, 12, 24, 14, 10))
|
||||
end
|
||||
|
||||
let(:procedure) { Procedure.all.page(1) }
|
||||
|
|
|
@ -2,7 +2,7 @@ FactoryBot.define do
|
|||
factory :deleted_dossier do
|
||||
dossier_id { 1111 }
|
||||
state { Dossier.states.fetch(:en_construction) }
|
||||
deleted_at { DateTime.now }
|
||||
deleted_at { Time.zone.now }
|
||||
|
||||
association :procedure, :published
|
||||
end
|
||||
|
|
|
@ -155,7 +155,7 @@ FactoryBot.define do
|
|||
|
||||
trait :whitelisted do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
procedure.update(whitelisted_at: DateTime.now)
|
||||
procedure.update(whitelisted_at: Time.zone.now)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,6 +3,6 @@ FactoryBot.define do
|
|||
factory :user do
|
||||
email { generate(:user_email) }
|
||||
password { 'password' }
|
||||
confirmed_at { DateTime.now }
|
||||
confirmed_at { Time.zone.now }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ feature "procedure filters" do
|
|||
add_column("Créé le")
|
||||
within ".dossiers-table" do
|
||||
expect(page).to have_link("Créé le")
|
||||
expect(page).to have_link(new_unfollow_dossier.created_at)
|
||||
expect(page).to have_link(new_unfollow_dossier.created_at.strftime('%d/%m/%Y'))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ feature 'The user' do
|
|||
fill_in('text', with: 'super texte')
|
||||
fill_in('textarea', with: 'super textarea')
|
||||
fill_in('date', with: '12/12/2012')
|
||||
select_date_and_time(DateTime.parse('06/01/1985 7h05'), form_id_for('datetime'))
|
||||
select_date_and_time(Time.zone.parse('06/01/1985 7h05'), form_id_for('datetime'))
|
||||
fill_in('number', with: '42')
|
||||
check('checkbox')
|
||||
choose('Madame')
|
||||
|
@ -67,7 +67,7 @@ feature 'The user' do
|
|||
expect(page).to have_field('text', with: 'super texte')
|
||||
expect(page).to have_field('textarea', with: 'super textarea')
|
||||
expect(page).to have_field('date', with: '2012-12-12')
|
||||
check_date_and_time(DateTime.parse('06/01/1985 7:05'), form_id_for('datetime'))
|
||||
check_date_and_time(Time.zone.parse('06/01/1985 7:05'), form_id_for('datetime'))
|
||||
expect(page).to have_field('number', with: '42')
|
||||
expect(page).to have_checked_field('checkbox')
|
||||
expect(page).to have_checked_field('Madame')
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ RSpec.describe CommentaireHelper, type: :helper do
|
|||
end
|
||||
|
||||
describe '.commentaire_date' do
|
||||
let(:present_date) { Time.local(2018, 9, 2, 10, 5, 0) }
|
||||
let(:present_date) { Time.zone.local(2018, 9, 2, 10, 5, 0) }
|
||||
let(:creation_date) { present_date }
|
||||
let(:commentaire) do
|
||||
Timecop.freeze(creation_date) { create(:commentaire, email: "michel@pref.fr") }
|
||||
|
@ -71,7 +71,7 @@ RSpec.describe CommentaireHelper, type: :helper do
|
|||
end
|
||||
|
||||
context 'when formatting the first day of the month' do
|
||||
let(:present_date) { Time.local(2018, 9, 1, 10, 5, 0) }
|
||||
let(:present_date) { Time.zone.local(2018, 9, 1, 10, 5, 0) }
|
||||
it 'includes the ordinal' do
|
||||
expect(subject).to eq 'le 1er septembre à 10 h 05'
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe DossierHelper, type: :helper do
|
||||
describe ".highlight_if_unseen_class" do
|
||||
let(:seen_at) { DateTime.now }
|
||||
let(:seen_at) { Time.zone.now }
|
||||
|
||||
subject { highlight_if_unseen_class(seen_at, updated_at) }
|
||||
|
||||
|
@ -19,7 +19,7 @@ RSpec.describe DossierHelper, type: :helper do
|
|||
end
|
||||
|
||||
context "when there is no last seen datetime" do
|
||||
let(:updated_at) { DateTime.now }
|
||||
let(:updated_at) { Time.zone.now }
|
||||
let(:seen_at) { nil }
|
||||
|
||||
it { is_expected.to eq nil }
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
|
|||
subject { Administrateurs::ActivateBeforeExpirationJob.perform_now }
|
||||
|
||||
before do
|
||||
Timecop.freeze(DateTime.new(2018, 03, 20))
|
||||
Timecop.freeze(Time.zone.local(2018, 03, 20))
|
||||
administrateur.reload
|
||||
allow(AdministrateurMailer).to receive(:activate_before_expiration).and_return(mailer_double)
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
|
|||
|
||||
context "created a long time ago" do
|
||||
before do
|
||||
administrateur.update_columns(created_at: DateTime.new(2018, 03, 10))
|
||||
administrateur.update_columns(created_at: Time.zone.local(2018, 03, 10))
|
||||
subject
|
||||
end
|
||||
|
||||
|
@ -34,7 +34,7 @@ RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
|
|||
|
||||
context "created 3 days ago" do
|
||||
before do
|
||||
administrateur.update_columns(created_at: DateTime.new(2018, 03, 17, 20, 00))
|
||||
administrateur.update_columns(created_at: Time.zone.local(2018, 03, 17, 20, 00))
|
||||
subject
|
||||
end
|
||||
|
||||
|
@ -52,7 +52,7 @@ RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
|
|||
|
||||
context "created a long time ago" do
|
||||
before do
|
||||
administrateur.update_columns(created_at: DateTime.new(2018, 03, 10))
|
||||
administrateur.update_columns(created_at: Time.zone.local(2018, 03, 10))
|
||||
subject
|
||||
end
|
||||
|
||||
|
@ -61,7 +61,7 @@ RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
|
|||
|
||||
context "created 2 days ago" do
|
||||
before do
|
||||
administrateur.update_columns(created_at: DateTime.new(2018, 03, 18, 20, 00))
|
||||
administrateur.update_columns(created_at: Time.zone.local(2018, 03, 18, 20, 00))
|
||||
subject
|
||||
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
|
||||
|
|
|
@ -4,8 +4,8 @@ describe '2018_03_06_clean_html_textareas#clean' do
|
|||
let(:procedure) { create(:procedure) }
|
||||
let(:type_champ) { create(:type_de_champ_textarea, procedure: procedure) }
|
||||
let(:champ) { type_champ.champ.create(value: "<p>Gnahar<br>greu bouahaha</p>") }
|
||||
let(:champ_date) { Time.local(1995) }
|
||||
let(:rake_date) { Time.local(2018) }
|
||||
let(:champ_date) { Time.zone.local(1995) }
|
||||
let(:rake_date) { Time.zone.local(2018) }
|
||||
let(:rake_task) { Rake::Task['2018_03_06_clean_html_textareas:clean'] }
|
||||
|
||||
before do
|
||||
|
|
|
@ -25,7 +25,7 @@ RSpec.describe GestionnaireMailer, type: :mailer do
|
|||
dossiers_en_instruction_description: 'desc')
|
||||
|
||||
{
|
||||
start_date: DateTime.now,
|
||||
start_date: Time.zone.now,
|
||||
procedure_overviews: [procedure_overview]
|
||||
}
|
||||
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) }
|
||||
|
||||
|
@ -187,9 +187,9 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
|
||||
context "when using a date tag" do
|
||||
before do
|
||||
dossier.en_construction_at = DateTime.new(2001, 2, 3)
|
||||
dossier.en_instruction_at = DateTime.new(2004, 5, 6)
|
||||
dossier.processed_at = DateTime.new(2007, 8, 9)
|
||||
dossier.en_construction_at = Time.zone.local(2001, 2, 3)
|
||||
dossier.en_instruction_at = Time.zone.local(2004, 5, 6)
|
||||
dossier.processed_at = Time.zone.local(2007, 8, 9)
|
||||
end
|
||||
|
||||
context "with date de dépôt" do
|
||||
|
|
|
@ -479,9 +479,9 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context 'when they are a lot of advice' do
|
||||
let!(:avis_1) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false, created_at: DateTime.parse('10/01/2010')) }
|
||||
let!(:avis_2) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false, created_at: DateTime.parse('9/01/2010')) }
|
||||
let!(:avis_3) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false, created_at: DateTime.parse('11/01/2010')) }
|
||||
let!(:avis_1) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false, created_at: Time.zone.parse('10/01/2010')) }
|
||||
let!(:avis_2) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false, created_at: Time.zone.parse('9/01/2010')) }
|
||||
let!(:avis_3) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false, created_at: Time.zone.parse('11/01/2010')) }
|
||||
|
||||
it { expect(dossier.avis_for(gestionnaire)).to match([avis_2, avis_1, avis_3]) }
|
||||
it { expect(dossier.avis_for(expert_1)).to match([avis_2, avis_1, avis_3]) }
|
||||
|
@ -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 }
|
||||
|
@ -566,9 +566,9 @@ describe Dossier do
|
|||
describe '.downloadable_sorted' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:brouillon)) }
|
||||
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_construction), en_construction_at: DateTime.parse('03/01/2010')) }
|
||||
let!(:dossier3) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_instruction), en_construction_at: DateTime.parse('01/01/2010')) }
|
||||
let!(:dossier4) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true, en_construction_at: DateTime.parse('02/01/2010')) }
|
||||
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_construction), en_construction_at: Time.zone.parse('03/01/2010')) }
|
||||
let!(:dossier3) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_instruction), en_construction_at: Time.zone.parse('01/01/2010')) }
|
||||
let!(:dossier4) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true, en_construction_at: Time.zone.parse('02/01/2010')) }
|
||||
|
||||
subject { procedure.dossiers.downloadable_sorted }
|
||||
|
||||
|
@ -734,7 +734,7 @@ describe Dossier do
|
|||
|
||||
describe 'updated_at' do
|
||||
let!(:dossier) { create(:dossier) }
|
||||
let(:modif_date) { DateTime.parse('01/01/2100') }
|
||||
let(:modif_date) { Time.zone.parse('01/01/2100') }
|
||||
|
||||
before { Timecop.freeze(modif_date) }
|
||||
after { Timecop.return }
|
||||
|
@ -982,10 +982,10 @@ describe Dossier do
|
|||
context "retention date" do
|
||||
let(:procedure) { create(:procedure, duree_conservation_dossiers_dans_ds: 6) }
|
||||
let(:uninstructed_dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
let(:young_dossier) { create(:dossier, :en_instruction, en_instruction_at: DateTime.now, procedure: procedure) }
|
||||
let(:young_dossier) { create(:dossier, :en_instruction, en_instruction_at: Time.zone.now, procedure: procedure) }
|
||||
let(:just_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: 6.months.ago, procedure: procedure) }
|
||||
let(:long_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: 1.year.ago, procedure: procedure) }
|
||||
let(:modif_date) { DateTime.parse('01/01/2100') }
|
||||
let(:modif_date) { Time.zone.parse('01/01/2100') }
|
||||
|
||||
before { Timecop.freeze(modif_date) }
|
||||
after { Timecop.return }
|
||||
|
@ -993,7 +993,7 @@ describe Dossier do
|
|||
describe "#retention_end_date" do
|
||||
it { expect(uninstructed_dossier.retention_end_date).to be_nil }
|
||||
it { expect(young_dossier.retention_end_date).to eq(6.months.from_now) }
|
||||
it { expect(just_expired_dossier.retention_end_date).to eq(DateTime.now) }
|
||||
it { expect(just_expired_dossier.retention_end_date).to eq(Time.zone.now) }
|
||||
it { expect(long_expired_dossier.retention_end_date).to eq(6.months.ago) }
|
||||
end
|
||||
|
||||
|
|
|
@ -138,8 +138,8 @@ describe Gestionnaire, type: :model do
|
|||
describe 'last_week_overview' do
|
||||
let!(:gestionnaire2) { create(:gestionnaire) }
|
||||
subject { gestionnaire2.last_week_overview }
|
||||
let(:friday) { DateTime.new(2017, 5, 12) }
|
||||
let(:monday) { DateTime.now.beginning_of_week }
|
||||
let(:friday) { Time.zone.local(2017, 5, 12) }
|
||||
let(:monday) { Time.zone.now.beginning_of_week }
|
||||
|
||||
before { Timecop.freeze(friday) }
|
||||
after { Timecop.return }
|
||||
|
@ -313,7 +313,7 @@ describe Gestionnaire, type: :model do
|
|||
context 'when gestionnaire update it s public champs last seen' do
|
||||
let(:follow) { gestionnaire.follows.find_by(dossier: dossier) }
|
||||
|
||||
before { follow.update_attribute('demande_seen_at', DateTime.now) }
|
||||
before { follow.update_attribute('demande_seen_at', Time.zone.now) }
|
||||
|
||||
it { is_expected.to match([]) }
|
||||
it { expect(gestionnaire_2.notifications_for_procedure(procedure)).to match([dossier.id]) }
|
||||
|
@ -376,7 +376,7 @@ describe Gestionnaire, type: :model do
|
|||
describe '#mark_tab_as_seen' do
|
||||
let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
||||
let(:gestionnaire) { dossier.follows.first.gestionnaire }
|
||||
let(:freeze_date) { DateTime.parse('12/12/2012') }
|
||||
let(:freeze_date) { Time.zone.parse('12/12/2012') }
|
||||
|
||||
context 'when demande is acknowledged' do
|
||||
let(:follow) { gestionnaire.follows.find_by(dossier: dossier) }
|
||||
|
|
|
@ -2,8 +2,8 @@ require 'spec_helper'
|
|||
|
||||
describe ProcedureOverview, type: :model do
|
||||
let(:procedure) { create(:procedure, libelle: 'libelle') }
|
||||
let(:friday) { DateTime.new(2017, 5, 12) } # vendredi 12 mai 2017, de la semaine du 8 mai
|
||||
let(:monday) { DateTime.new(2017, 5, 8) }
|
||||
let(:friday) { Time.zone.local(2017, 5, 12) } # vendredi 12 mai 2017, de la semaine du 8 mai
|
||||
let(:monday) { Time.zone.local(2017, 5, 8) }
|
||||
|
||||
before { Timecop.freeze(friday) }
|
||||
after { Timecop.return }
|
||||
|
|
|
@ -133,25 +133,25 @@ describe ProcedurePresentation do
|
|||
|
||||
context 'for created_at column' do
|
||||
let(:column) { 'created_at' }
|
||||
let(:dossier) { Timecop.freeze(DateTime.new(1992, 3, 22)) { create(:dossier, procedure: procedure) } }
|
||||
let(:dossier) { Timecop.freeze(Time.zone.local(1992, 3, 22)) { create(:dossier, procedure: procedure) } }
|
||||
|
||||
it { is_expected.to eq(DateTime.new(1992, 3, 22)) }
|
||||
it { is_expected.to eq(Time.zone.local(1992, 3, 22).strftime('%d/%m/%Y')) }
|
||||
end
|
||||
|
||||
context 'for en_construction_at column' do
|
||||
let(:column) { 'en_construction_at' }
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2018, 10, 17)) }
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: Time.zone.local(2018, 10, 17)) }
|
||||
|
||||
it { is_expected.to eq(DateTime.new(2018, 10, 17)) }
|
||||
it { is_expected.to eq(Time.zone.local(2018, 10, 17).strftime('%d/%m/%Y')) }
|
||||
end
|
||||
|
||||
context 'for updated_at column' do
|
||||
let(:column) { 'updated_at' }
|
||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
before { dossier.touch(time: DateTime.new(2018, 9, 25)) }
|
||||
before { dossier.touch(time: Time.zone.local(2018, 9, 25)) }
|
||||
|
||||
it { is_expected.to eq(DateTime.new(2018, 9, 25)) }
|
||||
it { is_expected.to eq(Time.zone.local(2018, 9, 25).strftime('%d/%m/%Y')) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -236,11 +236,11 @@ describe ProcedurePresentation do
|
|||
let!(:older_dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
|
||||
before do
|
||||
notified_dossier.champs.first.touch(time: DateTime.new(2018, 9, 20))
|
||||
create(:follow, gestionnaire: gestionnaire, dossier: notified_dossier, demande_seen_at: DateTime.new(2018, 9, 10))
|
||||
notified_dossier.touch(time: DateTime.new(2018, 9, 20))
|
||||
recent_dossier.touch(time: DateTime.new(2018, 9, 25))
|
||||
older_dossier.touch(time: DateTime.new(2018, 5, 13))
|
||||
notified_dossier.champs.first.touch(time: Time.zone.local(2018, 9, 20))
|
||||
create(:follow, gestionnaire: gestionnaire, dossier: notified_dossier, demande_seen_at: Time.zone.local(2018, 9, 10))
|
||||
notified_dossier.touch(time: Time.zone.local(2018, 9, 20))
|
||||
recent_dossier.touch(time: Time.zone.local(2018, 9, 25))
|
||||
older_dossier.touch(time: Time.zone.local(2018, 5, 13))
|
||||
end
|
||||
|
||||
context 'in ascending order' do
|
||||
|
@ -269,16 +269,16 @@ describe ProcedurePresentation do
|
|||
|
||||
context 'for created_at column' do
|
||||
let(:column) { 'created_at' }
|
||||
let!(:recent_dossier) { Timecop.freeze(DateTime.new(2018, 10, 17)) { create(:dossier, procedure: procedure) } }
|
||||
let!(:older_dossier) { Timecop.freeze(DateTime.new(2003, 11, 11)) { create(:dossier, procedure: procedure) } }
|
||||
let!(:recent_dossier) { Timecop.freeze(Time.zone.local(2018, 10, 17)) { create(:dossier, procedure: procedure) } }
|
||||
let!(:older_dossier) { Timecop.freeze(Time.zone.local(2003, 11, 11)) { create(:dossier, procedure: procedure) } }
|
||||
|
||||
it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) }
|
||||
end
|
||||
|
||||
context 'for en_construction_at column' do
|
||||
let(:column) { 'en_construction_at' }
|
||||
let!(:recent_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2018, 10, 17)) }
|
||||
let!(:older_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2013, 1, 1)) }
|
||||
let!(:recent_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: Time.zone.local(2018, 10, 17)) }
|
||||
let!(:older_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: Time.zone.local(2013, 1, 1)) }
|
||||
|
||||
it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) }
|
||||
end
|
||||
|
@ -289,8 +289,8 @@ describe ProcedurePresentation do
|
|||
let(:older_dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
before do
|
||||
recent_dossier.touch(time: DateTime.new(2018, 9, 25))
|
||||
older_dossier.touch(time: DateTime.new(2018, 5, 13))
|
||||
recent_dossier.touch(time: Time.zone.local(2018, 9, 25))
|
||||
older_dossier.touch(time: Time.zone.local(2018, 5, 13))
|
||||
end
|
||||
|
||||
it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) }
|
||||
|
@ -377,16 +377,16 @@ describe ProcedurePresentation do
|
|||
|
||||
context 'for self table' do
|
||||
context 'for created_at column' do
|
||||
let!(:kept_dossier) { create(:dossier, procedure: procedure, created_at: DateTime.new(2018, 9, 18, 14, 28)) }
|
||||
let!(:discarded_dossier) { create(:dossier, procedure: procedure, created_at: DateTime.new(2018, 9, 17, 23, 59)) }
|
||||
let!(:kept_dossier) { create(:dossier, procedure: procedure, created_at: Time.zone.local(2018, 9, 18, 14, 28)) }
|
||||
let!(:discarded_dossier) { create(:dossier, procedure: procedure, created_at: Time.zone.local(2018, 9, 17, 23, 59)) }
|
||||
let(:filter) { [{ 'table' => 'self', 'column' => 'created_at', 'value' => '18/9/2018' }] }
|
||||
|
||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||
end
|
||||
|
||||
context 'for en_construction_at column' do
|
||||
let!(:kept_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2018, 10, 17)) }
|
||||
let!(:discarded_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2013, 1, 1)) }
|
||||
let!(:kept_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: Time.zone.local(2018, 10, 17)) }
|
||||
let!(:discarded_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: Time.zone.local(2013, 1, 1)) }
|
||||
let(:filter) { [{ 'table' => 'self', 'column' => 'en_construction_at', 'value' => '17/10/2018' }] }
|
||||
|
||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||
|
@ -398,12 +398,17 @@ describe ProcedurePresentation do
|
|||
let(:filter) { [{ 'table' => 'self', 'column' => 'updated_at', 'value' => '18/9/2018' }] }
|
||||
|
||||
before do
|
||||
kept_dossier.touch(time: DateTime.new(2018, 9, 18, 14, 28))
|
||||
discarded_dossier.touch(time: DateTime.new(2018, 9, 17, 23, 59))
|
||||
kept_dossier.touch(time: Time.zone.local(2018, 9, 18, 14, 28))
|
||||
discarded_dossier.touch(time: Time.zone.local(2018, 9, 17, 23, 59))
|
||||
end
|
||||
|
||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||
end
|
||||
|
||||
context 'for a malformed date' do
|
||||
let(:filter) { [{ 'table' => 'self', 'column' => 'updated_at', 'value' => 'malformed date' }] }
|
||||
it { is_expected.to match([]) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'for type_de_champ table' do
|
||||
|
@ -436,8 +441,8 @@ describe ProcedurePresentation do
|
|||
|
||||
context 'for etablissement table' do
|
||||
context 'for entreprise_date_creation column' do
|
||||
let!(:kept_dossier) { create(:dossier, procedure: procedure, etablissement: create(:etablissement, entreprise_date_creation: DateTime.new(2018, 6, 21))) }
|
||||
let!(:discarded_dossier) { create(:dossier, procedure: procedure, etablissement: create(:etablissement, entreprise_date_creation: DateTime.new(2008, 6, 21))) }
|
||||
let!(:kept_dossier) { create(:dossier, procedure: procedure, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2018, 6, 21))) }
|
||||
let!(:discarded_dossier) { create(:dossier, procedure: procedure, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2008, 6, 21))) }
|
||||
let(:filter) { [{ 'table' => 'etablissement', 'column' => 'entreprise_date_creation', 'value' => '21/6/2018' }] }
|
||||
|
||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||
|
|
|
@ -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!
|
||||
|
@ -627,7 +627,7 @@ describe Procedure do
|
|||
end
|
||||
|
||||
describe "#export_filename" do
|
||||
before { Timecop.freeze(Time.new(2018, 1, 2, 23, 11, 14)) }
|
||||
before { Timecop.freeze(Time.zone.local(2018, 1, 2, 23, 11, 14)) }
|
||||
|
||||
subject { procedure.export_filename }
|
||||
|
||||
|
@ -716,7 +716,7 @@ describe Procedure do
|
|||
context 'which is termine' do
|
||||
before do
|
||||
dossier.accepte!
|
||||
processed_date = DateTime.parse('12/12/2012')
|
||||
processed_date = Time.zone.parse('12/12/2012')
|
||||
instruction_date = processed_date - 1.day
|
||||
dossier.update(en_instruction_at: instruction_date, processed_at: processed_date)
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ describe FranceConnectService do
|
|||
expect(subject).to have_attributes({
|
||||
given_name: given_name,
|
||||
family_name: family_name,
|
||||
birthdate: DateTime.parse(birthdate),
|
||||
birthdate: Date.parse(birthdate),
|
||||
birthplace: birthplace,
|
||||
gender: gender,
|
||||
email_france_connect: email,
|
||||
|
|
|
@ -6,6 +6,6 @@ describe RemoteDownloader do
|
|||
subject { described_class.new filename }
|
||||
|
||||
describe '#url' do
|
||||
it { expect(subject.url).to eq 'https://storage.apientreprise.fr/tps_dev/file_name.pdf' }
|
||||
it { expect(subject.url).to eq 'https://static.demarches-simplifiees.fr/tps_dev/file_name.pdf' }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue