commit
783f2ef4e1
79 changed files with 223 additions and 203 deletions
|
@ -764,7 +764,7 @@ Rails/SkipsModelValidations:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Rails/TimeZone:
|
Rails/TimeZone:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Rails/UniqBeforePluck:
|
Rails/UniqBeforePluck:
|
||||||
Enabled: true
|
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
|
jobs: bin/delayed_job run
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Admin::AttestationTemplatesController < AdminController
|
||||||
@title = activated_attestation_params[:title]
|
@title = activated_attestation_params[:title]
|
||||||
@body = activated_attestation_params[:body]
|
@body = activated_attestation_params[:body]
|
||||||
@footer = activated_attestation_params[:footer]
|
@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,
|
# 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
|
# 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)
|
if User.exists?(email: @gestionnaire.email)
|
||||||
GestionnaireMailer.user_to_gestionnaire(@gestionnaire.email).deliver_later
|
GestionnaireMailer.user_to_gestionnaire(@gestionnaire.email).deliver_later
|
||||||
else
|
else
|
||||||
User.create(email: email, password: password, confirmed_at: DateTime.now)
|
User.create(email: email, password: password, confirmed_at: Time.zone.now)
|
||||||
end
|
end
|
||||||
flash.notice = 'Instructeur ajouté'
|
flash.notice = 'Instructeur ajouté'
|
||||||
else
|
else
|
||||||
|
|
|
@ -15,7 +15,7 @@ class FranceConnect::ParticulierController < ApplicationController
|
||||||
if fci.user.nil?
|
if fci.user.nil?
|
||||||
user = User.find_or_create_by(email: fci.email_france_connect) do |new_user|
|
user = User.find_or_create_by(email: fci.email_france_connect) do |new_user|
|
||||||
new_user.password = Devise.friendly_token[0, 20]
|
new_user.password = Devise.friendly_token[0, 20]
|
||||||
new_user.confirmed_at = DateTime.now
|
new_user.confirmed_at = Time.zone.now
|
||||||
end
|
end
|
||||||
|
|
||||||
fci.update_attribute('user_id', user.id)
|
fci.update_attribute('user_id', user.id)
|
||||||
|
|
|
@ -89,7 +89,7 @@ module NewGestionnaire
|
||||||
if gestionnaire.save
|
if gestionnaire.save
|
||||||
user = User.find_by(email: email)
|
user = User.find_by(email: email)
|
||||||
if user.blank?
|
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
|
end
|
||||||
|
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
|
|
|
@ -13,7 +13,7 @@ module NewUser
|
||||||
.select("procedures.*, COUNT(*) AS procedures_count")
|
.select("procedures.*, COUNT(*) AS procedures_count")
|
||||||
.joins(:dossiers)
|
.joins(:dossiers)
|
||||||
.publiees
|
.publiees
|
||||||
.where(dossiers: { created_at: 7.days.ago..Time.now })
|
.where(dossiers: { created_at: 7.days.ago..Time.zone.now })
|
||||||
.group("procedures.id")
|
.group("procedures.id")
|
||||||
.order("procedures_count DESC")
|
.order("procedures_count DESC")
|
||||||
.limit(5)
|
.limit(5)
|
||||||
|
|
|
@ -10,6 +10,7 @@ module NewUser
|
||||||
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_brouillon, :modifier, :update]
|
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_invite_submission!, only: [:update_brouillon]
|
||||||
before_action :forbid_closed_submission!, only: [:update_brouillon]
|
before_action :forbid_closed_submission!, only: [:update_brouillon]
|
||||||
|
before_action :show_demarche_en_test_banner
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page)
|
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page)
|
||||||
|
@ -211,6 +212,12 @@ module NewUser
|
||||||
|
|
||||||
private
|
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
|
def ensure_dossier_can_be_updated
|
||||||
if !dossier.can_be_updated_by_the_user?
|
if !dossier.can_be_updated_by_the_user?
|
||||||
flash.alert = 'Votre dossier ne peut plus être modifié'
|
flash.alert = 'Votre dossier ne peut plus être modifié'
|
||||||
|
|
|
@ -82,7 +82,7 @@ class StatsController < ApplicationController
|
||||||
|
|
||||||
def procedures_numbers(procedures)
|
def procedures_numbers(procedures)
|
||||||
total = procedures.count
|
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
|
previous_count = procedures.where(published_at: 2.months.ago..1.month.ago).count
|
||||||
if previous_count != 0
|
if previous_count != 0
|
||||||
evolution = (((last_30_days_count.to_f / previous_count) - 1) * 100).round(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)
|
def dossiers_numbers(dossiers)
|
||||||
total = dossiers.count
|
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
|
previous_count = dossiers.where(en_construction_at: 2.months.ago..1.month.ago).count
|
||||||
if previous_count != 0
|
if previous_count != 0
|
||||||
evolution = (((last_30_days_count.to_f / previous_count) - 1) * 100).round(0)
|
evolution = (((last_30_days_count.to_f / previous_count) - 1) * 100).round(0)
|
||||||
|
@ -178,9 +178,9 @@ class StatsController < ApplicationController
|
||||||
|
|
||||||
def max_date
|
def max_date
|
||||||
if administration_signed_in?
|
if administration_signed_in?
|
||||||
Time.now.to_date
|
Time.zone.now.to_date
|
||||||
else
|
else
|
||||||
Time.now.beginning_of_month - 1.second
|
Time.zone.now.beginning_of_month - 1.second
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ class StatsController < ApplicationController
|
||||||
# and then computing the average for all the procedures
|
# and then computing the average for all the procedures
|
||||||
|
|
||||||
min_date = 11.months.ago
|
min_date = 11.months.ago
|
||||||
max_date = Time.now.to_date
|
max_date = Time.zone.now.to_date
|
||||||
|
|
||||||
processed_dossiers = dossiers
|
processed_dossiers = dossiers
|
||||||
.where(:processed_at => min_date..max_date)
|
.where(:processed_at => min_date..max_date)
|
||||||
|
@ -273,7 +273,7 @@ class StatsController < ApplicationController
|
||||||
# for a 24 champs form (the current form mean length)
|
# for a 24 champs form (the current form mean length)
|
||||||
|
|
||||||
min_date = 11.months.ago
|
min_date = 11.months.ago
|
||||||
max_date = Time.now.to_date
|
max_date = Time.zone.now.to_date
|
||||||
|
|
||||||
processed_dossiers = dossiers
|
processed_dossiers = dossiers
|
||||||
.where(:processed_at => min_date..max_date)
|
.where(:processed_at => min_date..max_date)
|
||||||
|
|
|
@ -24,7 +24,7 @@ class ChampDecorator < Draper::Decorator
|
||||||
if type_champ == TypeDeChamp.type_champs.fetch(:date)
|
if type_champ == TypeDeChamp.type_champs.fetch(:date)
|
||||||
object.value
|
object.value
|
||||||
elsif type_champ == TypeDeChamp.type_champs.fetch(:datetime) && object.value != ' 00:00'
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,11 +5,11 @@ class DossierDecorator < Draper::Decorator
|
||||||
delegate_all
|
delegate_all
|
||||||
|
|
||||||
def first_creation
|
def first_creation
|
||||||
created_at.localtime.strftime('%d/%m/%Y %H:%M')
|
created_at.strftime('%d/%m/%Y %H:%M')
|
||||||
end
|
end
|
||||||
|
|
||||||
def last_update
|
def last_update
|
||||||
updated_at.localtime.strftime('%d/%m/%Y %H:%M')
|
updated_at.strftime('%d/%m/%Y %H:%M')
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_state
|
def display_state
|
||||||
|
|
|
@ -2,12 +2,12 @@ class ProcedureDecorator < Draper::Decorator
|
||||||
delegate_all
|
delegate_all
|
||||||
|
|
||||||
def created_at_fr
|
def created_at_fr
|
||||||
created_at.localtime.strftime('%d/%m/%Y %H:%M')
|
created_at.strftime('%d/%m/%Y %H:%M')
|
||||||
end
|
end
|
||||||
|
|
||||||
def published_at_fr
|
def published_at_fr
|
||||||
if published_at.present?
|
if published_at.present?
|
||||||
published_at.localtime.strftime('%d/%m/%Y %H:%M')
|
published_at.strftime('%d/%m/%Y %H:%M')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ module CommentaireHelper
|
||||||
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 == Date.current.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.localtime, format: template)
|
I18n.l(commentaire.created_at, format: template)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -13,7 +13,7 @@ class AntiVirusJob < ApplicationJob
|
||||||
else
|
else
|
||||||
status = VirusScan.statuses.fetch(:infected)
|
status = VirusScan.statuses.fetch(:infected)
|
||||||
end
|
end
|
||||||
virus_scan.update(scanned_at: Time.now, status: status)
|
virus_scan.update(scanned_at: Time.zone.now, status: status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
class ApplicationJob < ActiveJob::Base
|
class ApplicationJob < ActiveJob::Base
|
||||||
before_perform do |job|
|
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
|
end
|
||||||
|
|
||||||
after_perform do |job|
|
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
|
end
|
||||||
|
|
||||||
def error(job, exception)
|
def error(job, exception)
|
||||||
|
|
|
@ -7,14 +7,14 @@ class AutoReceiveDossiersForProcedureJob < ApplicationJob
|
||||||
when Dossier.states.fetch(:en_instruction)
|
when Dossier.states.fetch(:en_instruction)
|
||||||
procedure.dossiers.state_en_construction.update_all(
|
procedure.dossiers.state_en_construction.update_all(
|
||||||
state: Dossier.states.fetch(:en_instruction),
|
state: Dossier.states.fetch(:en_instruction),
|
||||||
en_instruction_at: DateTime.now
|
en_instruction_at: Time.zone.now
|
||||||
)
|
)
|
||||||
when Dossier.states.fetch(:accepte)
|
when Dossier.states.fetch(:accepte)
|
||||||
procedure.dossiers.state_en_construction.find_each do |dossier|
|
procedure.dossiers.state_en_construction.find_each do |dossier|
|
||||||
dossier.update(
|
dossier.update(
|
||||||
state: Dossier.states.fetch(:accepte),
|
state: Dossier.states.fetch(:accepte),
|
||||||
en_instruction_at: DateTime.now,
|
en_instruction_at: Time.zone.now,
|
||||||
processed_at: DateTime.now
|
processed_at: Time.zone.now
|
||||||
)
|
)
|
||||||
dossier.attestation = dossier.build_attestation
|
dossier.attestation = dossier.build_attestation
|
||||||
dossier.save
|
dossier.save
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ApiEntreprise::EntrepriseAdapter < ApiEntreprise::Adapter
|
||||||
params = data_source[:entreprise].slice(*attr_to_fetch)
|
params = data_source[:entreprise].slice(*attr_to_fetch)
|
||||||
|
|
||||||
if valid_params?(params)
|
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}" }
|
params.transform_keys { |k| :"entreprise_#{k}" }
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Administration < ApplicationRecord
|
||||||
User.create({
|
User.create({
|
||||||
email: email,
|
email: email,
|
||||||
password: password,
|
password: password,
|
||||||
confirmed_at: DateTime.now
|
confirmed_at: Time.zone.now
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ class AttestationTemplate < ApplicationRecord
|
||||||
body: replace_tags(body, dossier),
|
body: replace_tags(body, dossier),
|
||||||
signature: signature,
|
signature: signature,
|
||||||
footer: footer,
|
footer: footer,
|
||||||
created_at: Time.now)
|
created_at: Time.zone.now)
|
||||||
|
|
||||||
attestation_view = action_view.render(file: 'admin/attestation_templates/show',
|
attestation_view = action_view.render(file: 'admin/attestation_templates/show',
|
||||||
formats: [:pdf])
|
formats: [:pdf])
|
||||||
|
|
|
@ -25,12 +25,12 @@ class Champs::DatetimeChamp < Champ
|
||||||
begin
|
begin
|
||||||
hash_date = YAML.safe_load(value.gsub('=>', ': '))
|
hash_date = YAML.safe_load(value.gsub('=>', ': '))
|
||||||
year, month, day, hour, minute = hash_date.values_at(1,2,3,4,5)
|
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
|
rescue
|
||||||
nil
|
nil
|
||||||
end
|
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
|
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
|
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
|
self.value = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Commentaire < ApplicationRecord
|
||||||
after_create :notify
|
after_create :notify
|
||||||
|
|
||||||
def header
|
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
|
end
|
||||||
|
|
||||||
def sender
|
def sender
|
||||||
|
|
|
@ -126,7 +126,7 @@ module TagsSubstitutionConcern
|
||||||
|
|
||||||
def format_date(date)
|
def format_date(date)
|
||||||
if date.present?
|
if date.present?
|
||||||
date.localtime.strftime('%d/%m/%Y')
|
date.strftime('%d/%m/%Y')
|
||||||
else
|
else
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|
|
@ -180,7 +180,7 @@ class Dossier < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def retention_expired?
|
def retention_expired?
|
||||||
instruction_commencee? && retention_end_date <= DateTime.now
|
instruction_commencee? && retention_end_date <= Time.zone.now
|
||||||
end
|
end
|
||||||
|
|
||||||
def text_summary
|
def text_summary
|
||||||
|
@ -194,7 +194,7 @@ class Dossier < ApplicationRecord
|
||||||
else
|
else
|
||||||
parts = [
|
parts = [
|
||||||
"Dossier déposé le ",
|
"Dossier déposé le ",
|
||||||
en_construction_at.localtime.strftime("%d/%m/%Y"),
|
en_construction_at.strftime("%d/%m/%Y"),
|
||||||
" sur la démarche ",
|
" sur la démarche ",
|
||||||
procedure.libelle,
|
procedure.libelle,
|
||||||
" gérée par l'organisme ",
|
" gérée par l'organisme ",
|
||||||
|
@ -275,7 +275,7 @@ class Dossier < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_and_keep_track
|
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)
|
deleted_dossier = DeletedDossier.create!(dossier_id: id, procedure: procedure, state: state, deleted_at: now)
|
||||||
update(hidden_at: now)
|
update(hidden_at: now)
|
||||||
|
|
||||||
|
@ -309,11 +309,11 @@ class Dossier < ApplicationRecord
|
||||||
|
|
||||||
def update_state_dates
|
def update_state_dates
|
||||||
if en_construction? && !self.en_construction_at
|
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
|
elsif en_instruction? && !self.en_instruction_at
|
||||||
self.en_instruction_at = DateTime.now
|
self.en_instruction_at = Time.zone.now
|
||||||
elsif TERMINE.include?(state)
|
elsif TERMINE.include?(state)
|
||||||
self.processed_at = DateTime.now
|
self.processed_at = Time.zone.now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ class Follow < ApplicationRecord
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_default_date
|
def set_default_date
|
||||||
self.demande_seen_at ||= DateTime.now
|
self.demande_seen_at ||= Time.zone.now
|
||||||
self.annotations_privees_seen_at ||= DateTime.now
|
self.annotations_privees_seen_at ||= Time.zone.now
|
||||||
self.avis_seen_at ||= DateTime.now
|
self.avis_seen_at ||= Time.zone.now
|
||||||
self.messagerie_seen_at ||= DateTime.now
|
self.messagerie_seen_at ||= Time.zone.now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Gestionnaire < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def last_week_overview
|
def last_week_overview
|
||||||
start_date = DateTime.now.beginning_of_week
|
start_date = Time.zone.now.beginning_of_week
|
||||||
|
|
||||||
active_procedure_overviews = procedures
|
active_procedure_overviews = procedures
|
||||||
.publiees
|
.publiees
|
||||||
|
@ -180,7 +180,7 @@ class Gestionnaire < ApplicationRecord
|
||||||
|
|
||||||
def mark_tab_as_seen(dossier, tab)
|
def mark_tab_as_seen(dossier, tab)
|
||||||
attributes = {}
|
attributes = {}
|
||||||
attributes["#{tab}_seen_at"] = DateTime.now
|
attributes["#{tab}_seen_at"] = Time.zone.now
|
||||||
Follow.where(gestionnaire: self, dossier: dossier).update_all(attributes)
|
Follow.where(gestionnaire: self, dossier: dossier).update_all(attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ class Procedure < ApplicationRecord
|
||||||
|
|
||||||
def export_filename
|
def export_filename
|
||||||
procedure_identifier = path || "procedure-#{id}"
|
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
|
end
|
||||||
|
|
||||||
def generate_export
|
def generate_export
|
||||||
|
@ -305,7 +305,7 @@ class Procedure < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def whitelist!
|
def whitelist!
|
||||||
update_attribute('whitelisted_at', DateTime.now)
|
update_attribute('whitelisted_at', Time.zone.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
def closed_mail_template_attestation_inconsistency_state
|
def closed_mail_template_attestation_inconsistency_state
|
||||||
|
@ -344,24 +344,24 @@ class Procedure < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_publish(path)
|
def after_publish(path)
|
||||||
update!(published_at: Time.now)
|
update!(published_at: Time.zone.now)
|
||||||
|
|
||||||
publish_with_path!(path)
|
publish_with_path!(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_archive
|
def after_archive
|
||||||
update!(archived_at: Time.now, path: nil)
|
update!(archived_at: Time.zone.now, path: nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_hide
|
def after_hide
|
||||||
now = Time.now
|
now = Time.zone.now
|
||||||
update!(hidden_at: now, path: nil)
|
update!(hidden_at: now, path: nil)
|
||||||
procedure_path&.hide!
|
procedure_path&.hide!
|
||||||
dossiers.update_all(hidden_at: now)
|
dossiers.update_all(hidden_at: now)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_reopen(path)
|
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)
|
publish_with_path!(path)
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ class ProcedureOverview
|
||||||
|
|
||||||
@created_dossiers_count = procedure
|
@created_dossiers_count = procedure
|
||||||
.dossiers
|
.dossiers
|
||||||
.where(created_at: start_date..DateTime.now)
|
.where(created_at: start_date..Time.zone.now)
|
||||||
.state_not_brouillon
|
.state_not_brouillon
|
||||||
.count
|
.count
|
||||||
end
|
end
|
||||||
|
|
|
@ -111,8 +111,12 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
column = sanitized_column(filter)
|
column = sanitized_column(filter)
|
||||||
case table
|
case table
|
||||||
when 'self'
|
when 'self'
|
||||||
date = filter['value'].to_date rescue nil
|
date = Time.zone.parse(filter['value'])
|
||||||
dossiers.where("DATE_TRUNC('day', #{column}) = ?", date)
|
if date.present?
|
||||||
|
dossiers.where("#{column} BETWEEN ? AND ?", date, date + 1.day)
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
when 'type_de_champ', 'type_de_champ_private'
|
when 'type_de_champ', 'type_de_champ_private'
|
||||||
relation = table == 'type_de_champ' ? :champs : :champs_private
|
relation = table == 'type_de_champ' ? :champs : :champs_private
|
||||||
dossiers
|
dossiers
|
||||||
|
@ -186,7 +190,7 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
def get_value(dossier, table, column)
|
def get_value(dossier, table, column)
|
||||||
case table
|
case table
|
||||||
when 'self'
|
when 'self'
|
||||||
dossier.send(column)
|
dossier.send(column)&.strftime('%d/%m/%Y')
|
||||||
when 'user', 'individual', 'etablissement'
|
when 'user', 'individual', 'etablissement'
|
||||||
dossier.send(table)&.send(column)
|
dossier.send(table)&.send(column)
|
||||||
when 'type_de_champ'
|
when 'type_de_champ'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#footer
|
#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" }
|
%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"
|
= 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'
|
= link_to 'Nouveautés', 'https://github.com/betagouv/tps/releases', target: '_blank'
|
||||||
\-
|
\-
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
%h2.claimant
|
%h2.claimant
|
||||||
Demandeur :
|
Demandeur :
|
||||||
%span.email= @avis.claimant.email
|
%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
|
%p.introduction= @avis.introduction
|
||||||
|
|
||||||
= form_for @avis, url: gestionnaire_avis_path(@avis), html: { class: 'form' } do |f|
|
= form_for @avis, url: gestionnaire_avis_path(@avis), html: { class: 'form' } do |f|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
confidentiel
|
confidentiel
|
||||||
%span.icon.lock{ title: "Cet avis n'est pas affiché avec les autres experts consultés" }
|
%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) }
|
%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
|
%p= avis.introduction
|
||||||
|
|
||||||
.answer.flex.align-start
|
.answer.flex.align-start
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
= (avis.email_to_display == current_gestionnaire.email) ? 'Vous' : avis.email_to_display
|
= (avis.email_to_display == current_gestionnaire.email) ? 'Vous' : avis.email_to_display
|
||||||
- if avis.answer.present?
|
- if avis.answer.present?
|
||||||
%span.date{ class: highlight_if_unseen_class(avis_seen_at, avis.updated_at) }
|
%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
|
- else
|
||||||
%span.waiting En attente de réponse
|
%span.waiting En attente de réponse
|
||||||
%p= avis.answer
|
%p= avis.answer
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
= render partial: 'shared/dossiers/status_badge', locals: { dossier: dossier }
|
= render partial: 'shared/dossiers/status_badge', locals: { dossier: dossier }
|
||||||
%td.updated-at-col
|
%td.updated-at-col
|
||||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
= 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)
|
= paginate(@dossiers)
|
||||||
|
|
||||||
- if current_user.feedbacks.empty? || current_user.feedbacks.last.created_at < 1.month.ago
|
- if current_user.feedbacks.empty? || current_user.feedbacks.last.created_at < 1.month.ago
|
||||||
|
|
|
@ -73,4 +73,4 @@
|
||||||
%td.updated-at
|
%td.updated-at
|
||||||
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
||||||
modifié le
|
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
|
= link_to pj.content_url, { target: :blank } do
|
||||||
%span.filename= display_pj_filename(pj)
|
%span.filename= display_pj_filename(pj)
|
||||||
%span
|
%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
|
- else
|
||||||
%td Pièce non fournie
|
%td Pièce non fournie
|
||||||
%td.updated-at
|
%td.updated-at
|
||||||
- if pj
|
- if pj
|
||||||
%span{ class: highlight_if_unseen_class(demande_seen_at, pj.updated_at) }
|
%span{ class: highlight_if_unseen_class(demande_seen_at, pj.updated_at) }
|
||||||
modifié le
|
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
|
.datetime
|
||||||
= form.datetime_select(:value, selected: parsed_value, start_year: 1950, end_year: 2100, minute_step: 5)
|
= 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.
|
# 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.
|
# 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.
|
# 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]
|
# 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"
|
PIPEDRIVE_API_URL = "https://api.pipedrive.com/v1"
|
||||||
|
|
||||||
# Internal URLs
|
# Internal URLs
|
||||||
FOG_BASE_URL = "https://storage.apientreprise.fr"
|
FOG_BASE_URL = "https://static.demarches-simplifiees.fr"
|
||||||
|
|
||||||
# External services URLs
|
# External services URLs
|
||||||
DOC_URL = "https://doc.demarches-simplifiees.fr"
|
DOC_URL = "https://doc.demarches-simplifiees.fr"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class AddTimeStampToDossier < ActiveRecord::Migration
|
class AddTimeStampToDossier < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
add_column :dossiers, :created_at, :datetime, default: Time.now
|
add_column :dossiers, :created_at, :datetime, default: Time.zone.now
|
||||||
add_column :dossiers, :updated_at, :datetime, default: Time.now
|
add_column :dossiers, :updated_at, :datetime, default: Time.zone.now
|
||||||
end
|
end
|
||||||
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.
|
# 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
|
# To avoid a short time window between running the migration and updating all existing
|
||||||
# users as confirmed, do the following
|
# 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.
|
# All existing user accounts should be able to log in after this.
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,4 @@ puts "Create test user '#{default_user}'"
|
||||||
Administration.create!(email: default_user, password: default_password)
|
Administration.create!(email: default_user, password: default_password)
|
||||||
Administrateur.create!(email: default_user, password: default_password)
|
Administrateur.create!(email: default_user, password: default_password)
|
||||||
Gestionnaire.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
|
end
|
||||||
|
|
||||||
def sign(request, key)
|
def sign(request, key)
|
||||||
date = Time.now.httpdate
|
date = Time.zone.now.httpdate
|
||||||
sig = signature(
|
sig = signature(
|
||||||
method: request.method,
|
method: request.method,
|
||||||
key: key,
|
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)
|
entreprise.update_columns(created_at: entreprise.dossier.created_at, updated_at: entreprise.dossier.created_at)
|
||||||
else
|
else
|
||||||
rake_puts "dossier #{entreprise.dossier_id} is missing for entreprise #{entreprise.id}"
|
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
|
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"
|
# 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|
|
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}"
|
rake_puts "cleaning #{c.value} => #{formated_date}"
|
||||||
c.update_columns(value: formated_date)
|
c.update_columns(value: formated_date)
|
||||||
end
|
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,
|
# `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.
|
# and checking for dossiers with a missing accusé de réception.
|
||||||
|
|
||||||
bug_date = DateTime.new(2018, 3, 1, 9, 50)
|
bug_date = Time.zone.local(2018, 3, 1, 9, 50)
|
||||||
fix_date = DateTime.new(2018, 3, 5, 18, 40)
|
fix_date = Time.zone.local(2018, 3, 5, 18, 40)
|
||||||
|
|
||||||
# Only send the accusé for dossiers that are still en construction.
|
# 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
|
# 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
|
end
|
||||||
|
|
||||||
def create_commentaires(date_name, template_name, dossiers = Dossier)
|
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|
|
dossiers.includes(:procedure).where(date_name => error_range).find_each(batch_size: 100) do |dossier|
|
||||||
print "#{dossier.id}\n"
|
print "#{dossier.id}\n"
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace :'2018_06_06_users_for_admins_and_gestionnaires' do
|
||||||
User
|
User
|
||||||
.joins("INNER JOIN #{table_name} ON #{table_name}.email = users.email")
|
.joins("INNER JOIN #{table_name} ON #{table_name}.email = users.email")
|
||||||
.where(confirmed_at: nil)
|
.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"
|
rake_puts "Fixed #{count} #{table_name} with unconfirmed user"
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,11 @@ namespace :'2018_09_12_fix_templates' do
|
||||||
end
|
end
|
||||||
|
|
||||||
# 16:15 in Paris -> 14:15 UTC
|
# 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
|
def find_dossiers_with_sent_and_invalid_attestations
|
||||||
invalid_procedures_ids = AttestationTemplate
|
invalid_procedures_ids = AttestationTemplate
|
||||||
|
@ -16,12 +20,12 @@ namespace :'2018_09_12_fix_templates' do
|
||||||
|
|
||||||
dossiers_with_invalid_template_ids = Dossier
|
dossiers_with_invalid_template_ids = Dossier
|
||||||
.where(procedure_id: invalid_procedures_ids)
|
.where(procedure_id: invalid_procedures_ids)
|
||||||
.where(processed_at: DEPLOY_DATETIME..Time.now)
|
.where(processed_at: DEPLOY_DATETIME..Time.zone.now)
|
||||||
.pluck(:id)
|
.pluck(:id)
|
||||||
|
|
||||||
Attestation
|
Attestation
|
||||||
.includes(:dossier)
|
.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)
|
.where(dossier_id: dossiers_with_invalid_template_ids)
|
||||||
.map(&:dossier)
|
.map(&:dossier)
|
||||||
end
|
end
|
||||||
|
|
|
@ -104,8 +104,8 @@ namespace :cloudstorage do
|
||||||
Rake::Task['cloudstorage:init'].invoke
|
Rake::Task['cloudstorage:init'].invoke
|
||||||
|
|
||||||
@cont.objects_detail.each { |object, details|
|
@cont.objects_detail.each { |object, details|
|
||||||
last_modified = DateTime.parse(details[:last_modified])
|
last_modified = Time.zone.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
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe Admin::AttestationTemplatesController, type: :controller do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in admin
|
sign_in admin
|
||||||
Timecop.freeze(Time.now)
|
Timecop.freeze(Time.zone.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
@ -47,7 +47,7 @@ describe Admin::AttestationTemplatesController, type: :controller do
|
||||||
|
|
||||||
it { expect(subject.status).to eq(200) }
|
it { expect(subject.status).to eq(200) }
|
||||||
it { expect(assigns).to include(upload_params.stringify_keys) }
|
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(:logo).read).to eq(logo.read) }
|
||||||
it { expect(assigns(:signature).read).to eq(signature.read) }
|
it { expect(assigns(:signature).read).to eq(signature.read) }
|
||||||
after { procedure.attestation_template.destroy }
|
after { procedure.attestation_template.destroy }
|
||||||
|
|
|
@ -96,8 +96,8 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
describe 'DELETE #destroy' do
|
describe 'DELETE #destroy' do
|
||||||
let(:procedure_draft) { create :procedure, administrateur: admin, published_at: nil, archived_at: nil }
|
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_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.now }
|
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 } }
|
subject { delete :destroy, params: { id: procedure.id } }
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when procedure is published' do
|
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) }
|
it { is_expected.to have_http_status(:success) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ describe API::V1::DossiersController do
|
||||||
|
|
||||||
context 'when procedure is found and belongs to admin' do
|
context 'when procedure is found and belongs to admin' do
|
||||||
let(:procedure_id) { procedure.id }
|
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!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :en_construction, procedure: procedure) } }
|
||||||
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ describe API::V1::DossiersController do
|
||||||
describe 'dossier' do
|
describe 'dossier' do
|
||||||
subject { super().first }
|
subject { super().first }
|
||||||
it { expect(subject[:id]).to eq(dossier.id) }
|
it { expect(subject[:id]).to eq(dossier.id) }
|
||||||
it { expect(subject[:updated_at]).to eq("2008-09-01T10:05: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.000Z") }
|
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[:state]).to eq("initiated") }
|
||||||
it { expect(subject.keys.size).to eq(4) }
|
it { expect(subject.keys.size).to eq(4) }
|
||||||
end
|
end
|
||||||
|
@ -135,7 +135,7 @@ describe API::V1::DossiersController do
|
||||||
|
|
||||||
context 'when dossier exists and belongs to procedure' do
|
context 'when dossier exists and belongs to procedure' do
|
||||||
let(:procedure_id) { procedure.id }
|
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) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, motivation: "Motivation") } }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
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[:id]).to eq(dossier.id) }
|
||||||
it { expect(subject[:state]).to eq(dossier.state) }
|
it { expect(subject[:state]).to eq(dossier.state) }
|
||||||
it { expect(subject[:created_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.000Z') }
|
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[:archived]).to eq(dossier.archived) }
|
||||||
|
|
||||||
it { expect(subject.keys).to match_array(field_list) }
|
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.size).to eq 2 }
|
||||||
|
|
||||||
it { expect(subject.first[:body]).to eq 'plop' }
|
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' }
|
it { expect(subject.first[:email]).to eq 'plop@plip.com' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ describe FranceConnect::ParticulierController, type: :controller do
|
||||||
|
|
||||||
before { subject }
|
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
|
end
|
||||||
|
|
||||||
it { is_expected.to redirect_to(root_path) }
|
it { is_expected.to redirect_to(root_path) }
|
||||||
|
|
|
@ -250,11 +250,11 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Timecop.freeze(DateTime.now)
|
Timecop.freeze(Time.zone.now)
|
||||||
|
|
||||||
expect_any_instance_of(AttestationTemplate)
|
expect_any_instance_of(AttestationTemplate)
|
||||||
.to receive(:attestation_for)
|
.to receive(:attestation_for)
|
||||||
.with(have_attributes(motivation: "Yallah", processed_at: DateTime.now))
|
.with(have_attributes(motivation: "Yallah", processed_at: Time.zone.now))
|
||||||
end
|
end
|
||||||
|
|
||||||
after { Timecop.return }
|
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 => 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 => 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
|
@controller = StatsController.new
|
||||||
|
|
||||||
allow(@controller).to receive(:administration_signed_in?).and_return(false)
|
allow(@controller).to receive(:administration_signed_in?).and_return(false)
|
||||||
|
@ -53,7 +53,7 @@ describe StatsController, type: :controller do
|
||||||
|
|
||||||
describe '#cumulative_hash' do
|
describe '#cumulative_hash' do
|
||||||
before 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 => 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 => 40.days.ago)
|
||||||
FactoryBot.create(:procedure, :created_at => 45.days.ago, :updated_at => 20.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
|
it do
|
||||||
expect(subject).to eq({
|
expect(subject).to eq({
|
||||||
2.months.ago.beginning_of_month => 2,
|
Time.utc(2016, 8, 1) => 2,
|
||||||
1.month.ago.beginning_of_month => 4,
|
Time.utc(2016, 9, 1) => 4,
|
||||||
1.hour.ago.beginning_of_month => 5
|
Time.utc(2016, 10, 1) => 5
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -86,8 +86,8 @@ describe StatsController, type: :controller do
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(subject).to eq({
|
expect(subject).to eq({
|
||||||
2.months.ago.beginning_of_month => 2,
|
Time.utc(2016, 8, 1) => 2,
|
||||||
1.month.ago.beginning_of_month => 4
|
Time.utc(2016, 9, 1) => 4
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -102,18 +102,18 @@ describe StatsController, type: :controller do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
3.times do
|
3.times do
|
||||||
create(:procedure, published_at: Time.now, administrateur: administrateur_1)
|
create(:procedure, published_at: Time.zone.now, administrateur: administrateur_1)
|
||||||
end
|
end
|
||||||
|
|
||||||
2.times do
|
2.times do
|
||||||
create(:procedure, published_at: Time.now, administrateur: administrateur_2)
|
create(:procedure, published_at: Time.zone.now, administrateur: administrateur_2)
|
||||||
end
|
end
|
||||||
|
|
||||||
8.times do
|
8.times do
|
||||||
create(:procedure, published_at: Time.now, administrateur: administrateur_3)
|
create(:procedure, published_at: Time.zone.now, administrateur: administrateur_3)
|
||||||
end
|
end
|
||||||
|
|
||||||
create(:procedure, published_at: Time.now, administrateur: administrateur_4)
|
create(:procedure, published_at: Time.zone.now, administrateur: administrateur_4)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:association){ Procedure.all }
|
let(:association){ Procedure.all }
|
||||||
|
@ -234,7 +234,7 @@ describe StatsController, type: :controller do
|
||||||
let!(:avis_with_dossier) { create(:avis) }
|
let!(:avis_with_dossier) { create(:avis) }
|
||||||
let!(:dossier2) { create(:dossier) }
|
let!(:dossier2) { create(:dossier) }
|
||||||
|
|
||||||
before { Timecop.freeze(Time.now) }
|
before { Timecop.freeze(Time.zone.now) }
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
|
||||||
subject { StatsController.new.send(:avis_usage) }
|
subject { StatsController.new.send(:avis_usage) }
|
||||||
|
@ -244,7 +244,7 @@ describe StatsController, type: :controller do
|
||||||
|
|
||||||
describe "#avis_average_answer_time" do
|
describe "#avis_average_answer_time" do
|
||||||
before do
|
before do
|
||||||
Timecop.freeze(Time.now)
|
Timecop.freeze(Time.zone.now)
|
||||||
|
|
||||||
# 1 week ago
|
# 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
|
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) }
|
subject { StatsController.new.send(:avis_answer_percentages) }
|
||||||
|
|
||||||
before { Timecop.freeze(Time.now) }
|
before { Timecop.freeze(Time.zone.now) }
|
||||||
after { Timecop.return }
|
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]] }
|
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!(:dossier2) { create(:dossier, processed_at: 1.week.ago) }
|
||||||
let!(:dossier3) { 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 }
|
after { Timecop.return }
|
||||||
|
|
||||||
subject { StatsController.new.send(:motivation_usage_dossier) }
|
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!(:dossier2) { create(:dossier, processed_at: 1.week.ago) }
|
||||||
let!(:dossier3) { 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 }
|
after { Timecop.return }
|
||||||
|
|
||||||
subject { StatsController.new.send(:motivation_usage_procedure) }
|
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!(:procedure2) { create(:procedure, created_at: 2.weeks.ago) }
|
||||||
let!(:procedure3) { create(:procedure, created_at: 2.weeks.ago, cloned_from_library: true) }
|
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 }
|
after { Timecop.return }
|
||||||
|
|
||||||
subject { StatsController.new.send(:cloned_from_library_procedures_ratio) }
|
subject { StatsController.new.send(:cloned_from_library_procedures_ratio) }
|
||||||
|
|
|
@ -57,7 +57,7 @@ describe Users::RegistrationsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'and the user is confirmed' do
|
context 'and the user is confirmed' do
|
||||||
let(:confirmed_at) { DateTime.now }
|
let(:confirmed_at) { Time.zone.now }
|
||||||
|
|
||||||
before { subject }
|
before { subject }
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe DossierDecorator do
|
describe DossierDecorator do
|
||||||
let(:dossier) do
|
let(:dossier) do
|
||||||
dossier = create(:dossier, created_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.new(2015, 12, 24, 14, 10))
|
dossier.update_column('updated_at', Time.zone.local(2015, 12, 24, 14, 10))
|
||||||
dossier
|
dossier
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe ProcedureDecorator do
|
describe ProcedureDecorator do
|
||||||
let(:published_at) { Time.new(2017, 12, 24, 14, 12) }
|
let(:published_at) { Time.zone.local(2017, 12, 24, 14, 12) }
|
||||||
let(:procedure) { create(:procedure, published_at: published_at, created_at: Time.new(2015, 12, 24, 14, 10)) }
|
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) }
|
let!(:procedure_path) { create(:procedure_path, administrateur: create(:administrateur), procedure: procedure) }
|
||||||
|
|
||||||
subject { procedure.decorate }
|
subject { procedure.decorate }
|
||||||
|
|
|
@ -2,9 +2,9 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe ProceduresDecorator do
|
describe ProceduresDecorator do
|
||||||
before do
|
before do
|
||||||
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.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.new(2015, 12, 24, 14, 10))
|
create(:procedure, :published, created_at: Time.zone.local(2015, 12, 24, 14, 10))
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:procedure) { Procedure.all.page(1) }
|
let(:procedure) { Procedure.all.page(1) }
|
||||||
|
|
|
@ -2,7 +2,7 @@ FactoryBot.define do
|
||||||
factory :deleted_dossier do
|
factory :deleted_dossier do
|
||||||
dossier_id { 1111 }
|
dossier_id { 1111 }
|
||||||
state { Dossier.states.fetch(:en_construction) }
|
state { Dossier.states.fetch(:en_construction) }
|
||||||
deleted_at { DateTime.now }
|
deleted_at { Time.zone.now }
|
||||||
|
|
||||||
association :procedure, :published
|
association :procedure, :published
|
||||||
end
|
end
|
||||||
|
|
|
@ -155,7 +155,7 @@ FactoryBot.define do
|
||||||
|
|
||||||
trait :whitelisted do
|
trait :whitelisted do
|
||||||
after(:build) do |procedure, _evaluator|
|
after(:build) do |procedure, _evaluator|
|
||||||
procedure.update(whitelisted_at: DateTime.now)
|
procedure.update(whitelisted_at: Time.zone.now)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,6 @@ FactoryBot.define do
|
||||||
factory :user do
|
factory :user do
|
||||||
email { generate(:user_email) }
|
email { generate(:user_email) }
|
||||||
password { 'password' }
|
password { 'password' }
|
||||||
confirmed_at { DateTime.now }
|
confirmed_at { Time.zone.now }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,7 +35,7 @@ feature "procedure filters" do
|
||||||
add_column("Créé le")
|
add_column("Créé le")
|
||||||
within ".dossiers-table" do
|
within ".dossiers-table" do
|
||||||
expect(page).to have_link("Créé le")
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ feature 'The user' do
|
||||||
fill_in('text', with: 'super texte')
|
fill_in('text', with: 'super texte')
|
||||||
fill_in('textarea', with: 'super textarea')
|
fill_in('textarea', with: 'super textarea')
|
||||||
fill_in('date', with: '12/12/2012')
|
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')
|
fill_in('number', with: '42')
|
||||||
check('checkbox')
|
check('checkbox')
|
||||||
choose('Madame')
|
choose('Madame')
|
||||||
|
@ -67,7 +67,7 @@ feature 'The user' do
|
||||||
expect(page).to have_field('text', with: 'super texte')
|
expect(page).to have_field('text', with: 'super texte')
|
||||||
expect(page).to have_field('textarea', with: 'super textarea')
|
expect(page).to have_field('textarea', with: 'super textarea')
|
||||||
expect(page).to have_field('date', with: '2012-12-12')
|
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_field('number', with: '42')
|
||||||
expect(page).to have_checked_field('checkbox')
|
expect(page).to have_checked_field('checkbox')
|
||||||
expect(page).to have_checked_field('Madame')
|
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
|
describe "the user can see the mean time they are expected to wait" do
|
||||||
context "when the dossier is in construction" do
|
context "when the dossier is in construction" do
|
||||||
before 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)
|
visit dossier_path(dossier)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ describe 'Dossier details:' do
|
||||||
let(:dossier) { create(:dossier, :en_instruction, :for_individual, :with_commentaires, user: user, procedure: procedure) }
|
let(:dossier) { create(:dossier, :en_instruction, :for_individual, :with_commentaires, user: user, procedure: procedure) }
|
||||||
|
|
||||||
before do
|
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)
|
visit dossier_path(dossier)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ RSpec.describe CommentaireHelper, type: :helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.commentaire_date' do
|
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(:creation_date) { present_date }
|
||||||
let(:commentaire) do
|
let(:commentaire) do
|
||||||
Timecop.freeze(creation_date) { create(:commentaire, email: "michel@pref.fr") }
|
Timecop.freeze(creation_date) { create(:commentaire, email: "michel@pref.fr") }
|
||||||
|
@ -71,7 +71,7 @@ RSpec.describe CommentaireHelper, type: :helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when formatting the first day of the month' do
|
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
|
it 'includes the ordinal' do
|
||||||
expect(subject).to eq 'le 1er septembre à 10 h 05'
|
expect(subject).to eq 'le 1er septembre à 10 h 05'
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe DossierHelper, type: :helper do
|
RSpec.describe DossierHelper, type: :helper do
|
||||||
describe ".highlight_if_unseen_class" 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) }
|
subject { highlight_if_unseen_class(seen_at, updated_at) }
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ RSpec.describe DossierHelper, type: :helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when there is no last seen datetime" do
|
context "when there is no last seen datetime" do
|
||||||
let(:updated_at) { DateTime.now }
|
let(:updated_at) { Time.zone.now }
|
||||||
let(:seen_at) { nil }
|
let(:seen_at) { nil }
|
||||||
|
|
||||||
it { is_expected.to eq nil }
|
it { is_expected.to eq nil }
|
||||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
|
||||||
subject { Administrateurs::ActivateBeforeExpirationJob.perform_now }
|
subject { Administrateurs::ActivateBeforeExpirationJob.perform_now }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Timecop.freeze(DateTime.new(2018, 03, 20))
|
Timecop.freeze(Time.zone.local(2018, 03, 20))
|
||||||
administrateur.reload
|
administrateur.reload
|
||||||
allow(AdministrateurMailer).to receive(:activate_before_expiration).and_return(mailer_double)
|
allow(AdministrateurMailer).to receive(:activate_before_expiration).and_return(mailer_double)
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
|
||||||
|
|
||||||
context "created a long time ago" do
|
context "created a long time ago" do
|
||||||
before 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
|
subject
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
|
||||||
|
|
||||||
context "created 3 days ago" do
|
context "created 3 days ago" do
|
||||||
before 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
|
subject
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
|
||||||
|
|
||||||
context "created a long time ago" do
|
context "created a long time ago" do
|
||||||
before 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
|
subject
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
|
||||||
|
|
||||||
context "created 2 days ago" do
|
context "created 2 days ago" do
|
||||||
before 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
|
subject
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ describe 'AmazonV2RequestSigner' do
|
||||||
|
|
||||||
before { request_signer.sign(subject, 'fichier') }
|
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=') }
|
it { expect(subject['authorization']).to eq('AWS AKIAJFTRSGRH3RXX6D5Q:nkvviwZYb1V9HDrKyJZmY3Z8sSA=') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,8 +4,8 @@ describe '2018_03_06_clean_html_textareas#clean' do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:type_champ) { create(:type_de_champ_textarea, procedure: 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) { type_champ.champ.create(value: "<p>Gnahar<br>greu bouahaha</p>") }
|
||||||
let(:champ_date) { Time.local(1995) }
|
let(:champ_date) { Time.zone.local(1995) }
|
||||||
let(:rake_date) { Time.local(2018) }
|
let(:rake_date) { Time.zone.local(2018) }
|
||||||
let(:rake_task) { Rake::Task['2018_03_06_clean_html_textareas:clean'] }
|
let(:rake_task) { Rake::Task['2018_03_06_clean_html_textareas:clean'] }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -25,7 +25,7 @@ RSpec.describe GestionnaireMailer, type: :mailer do
|
||||||
dossiers_en_instruction_description: 'desc')
|
dossiers_en_instruction_description: 'desc')
|
||||||
|
|
||||||
{
|
{
|
||||||
start_date: DateTime.now,
|
start_date: Time.zone.now,
|
||||||
procedure_overviews: [procedure_overview]
|
procedure_overviews: [procedure_overview]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -115,7 +115,7 @@ describe AttestationTemplate, type: :model do
|
||||||
before do
|
before do
|
||||||
@logo = File.open('spec/fixtures/files/white.png')
|
@logo = File.open('spec/fixtures/files/white.png')
|
||||||
@signature = File.open('spec/fixtures/files/black.png')
|
@signature = File.open('spec/fixtures/files/black.png')
|
||||||
Timecop.freeze(Time.now)
|
Timecop.freeze(Time.zone.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe TagsSubstitutionConcern, type: :model do
|
||||||
let(:etablissement) { create(:etablissement) }
|
let(:etablissement) { create(:etablissement) }
|
||||||
let!(:dossier) { create(:dossier, procedure: procedure, individual: individual, etablissement: 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) }
|
subject { template_concern.send(:replace_tags, template, dossier) }
|
||||||
|
|
||||||
|
@ -187,9 +187,9 @@ describe TagsSubstitutionConcern, type: :model do
|
||||||
|
|
||||||
context "when using a date tag" do
|
context "when using a date tag" do
|
||||||
before do
|
before do
|
||||||
dossier.en_construction_at = DateTime.new(2001, 2, 3)
|
dossier.en_construction_at = Time.zone.local(2001, 2, 3)
|
||||||
dossier.en_instruction_at = DateTime.new(2004, 5, 6)
|
dossier.en_instruction_at = Time.zone.local(2004, 5, 6)
|
||||||
dossier.processed_at = DateTime.new(2007, 8, 9)
|
dossier.processed_at = Time.zone.local(2007, 8, 9)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with date de dépôt" do
|
context "with date de dépôt" do
|
||||||
|
|
|
@ -479,9 +479,9 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when they are a lot of advice' do
|
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_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: DateTime.parse('9/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: DateTime.parse('11/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(gestionnaire)).to match([avis_2, avis_1, avis_3]) }
|
||||||
it { expect(dossier.avis_for(expert_1)).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
|
describe '#update_state_dates' do
|
||||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||||
let(:dossier) { create(:dossier, state: state) }
|
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) }
|
before { Timecop.freeze(beginning_of_day) }
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
@ -566,9 +566,9 @@ describe Dossier do
|
||||||
describe '.downloadable_sorted' do
|
describe '.downloadable_sorted' do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:brouillon)) }
|
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!(: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: DateTime.parse('01/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: DateTime.parse('02/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 }
|
subject { procedure.dossiers.downloadable_sorted }
|
||||||
|
|
||||||
|
@ -734,7 +734,7 @@ describe Dossier do
|
||||||
|
|
||||||
describe 'updated_at' do
|
describe 'updated_at' do
|
||||||
let!(:dossier) { create(:dossier) }
|
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) }
|
before { Timecop.freeze(modif_date) }
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
@ -982,10 +982,10 @@ describe Dossier do
|
||||||
context "retention date" do
|
context "retention date" do
|
||||||
let(:procedure) { create(:procedure, duree_conservation_dossiers_dans_ds: 6) }
|
let(:procedure) { create(:procedure, duree_conservation_dossiers_dans_ds: 6) }
|
||||||
let(:uninstructed_dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
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(: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(: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) }
|
before { Timecop.freeze(modif_date) }
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
@ -993,7 +993,7 @@ describe Dossier do
|
||||||
describe "#retention_end_date" do
|
describe "#retention_end_date" do
|
||||||
it { expect(uninstructed_dossier.retention_end_date).to be_nil }
|
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(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) }
|
it { expect(long_expired_dossier.retention_end_date).to eq(6.months.ago) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -138,8 +138,8 @@ describe Gestionnaire, type: :model do
|
||||||
describe 'last_week_overview' do
|
describe 'last_week_overview' do
|
||||||
let!(:gestionnaire2) { create(:gestionnaire) }
|
let!(:gestionnaire2) { create(:gestionnaire) }
|
||||||
subject { gestionnaire2.last_week_overview }
|
subject { gestionnaire2.last_week_overview }
|
||||||
let(:friday) { DateTime.new(2017, 5, 12) }
|
let(:friday) { Time.zone.local(2017, 5, 12) }
|
||||||
let(:monday) { DateTime.now.beginning_of_week }
|
let(:monday) { Time.zone.now.beginning_of_week }
|
||||||
|
|
||||||
before { Timecop.freeze(friday) }
|
before { Timecop.freeze(friday) }
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
@ -313,7 +313,7 @@ describe Gestionnaire, type: :model do
|
||||||
context 'when gestionnaire update it s public champs last seen' do
|
context 'when gestionnaire update it s public champs last seen' do
|
||||||
let(:follow) { gestionnaire.follows.find_by(dossier: dossier) }
|
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 { is_expected.to match([]) }
|
||||||
it { expect(gestionnaire_2.notifications_for_procedure(procedure)).to match([dossier.id]) }
|
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
|
describe '#mark_tab_as_seen' do
|
||||||
let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
||||||
let(:gestionnaire) { dossier.follows.first.gestionnaire }
|
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
|
context 'when demande is acknowledged' do
|
||||||
let(:follow) { gestionnaire.follows.find_by(dossier: dossier) }
|
let(:follow) { gestionnaire.follows.find_by(dossier: dossier) }
|
||||||
|
|
|
@ -2,8 +2,8 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe ProcedureOverview, type: :model do
|
describe ProcedureOverview, type: :model do
|
||||||
let(:procedure) { create(:procedure, libelle: 'libelle') }
|
let(:procedure) { create(:procedure, libelle: 'libelle') }
|
||||||
let(:friday) { DateTime.new(2017, 5, 12) } # vendredi 12 mai 2017, de la semaine du 8 mai
|
let(:friday) { Time.zone.local(2017, 5, 12) } # vendredi 12 mai 2017, de la semaine du 8 mai
|
||||||
let(:monday) { DateTime.new(2017, 5, 8) }
|
let(:monday) { Time.zone.local(2017, 5, 8) }
|
||||||
|
|
||||||
before { Timecop.freeze(friday) }
|
before { Timecop.freeze(friday) }
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
|
|
@ -133,25 +133,25 @@ describe ProcedurePresentation do
|
||||||
|
|
||||||
context 'for created_at column' do
|
context 'for created_at column' do
|
||||||
let(:column) { 'created_at' }
|
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
|
end
|
||||||
|
|
||||||
context 'for en_construction_at column' do
|
context 'for en_construction_at column' do
|
||||||
let(:column) { 'en_construction_at' }
|
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
|
end
|
||||||
|
|
||||||
context 'for updated_at column' do
|
context 'for updated_at column' do
|
||||||
let(:column) { 'updated_at' }
|
let(:column) { 'updated_at' }
|
||||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -236,11 +236,11 @@ describe ProcedurePresentation do
|
||||||
let!(:older_dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
let!(:older_dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
notified_dossier.champs.first.touch(time: DateTime.new(2018, 9, 20))
|
notified_dossier.champs.first.touch(time: Time.zone.local(2018, 9, 20))
|
||||||
create(:follow, gestionnaire: gestionnaire, dossier: notified_dossier, demande_seen_at: DateTime.new(2018, 9, 10))
|
create(:follow, gestionnaire: gestionnaire, dossier: notified_dossier, demande_seen_at: Time.zone.local(2018, 9, 10))
|
||||||
notified_dossier.touch(time: DateTime.new(2018, 9, 20))
|
notified_dossier.touch(time: Time.zone.local(2018, 9, 20))
|
||||||
recent_dossier.touch(time: DateTime.new(2018, 9, 25))
|
recent_dossier.touch(time: Time.zone.local(2018, 9, 25))
|
||||||
older_dossier.touch(time: DateTime.new(2018, 5, 13))
|
older_dossier.touch(time: Time.zone.local(2018, 5, 13))
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'in ascending order' do
|
context 'in ascending order' do
|
||||||
|
@ -269,16 +269,16 @@ describe ProcedurePresentation do
|
||||||
|
|
||||||
context 'for created_at column' do
|
context 'for created_at column' do
|
||||||
let(:column) { 'created_at' }
|
let(:column) { 'created_at' }
|
||||||
let!(:recent_dossier) { Timecop.freeze(DateTime.new(2018, 10, 17)) { create(:dossier, procedure: procedure) } }
|
let!(:recent_dossier) { Timecop.freeze(Time.zone.local(2018, 10, 17)) { create(:dossier, procedure: procedure) } }
|
||||||
let!(:older_dossier) { Timecop.freeze(DateTime.new(2003, 11, 11)) { 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)) }
|
it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for en_construction_at column' do
|
context 'for en_construction_at column' do
|
||||||
let(:column) { 'en_construction_at' }
|
let(:column) { 'en_construction_at' }
|
||||||
let!(:recent_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2018, 10, 17)) }
|
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: DateTime.new(2013, 1, 1)) }
|
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)) }
|
it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) }
|
||||||
end
|
end
|
||||||
|
@ -289,8 +289,8 @@ describe ProcedurePresentation do
|
||||||
let(:older_dossier) { create(:dossier, procedure: procedure) }
|
let(:older_dossier) { create(:dossier, procedure: procedure) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
recent_dossier.touch(time: DateTime.new(2018, 9, 25))
|
recent_dossier.touch(time: Time.zone.local(2018, 9, 25))
|
||||||
older_dossier.touch(time: DateTime.new(2018, 5, 13))
|
older_dossier.touch(time: Time.zone.local(2018, 5, 13))
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) }
|
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 self table' do
|
||||||
context 'for created_at column' do
|
context 'for created_at column' do
|
||||||
let!(:kept_dossier) { create(:dossier, procedure: procedure, created_at: DateTime.new(2018, 9, 18, 14, 28)) }
|
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: DateTime.new(2018, 9, 17, 23, 59)) }
|
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' }] }
|
let(:filter) { [{ 'table' => 'self', 'column' => 'created_at', 'value' => '18/9/2018' }] }
|
||||||
|
|
||||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for en_construction_at column' do
|
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!(: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: DateTime.new(2013, 1, 1)) }
|
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' }] }
|
let(:filter) { [{ 'table' => 'self', 'column' => 'en_construction_at', 'value' => '17/10/2018' }] }
|
||||||
|
|
||||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
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' }] }
|
let(:filter) { [{ 'table' => 'self', 'column' => 'updated_at', 'value' => '18/9/2018' }] }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
kept_dossier.touch(time: DateTime.new(2018, 9, 18, 14, 28))
|
kept_dossier.touch(time: Time.zone.local(2018, 9, 18, 14, 28))
|
||||||
discarded_dossier.touch(time: DateTime.new(2018, 9, 17, 23, 59))
|
discarded_dossier.touch(time: Time.zone.local(2018, 9, 17, 23, 59))
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'for a malformed date' do
|
||||||
|
let(:filter) { [{ 'table' => 'self', 'column' => 'updated_at', 'value' => 'malformed date' }] }
|
||||||
|
it { is_expected.to match([]) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for type_de_champ table' do
|
context 'for type_de_champ table' do
|
||||||
|
@ -436,8 +441,8 @@ describe ProcedurePresentation do
|
||||||
|
|
||||||
context 'for etablissement table' do
|
context 'for etablissement table' do
|
||||||
context 'for entreprise_date_creation column' 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!(: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: DateTime.new(2008, 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' }] }
|
let(:filter) { [{ 'table' => 'etablissement', 'column' => 'entreprise_date_creation', 'value' => '21/6/2018' }] }
|
||||||
|
|
||||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||||
|
|
|
@ -429,7 +429,7 @@ describe Procedure do
|
||||||
|
|
||||||
describe '#publish!' do
|
describe '#publish!' do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:now) { Time.now.beginning_of_minute }
|
let(:now) { Time.zone.now.beginning_of_minute }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Timecop.freeze(now)
|
Timecop.freeze(now)
|
||||||
|
@ -446,8 +446,8 @@ describe Procedure do
|
||||||
|
|
||||||
describe "#brouillon?" do
|
describe "#brouillon?" do
|
||||||
let(:procedure_brouillon) { Procedure.new() }
|
let(:procedure_brouillon) { Procedure.new() }
|
||||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_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.now, archived_at: Time.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_brouillon.brouillon?).to be_truthy }
|
||||||
it { expect(procedure_publiee.brouillon?).to be_falsey }
|
it { expect(procedure_publiee.brouillon?).to be_falsey }
|
||||||
|
@ -456,8 +456,8 @@ describe Procedure do
|
||||||
|
|
||||||
describe "#publiee?" do
|
describe "#publiee?" do
|
||||||
let(:procedure_brouillon) { Procedure.new() }
|
let(:procedure_brouillon) { Procedure.new() }
|
||||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_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.now, archived_at: Time.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_brouillon.publiee?).to be_falsey }
|
||||||
it { expect(procedure_publiee.publiee?).to be_truthy }
|
it { expect(procedure_publiee.publiee?).to be_truthy }
|
||||||
|
@ -466,8 +466,8 @@ describe Procedure do
|
||||||
|
|
||||||
describe "#archivee?" do
|
describe "#archivee?" do
|
||||||
let(:procedure_brouillon) { Procedure.new() }
|
let(:procedure_brouillon) { Procedure.new() }
|
||||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_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.now, archived_at: Time.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_brouillon.archivee?).to be_falsey }
|
||||||
it { expect(procedure_publiee.archivee?).to be_falsey }
|
it { expect(procedure_publiee.archivee?).to be_falsey }
|
||||||
|
@ -476,8 +476,8 @@ describe Procedure do
|
||||||
|
|
||||||
describe "#publiee_ou_archivee?" do
|
describe "#publiee_ou_archivee?" do
|
||||||
let(:procedure_brouillon) { Procedure.new() }
|
let(:procedure_brouillon) { Procedure.new() }
|
||||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_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.now, archived_at: Time.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_brouillon.publiee_ou_archivee?).to be_falsey }
|
||||||
it { expect(procedure_publiee.publiee_ou_archivee?).to be_truthy }
|
it { expect(procedure_publiee.publiee_ou_archivee?).to be_truthy }
|
||||||
|
@ -487,7 +487,7 @@ describe Procedure do
|
||||||
describe 'archive' do
|
describe 'archive' do
|
||||||
let(:procedure) { create(:procedure, :published) }
|
let(:procedure) { create(:procedure, :published) }
|
||||||
let(:procedure_path) { ProcedurePath.find(procedure.procedure_path.id) }
|
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
|
before do
|
||||||
Timecop.freeze(now)
|
Timecop.freeze(now)
|
||||||
procedure.archive!
|
procedure.archive!
|
||||||
|
@ -627,7 +627,7 @@ describe Procedure do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#export_filename" do
|
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 }
|
subject { procedure.export_filename }
|
||||||
|
|
||||||
|
@ -716,7 +716,7 @@ describe Procedure do
|
||||||
context 'which is termine' do
|
context 'which is termine' do
|
||||||
before do
|
before do
|
||||||
dossier.accepte!
|
dossier.accepte!
|
||||||
processed_date = DateTime.parse('12/12/2012')
|
processed_date = Time.zone.parse('12/12/2012')
|
||||||
instruction_date = processed_date - 1.day
|
instruction_date = processed_date - 1.day
|
||||||
dossier.update(en_instruction_at: instruction_date, processed_at: processed_date)
|
dossier.update(en_instruction_at: instruction_date, processed_at: processed_date)
|
||||||
end
|
end
|
||||||
|
|
|
@ -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: DateTime.parse(birthdate),
|
birthdate: Date.parse(birthdate),
|
||||||
birthplace: birthplace,
|
birthplace: birthplace,
|
||||||
gender: gender,
|
gender: gender,
|
||||||
email_france_connect: email,
|
email_france_connect: email,
|
||||||
|
|
|
@ -6,6 +6,6 @@ describe RemoteDownloader do
|
||||||
subject { described_class.new filename }
|
subject { described_class.new filename }
|
||||||
|
|
||||||
describe '#url' do
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue