Enable some Rails cops
This commit is contained in:
parent
da3d9d403a
commit
0a9f442260
83 changed files with 180 additions and 178 deletions
44
.rubocop.yml
44
.rubocop.yml
|
@ -640,22 +640,22 @@ Performance/UriDefaultParser:
|
|||
Enabled: true
|
||||
|
||||
Rails/ActionFilter:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/ActiveRecordAliases:
|
||||
Enabled: true
|
||||
|
||||
Rails/ActiveSupportAliases:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/ApplicationJob:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/ApplicationRecord:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/Blank:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/CreateTableWithTimestamps:
|
||||
Enabled: false
|
||||
|
@ -667,28 +667,30 @@ Rails/Delegate:
|
|||
Enabled: false
|
||||
|
||||
Rails/DelegateAllowBlank:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/DynamicFindBy:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
Exclude:
|
||||
- "spec/features/**/*.rb"
|
||||
|
||||
Rails/EnumUniqueness:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/EnvironmentComparison:
|
||||
Enabled: false
|
||||
|
||||
Rails/Exit:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/FilePath:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/FindBy:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/FindEach:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/HasAndBelongsToMany:
|
||||
Enabled: false
|
||||
|
@ -697,7 +699,7 @@ Rails/HasManyOrHasOneDependent:
|
|||
Enabled: false
|
||||
|
||||
Rails/HttpPositionalArguments:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/InverseOf:
|
||||
Enabled: false
|
||||
|
@ -715,10 +717,10 @@ Rails/OutputSafety:
|
|||
Enabled: true
|
||||
|
||||
Rails/PluralizationGrammar:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/Presence:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/Present:
|
||||
Enabled: true
|
||||
|
@ -730,22 +732,22 @@ Rails/RedundantReceiverInWithOptions:
|
|||
Enabled: true
|
||||
|
||||
Rails/RelativeDateConstant:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/RequestReferer:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/ReversibleMigration:
|
||||
Enabled: false
|
||||
|
||||
Rails/SafeNavigation:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/SaveBang:
|
||||
Enabled: false
|
||||
|
||||
Rails/ScopeArgs:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/SkipsModelValidations:
|
||||
Enabled: false
|
||||
|
@ -754,13 +756,13 @@ Rails/TimeZone:
|
|||
Enabled: false
|
||||
|
||||
Rails/UniqBeforePluck:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails/UnknownEnv:
|
||||
Enabled: false
|
||||
|
||||
Rails/Validation:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Rails:
|
||||
Enabled: true
|
||||
|
|
|
@ -19,7 +19,7 @@ class Admin::GestionnairesController < AdminController
|
|||
|
||||
def create
|
||||
email = params[:gestionnaire][:email].downcase
|
||||
@gestionnaire = Gestionnaire.find_by_email(email)
|
||||
@gestionnaire = Gestionnaire.find_by(email: email)
|
||||
procedure_id = params[:procedure_id]
|
||||
|
||||
if @gestionnaire.nil?
|
||||
|
|
|
@ -132,7 +132,7 @@ class Admin::ProceduresController < AdminController
|
|||
return redirect_to admin_procedures_path
|
||||
end
|
||||
|
||||
procedure_path = ProcedurePath.find_by_path(params[:procedure_path])
|
||||
procedure_path = ProcedurePath.find_by(path: params[:procedure_path])
|
||||
if procedure_path
|
||||
if procedure_path.administrateur_id == current_administrateur.id
|
||||
procedure_path.procedure.archive
|
||||
|
@ -154,7 +154,7 @@ class Admin::ProceduresController < AdminController
|
|||
end
|
||||
|
||||
def transfer
|
||||
admin = Administrateur.find_by_email(params[:email_admin].downcase)
|
||||
admin = Administrateur.find_by(email: params[:email_admin].downcase)
|
||||
|
||||
if admin.nil?
|
||||
render '/admin/procedures/transfer', formats: 'js', status: 404
|
||||
|
|
|
@ -13,7 +13,7 @@ class APIController < ApplicationController
|
|||
end
|
||||
|
||||
def current_administrateur
|
||||
@administrateur ||= Administrateur.find_by_api_token(params[:token])
|
||||
@administrateur ||= Administrateur.find_by(api_token: params[:token])
|
||||
end
|
||||
|
||||
def default_format_json
|
||||
|
|
|
@ -9,7 +9,7 @@ class InvitesController < ApplicationController
|
|||
|
||||
email = params[:email].downcase
|
||||
|
||||
user = User.find_by_email(email)
|
||||
user = User.find_by(email: email)
|
||||
invite = class_var.create(dossier: dossier, user: user, email: email, email_sender: email_sender)
|
||||
|
||||
if invite.valid?
|
||||
|
|
|
@ -13,7 +13,7 @@ module NewGestionnaire
|
|||
@avis_a_donner = gestionnaire_avis.without_answer
|
||||
@avis_donnes = gestionnaire_avis.with_answer
|
||||
|
||||
@statut = params[:statut].present? ? params[:statut] : A_DONNER_STATUS
|
||||
@statut = params[:statut].presence || A_DONNER_STATUS
|
||||
|
||||
@avis = case @statut
|
||||
when A_DONNER_STATUS
|
||||
|
|
|
@ -76,7 +76,7 @@ module NewGestionnaire
|
|||
filtered_sorted_ids = sorted_ids
|
||||
end
|
||||
|
||||
page = params[:page].present? ? params[:page] : 1
|
||||
page = params[:page].presence || 1
|
||||
|
||||
filtered_sorted_paginated_ids = Kaminari
|
||||
.paginate_array(filtered_sorted_ids)
|
||||
|
@ -187,7 +187,7 @@ module NewGestionnaire
|
|||
private
|
||||
|
||||
def statut
|
||||
@statut ||= params[:statut].present? ? params[:statut] : 'a-suivre'
|
||||
@statut ||= (params[:statut].presence || 'a-suivre')
|
||||
end
|
||||
|
||||
def procedure
|
||||
|
|
|
@ -170,7 +170,7 @@ class StatsController < ApplicationController
|
|||
end
|
||||
|
||||
def avis_usage
|
||||
[3.week.ago, 2.week.ago, 1.week.ago].map do |min_date|
|
||||
[3.weeks.ago, 2.weeks.ago, 1.week.ago].map do |min_date|
|
||||
max_date = min_date + 1.week
|
||||
|
||||
weekly_dossiers = Dossier.includes(:avis).where(created_at: min_date..max_date).to_a
|
||||
|
@ -189,7 +189,7 @@ class StatsController < ApplicationController
|
|||
end
|
||||
|
||||
def avis_average_answer_time
|
||||
[3.week.ago, 2.week.ago, 1.week.ago].map do |min_date|
|
||||
[3.weeks.ago, 2.weeks.ago, 1.week.ago].map do |min_date|
|
||||
max_date = min_date + 1.week
|
||||
|
||||
average = Avis.with_answer
|
||||
|
@ -203,7 +203,7 @@ class StatsController < ApplicationController
|
|||
end
|
||||
|
||||
def avis_answer_percentages
|
||||
[3.week.ago, 2.week.ago, 1.week.ago].map do |min_date|
|
||||
[3.weeks.ago, 2.weeks.ago, 1.week.ago].map do |min_date|
|
||||
max_date = min_date + 1.week
|
||||
|
||||
weekly_avis = Avis.where(created_at: min_date..max_date)
|
||||
|
@ -222,7 +222,7 @@ class StatsController < ApplicationController
|
|||
end
|
||||
|
||||
def motivation_usage_dossier
|
||||
[3.week.ago, 2.week.ago, 1.week.ago].map do |date|
|
||||
[3.weeks.ago, 2.weeks.ago, 1.week.ago].map do |date|
|
||||
min_date = date.beginning_of_week
|
||||
max_date = date.end_of_week
|
||||
|
||||
|
@ -241,7 +241,7 @@ class StatsController < ApplicationController
|
|||
end
|
||||
|
||||
def motivation_usage_procedure
|
||||
[3.week.ago, 2.week.ago, 1.week.ago].map do |date|
|
||||
[3.weeks.ago, 2.weeks.ago, 1.week.ago].map do |date|
|
||||
min_date = date.beginning_of_week
|
||||
max_date = date.end_of_week
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ class Users::DescriptionController < UsersController
|
|||
flash.notice = 'Nouveaux fichiers envoyés' if flash.alert.nil?
|
||||
end
|
||||
|
||||
return redirect_to users_dossiers_invite_path(id: current_user.invites.find_by_dossier_id(@dossier.id).id) if invite
|
||||
return redirect_to users_dossiers_invite_path(id: current_user.invites.find_by(dossier_id: @dossier.id).id) if invite
|
||||
|
||||
redirect_to users_dossier_recapitulatif_path
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class Users::Dossiers::InvitesController < UsersController
|
||||
def authenticate_user!
|
||||
session["user_return_to"] = request.fullpath
|
||||
return redirect_to new_user_registration_path(user_email: params[:email]) if params[:email].present? && User.find_by_email(params[:email]).nil?
|
||||
return redirect_to new_user_registration_path(user_email: params[:email]) if params[:email].present? && User.find_by(email: params[:email]).nil?
|
||||
|
||||
super
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ class EntrepriseDecorator < Draper::Decorator
|
|||
delegate_all
|
||||
|
||||
def raison_sociale_or_name
|
||||
raison_sociale.blank? ? "#{nom} #{prenom}" : raison_sociale
|
||||
raison_sociale.presence || "#{nom} #{prenom}"
|
||||
end
|
||||
|
||||
def effectif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Administrateur < ActiveRecord::Base
|
||||
class Administrateur < ApplicationRecord
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Administration < ActiveRecord::Base
|
||||
class Administration < ApplicationRecord
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :rememberable, :trackable, :validatable, :omniauthable, omniauth_providers: [:github]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class AssignTo < ActiveRecord::Base
|
||||
class AssignTo < ApplicationRecord
|
||||
belongs_to :procedure
|
||||
belongs_to :gestionnaire
|
||||
has_one :procedure_presentation, dependent: :destroy
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Cadastre < ActiveRecord::Base
|
||||
class Cadastre < ApplicationRecord
|
||||
belongs_to :dossier, touch: true
|
||||
|
||||
def geometry
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Cerfa < ActiveRecord::Base
|
||||
class Cerfa < ApplicationRecord
|
||||
belongs_to :dossier, touch: true
|
||||
belongs_to :user
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Champ < ActiveRecord::Base
|
||||
class Champ < ApplicationRecord
|
||||
self.inheritance_column = :_type_disabled
|
||||
|
||||
belongs_to :dossier, touch: true
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Commentaire < ActiveRecord::Base
|
||||
class Commentaire < ApplicationRecord
|
||||
belongs_to :dossier, touch: true
|
||||
belongs_to :champ
|
||||
belongs_to :piece_justificative
|
||||
|
@ -6,7 +6,7 @@ class Commentaire < ActiveRecord::Base
|
|||
mount_uploader :file, CommentaireFileUploader
|
||||
validates :file, file_size: { maximum: 20.megabytes, message: "La taille du fichier doit être inférieure à 20 Mo" }
|
||||
validate :is_virus_free?
|
||||
validates_presence_of :body, message: "Votre message ne peut être vide"
|
||||
validates :body, presence: { message: "Votre message ne peut être vide" }
|
||||
|
||||
default_scope { order(created_at: :asc) }
|
||||
scope :updated_since?, -> (date) { where('commentaires.updated_at > ?', date) }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Dossier < ActiveRecord::Base
|
||||
class Dossier < ApplicationRecord
|
||||
enum state: {
|
||||
brouillon: 'brouillon',
|
||||
en_construction: 'en_construction',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class DropDownList < ActiveRecord::Base
|
||||
class DropDownList < ApplicationRecord
|
||||
belongs_to :type_de_champ
|
||||
|
||||
def options
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class Entreprise < ActiveRecord::Base
|
||||
class Entreprise < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
has_one :etablissement, dependent: :destroy
|
||||
has_one :rna_information, dependent: :destroy
|
||||
|
||||
validates_presence_of :siren
|
||||
validates_uniqueness_of :dossier_id
|
||||
validates :siren, presence: true
|
||||
validates :dossier_id, uniqueness: true
|
||||
|
||||
accepts_nested_attributes_for :rna_information
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Etablissement < ActiveRecord::Base
|
||||
class Etablissement < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
belongs_to :entreprise
|
||||
|
||||
|
@ -7,7 +7,7 @@ class Etablissement < ActiveRecord::Base
|
|||
accepts_nested_attributes_for :exercices
|
||||
accepts_nested_attributes_for :entreprise
|
||||
|
||||
validates_uniqueness_of :dossier_id
|
||||
validates :dossier_id, uniqueness: true
|
||||
|
||||
def geo_adresse
|
||||
[numero_voie, type_voie, nom_voie, complement_adresse, code_postal, localite].join(' ')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Exercice < ActiveRecord::Base
|
||||
class Exercice < ApplicationRecord
|
||||
belongs_to :etablissement
|
||||
|
||||
validates :ca, presence: true, allow_blank: false, allow_nil: false
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class Follow < ActiveRecord::Base
|
||||
class Follow < ApplicationRecord
|
||||
belongs_to :gestionnaire
|
||||
belongs_to :dossier
|
||||
|
||||
validates_uniqueness_of :gestionnaire_id, :scope => :dossier_id
|
||||
validates :gestionnaire_id, uniqueness: { scope: :dossier_id }
|
||||
|
||||
before_create :set_default_date
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class FranceConnectInformation < ActiveRecord::Base
|
||||
class FranceConnectInformation < ApplicationRecord
|
||||
belongs_to :user
|
||||
|
||||
validates :france_connect_particulier_id, presence: true, allow_blank: false, allow_nil: false
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Gestionnaire < ActiveRecord::Base
|
||||
class Gestionnaire < ApplicationRecord
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class Individual < ActiveRecord::Base
|
||||
class Individual < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
|
||||
validates_uniqueness_of :dossier_id
|
||||
validates :dossier_id, uniqueness: true
|
||||
validates :gender, presence: true, allow_nil: false, on: :update
|
||||
validates :nom, presence: true, allow_blank: false, allow_nil: false, on: :update
|
||||
validates :prenom, presence: true, allow_blank: false, allow_nil: false, on: :update
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class Invite < ActiveRecord::Base
|
||||
class Invite < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
belongs_to :user
|
||||
|
||||
validates_presence_of :email
|
||||
validates_uniqueness_of :email, :scope => :dossier_id
|
||||
validates :email, presence: true
|
||||
validates :email, uniqueness: { scope: :dossier_id }
|
||||
|
||||
validates :email, email_format: true
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class ModuleAPICarto < ActiveRecord::Base
|
||||
class ModuleAPICarto < ApplicationRecord
|
||||
belongs_to :procedure
|
||||
|
||||
validates :use_api_carto, presence: true, allow_blank: true, allow_nil: false
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class PieceJustificative < ActiveRecord::Base
|
||||
class PieceJustificative < ApplicationRecord
|
||||
belongs_to :dossier, touch: true
|
||||
belongs_to :type_de_piece_justificative
|
||||
has_one :commentaire
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Procedure < ActiveRecord::Base
|
||||
class Procedure < ApplicationRecord
|
||||
has_many :types_de_piece_justificative, -> { order "order_place ASC" }, dependent: :destroy
|
||||
has_many :types_de_champ, -> { public_only }, dependent: :destroy
|
||||
has_many :types_de_champ_private, -> { private_only }, class_name: 'TypeDeChamp', dependent: :destroy
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class ProcedurePath < ActiveRecord::Base
|
||||
class ProcedurePath < ApplicationRecord
|
||||
validates :path, format: { with: /\A[a-z0-9_\-]{3,50}\z/ }, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :administrateur_id, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :procedure_id, presence: true, allow_blank: false, allow_nil: false
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class ProcedurePresentation < ActiveRecord::Base
|
||||
class ProcedurePresentation < ApplicationRecord
|
||||
belongs_to :assign_to
|
||||
|
||||
def displayed_fields
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class QuartierPrioritaire < ActiveRecord::Base
|
||||
class QuartierPrioritaire < ApplicationRecord
|
||||
belongs_to :dossier, touch: true
|
||||
|
||||
def geometry
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class RNAInformation < ActiveRecord::Base
|
||||
class RNAInformation < ApplicationRecord
|
||||
belongs_to :entreprise
|
||||
|
||||
validates :association_id, presence: true, allow_blank: false, allow_nil: false
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# See:
|
||||
# - https://robots.thoughtbot.com/implementing-multi-table-full-text-search-with-postgres
|
||||
# - http://calebthompson.io/talks/search.html
|
||||
class Search < ActiveRecord::Base
|
||||
class Search < ApplicationRecord
|
||||
# :nodoc:
|
||||
#
|
||||
# Englobs a search result (actually a collection of Search objects) so it acts
|
||||
|
|
|
@ -4,7 +4,7 @@ class Siret
|
|||
|
||||
attr_accessor :siret
|
||||
|
||||
validates_presence_of :siret
|
||||
validates :siret, presence: true
|
||||
validates :siret, siret_format: true
|
||||
|
||||
before_validation :remove_whitespace
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class TypeDeChamp < ActiveRecord::Base
|
||||
class TypeDeChamp < ApplicationRecord
|
||||
self.inheritance_column = :_type_disabled
|
||||
|
||||
enum type_champs: {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class TypeDePieceJustificative < ActiveRecord::Base
|
||||
class TypeDePieceJustificative < ApplicationRecord
|
||||
has_many :pieces_justificatives, dependent: :destroy
|
||||
|
||||
belongs_to :procedure
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class User < ActiveRecord::Base
|
||||
class User < ApplicationRecord
|
||||
enum loged_in_with_france_connect: {
|
||||
particulier: 'particulier',
|
||||
entreprise: 'entreprise'
|
||||
|
@ -21,7 +21,7 @@ class User < ActiveRecord::Base
|
|||
include CredentialsSyncableConcern
|
||||
|
||||
def self.find_for_france_connect email, siret
|
||||
user = User.find_by_email(email)
|
||||
user = User.find_by(email: email)
|
||||
if user.nil?
|
||||
return User.create(email: email, password: Devise.friendly_token[0, 20], siret: siret)
|
||||
else
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class StagingAuthService
|
||||
CONFIG_PATH = Rails.root.join("config/basic_auth.yml")
|
||||
CONFIG_PATH = Rails.root.join("config", "basic_auth.yml")
|
||||
|
||||
def self.authenticate(username, password)
|
||||
if enabled?
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class AttestationTemplateLogoUploader < BaseUploader
|
||||
def root
|
||||
File.join(Rails.root, 'public')
|
||||
Rails.root.join("public")
|
||||
end
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class AttestationTemplateSignatureUploader < BaseUploader
|
||||
def root
|
||||
File.join(Rails.root, 'public')
|
||||
Rails.root.join("public")
|
||||
end
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class AttestationUploader < BaseUploader
|
||||
def root
|
||||
File.join(Rails.root, 'public')
|
||||
Rails.root.join("public")
|
||||
end
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class CommentaireFileUploader < BaseUploader
|
||||
def root
|
||||
File.join(Rails.root, 'public')
|
||||
Rails.root.join("public")
|
||||
end
|
||||
|
||||
if Features.remote_storage
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'securerandom'
|
||||
|
||||
class LocalDownloader
|
||||
BASE_PATH_DISK = File.join(Rails.root, "public/downloads/")
|
||||
BASE_PATH_DISK = Rails.root.join("public", "downloads")
|
||||
|
||||
def initialize(filename, filename_suffix = '')
|
||||
@filename = filename.to_s
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class ProcedureLogoUploader < BaseUploader
|
||||
def root
|
||||
File.join(Rails.root, "public")
|
||||
Rails.root.join("public")
|
||||
end
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
|
|
|
@ -2,7 +2,7 @@ Apipie.configure do |config|
|
|||
config.app_name = "API demarches-simplifiees.fr"
|
||||
config.api_base_url = "/api/v1"
|
||||
config.doc_base_url = "/docs"
|
||||
config.api_controllers_matcher = File.join(Rails.root, "app", "controllers","api","v1", "**","*.rb")
|
||||
config.api_controllers_matcher = Rails.root.join("app", "controllers"," api", "v1", "**", "*.rb")
|
||||
config.markup = Apipie::Markup::Markdown.new
|
||||
config.default_version = '1.0'
|
||||
config.validate = false
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
require_relative 'features'
|
||||
|
||||
if Rails.env.test?
|
||||
Fog.credentials_path = Rails.root.join('config/fog_credentials.test.yml')
|
||||
Fog.credentials_path = Rails.root.join('config', 'fog_credentials.test.yml')
|
||||
else
|
||||
Fog.credentials_path = Rails.root.join('config/fog_credentials.yml')
|
||||
Fog.credentials_path = Rails.root.join('config', 'fog_credentials.yml')
|
||||
end
|
||||
|
||||
CarrierWave.configure do |config|
|
||||
|
@ -20,7 +20,7 @@ CarrierWave.configure do |config|
|
|||
# they will not be available for public (non-authenticated) downloading
|
||||
config.root = Rails.root
|
||||
|
||||
config.cache_dir = "#{Rails.root}/uploads"
|
||||
config.cache_dir = Rails.root.join("uploads")
|
||||
|
||||
config.fog_public = true
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ FRANCE_CONNECT = if Rails.env.test?
|
|||
}
|
||||
}
|
||||
else
|
||||
fc_config_file_path = "#{Rails.root}/config/france_connect.yml"
|
||||
fc_config_file_path = Rails.root.join("config", "france_connect.yml")
|
||||
|
||||
# FIXME: with a yaml with a { particulier: {} } structure
|
||||
config_hash = YAML.safe_load(File.read(fc_config_file_path))
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class UpdateModuleAPICarto < ActiveRecord::Migration
|
||||
class Procedure < ActiveRecord::Base
|
||||
class Procedure < ApplicationRecord
|
||||
end
|
||||
|
||||
class ModuleAPICarto < ActiveRecord::Base
|
||||
class ModuleAPICarto < ApplicationRecord
|
||||
end
|
||||
|
||||
def up
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class CreateFranceConnectInformation < ActiveRecord::Migration
|
||||
class User < ActiveRecord::Base
|
||||
class User < ApplicationRecord
|
||||
end
|
||||
|
||||
class FranceConnectInformation < ActiveRecord::Base
|
||||
class FranceConnectInformation < ApplicationRecord
|
||||
end
|
||||
|
||||
def up
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class DBremovePieceJustificativeEmpty < ActiveRecord::Migration
|
||||
class PieceJustificative < ActiveRecord::Base
|
||||
class PieceJustificative < ApplicationRecord
|
||||
end
|
||||
|
||||
def change
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
class PieceJustificativeHaveUser < ActiveRecord::Migration
|
||||
class PieceJustificative < ActiveRecord::Base
|
||||
class PieceJustificative < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
end
|
||||
|
||||
class Dossier < ActiveRecord::Base
|
||||
class Dossier < ApplicationRecord
|
||||
belongs_to :user
|
||||
end
|
||||
|
||||
class User < ActiveRecord::Base
|
||||
class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def change
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
class CerfaHaveUser < ActiveRecord::Migration
|
||||
class Cerfa < ActiveRecord::Base
|
||||
class Cerfa < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
end
|
||||
|
||||
class Dossier < ActiveRecord::Base
|
||||
class Dossier < ApplicationRecord
|
||||
belongs_to :user
|
||||
end
|
||||
|
||||
class User < ActiveRecord::Base
|
||||
class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def change
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class AdminHasAndBelongGestionnaire < ActiveRecord::Migration
|
||||
class Gestionnaire < ActiveRecord::Base
|
||||
class Gestionnaire < ApplicationRecord
|
||||
end
|
||||
|
||||
class AdministrateursGestionnaire < ActiveRecord::Base
|
||||
class AdministrateursGestionnaire < ApplicationRecord
|
||||
end
|
||||
|
||||
def up
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
class GestionnaireIsAssignToProcedure < ActiveRecord::Migration
|
||||
class AssignTo < ActiveRecord::Base
|
||||
class AssignTo < ApplicationRecord
|
||||
belongs_to :gestionnaire
|
||||
belongs_to :procedure
|
||||
end
|
||||
|
||||
class Gestionnaire < ActiveRecord::Base
|
||||
class Gestionnaire < ApplicationRecord
|
||||
has_and_belongs_to_many :administrateurs
|
||||
has_many :procedures, through: :assign_to
|
||||
end
|
||||
|
||||
class Administrateur < ActiveRecord::Base
|
||||
class Administrateur < ApplicationRecord
|
||||
has_and_belongs_to_many :gestionnaires
|
||||
has_many :procedures
|
||||
end
|
||||
|
||||
class Procedure < ActiveRecord::Base
|
||||
class Procedure < ApplicationRecord
|
||||
belongs_to :administrateur
|
||||
has_many :gestionnaires, through: :assign_to
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class SetOriginalFilenameForUploaders < ActiveRecord::Migration
|
||||
class PieceJustificative < ActiveRecord::Base
|
||||
class PieceJustificative < ApplicationRecord
|
||||
end
|
||||
|
||||
class Cerfa < ActiveRecord::Base
|
||||
class Cerfa < ApplicationRecord
|
||||
end
|
||||
|
||||
def change
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddProcedureStatus < ActiveRecord::Migration
|
||||
class Procedure < ActiveRecord::Base
|
||||
class Procedure < ApplicationRecord
|
||||
end
|
||||
|
||||
def change
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
class DeleteDefaultDescriptionToDossier < ActiveRecord::Migration
|
||||
class Dossier < ActiveRecord::Base
|
||||
class Dossier < ApplicationRecord
|
||||
end
|
||||
|
||||
class Champ < ActiveRecord::Base
|
||||
class Champ < ApplicationRecord
|
||||
end
|
||||
|
||||
class Procedure < ActiveRecord::Base
|
||||
class Procedure < ApplicationRecord
|
||||
end
|
||||
|
||||
class TypeDeChamp < ActiveRecord::Base
|
||||
class TypeDeChamp < ApplicationRecord
|
||||
end
|
||||
|
||||
def up
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class ConvertAllDatetimeToDateOnDatabase < ActiveRecord::Migration
|
||||
class TypeDeChamp < ActiveRecord::Base
|
||||
class TypeDeChamp < ApplicationRecord
|
||||
end
|
||||
|
||||
def change
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddProcedurePathMappingTable < ActiveRecord::Migration
|
||||
class ProcedurePath < ActiveRecord::Base
|
||||
class ProcedurePath < ApplicationRecord
|
||||
end
|
||||
|
||||
def change
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class BuildDefaultPreferenceListDossier < ActiveRecord::Migration
|
||||
class Gestionnaire < ActiveRecord::Base
|
||||
class Gestionnaire < ApplicationRecord
|
||||
def build_default_preferences_list_dossier
|
||||
PreferenceListDossier.available_columns.each do |table|
|
||||
table.second.each do |column|
|
||||
|
@ -47,7 +47,7 @@ class BuildDefaultPreferenceListDossier < ActiveRecord::Migration
|
|||
end
|
||||
end
|
||||
|
||||
class PreferenceListDossier < ActiveRecord::Base
|
||||
class PreferenceListDossier < ApplicationRecord
|
||||
def self.available_columns
|
||||
{
|
||||
dossier: columns_dossier,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class FixDefaultTypeOnTypeDeChampTable < ActiveRecord::Migration
|
||||
class TypeDeChamp < ActiveRecord::Base
|
||||
class TypeDeChamp < ApplicationRecord
|
||||
end
|
||||
|
||||
def up
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class AddTypeAttrInChampTable < ActiveRecord::Migration
|
||||
class TypeDeChamp < ActiveRecord::Base
|
||||
class TypeDeChamp < ApplicationRecord
|
||||
has_many :champs
|
||||
end
|
||||
|
||||
class Champ < ActiveRecord::Base
|
||||
class Champ < ApplicationRecord
|
||||
belongs_to :type_de_champ
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class DeleteValueOfFilterProcedure < ActiveRecord::Migration
|
||||
class Gestionnaire < ActiveRecord::Base
|
||||
class Gestionnaire < ApplicationRecord
|
||||
end
|
||||
|
||||
def change
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class InitiatedAllReceivedMailForProcedure < ActiveRecord::Migration
|
||||
class Procedure < ActiveRecord::Base
|
||||
class Procedure < ApplicationRecord
|
||||
has_one :mail_received
|
||||
end
|
||||
|
||||
class MailTemplate < ActiveRecord::Base
|
||||
class MailTemplate < ApplicationRecord
|
||||
end
|
||||
|
||||
class ::MailReceived < MailTemplate
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
class BuildDefaultPrefListDossierProcedure < ActiveRecord::Migration
|
||||
class Gestionnaire < ActiveRecord::Base
|
||||
class Gestionnaire < ApplicationRecord
|
||||
has_many :assign_to, dependent: :destroy
|
||||
has_many :procedures, through: :assign_to
|
||||
has_many :preference_list_dossiers
|
||||
end
|
||||
|
||||
class PreferenceListDossier < ActiveRecord::Base
|
||||
class PreferenceListDossier < ApplicationRecord
|
||||
belongs_to :gestionnaire
|
||||
belongs_to :procedure
|
||||
end
|
||||
|
||||
class AssignTo < ActiveRecord::Base
|
||||
class AssignTo < ApplicationRecord
|
||||
belongs_to :procedure
|
||||
belongs_to :gestionnaire
|
||||
end
|
||||
|
||||
class Procedure < ActiveRecord::Base
|
||||
class Procedure < ApplicationRecord
|
||||
has_many :gestionnaires, through: :assign_to
|
||||
has_many :preference_list_dossiers
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class ChangeEmptytoNilInPreferenceListDossierTable < ActiveRecord::Migration
|
||||
class PreferenceListDossier < ActiveRecord::Base
|
||||
class PreferenceListDossier < ApplicationRecord
|
||||
end
|
||||
|
||||
def change
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class FixTypeDeChampHeaderSectionWithMandatoryTrue < ActiveRecord::Migration
|
||||
class TypeDeChamp < ActiveRecord::Base
|
||||
class TypeDeChamp < ApplicationRecord
|
||||
end
|
||||
|
||||
def change
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class PurgeDraftDossier < ActiveRecord::Migration
|
||||
class Dossier < ActiveRecord::Base
|
||||
class Dossier < ApplicationRecord
|
||||
BROUILLON = %w(draft)
|
||||
|
||||
def brouillon?
|
||||
|
@ -7,11 +7,11 @@ class PurgeDraftDossier < ActiveRecord::Migration
|
|||
end
|
||||
end
|
||||
|
||||
class Commentaire < ActiveRecord::Base
|
||||
class Commentaire < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
end
|
||||
|
||||
class Cerfa < ActiveRecord::Base
|
||||
class Cerfa < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
belongs_to :user
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class ResetAllPreferenceListDossier < ActiveRecord::Migration
|
||||
class PreferenceListDossier < ActiveRecord::Base
|
||||
class PreferenceListDossier < ApplicationRecord
|
||||
belongs_to :gestionnaire
|
||||
belongs_to :procedure
|
||||
|
||||
|
@ -91,7 +91,7 @@ class ResetAllPreferenceListDossier < ActiveRecord::Migration
|
|||
end
|
||||
end
|
||||
|
||||
class Gestionnaire < ActiveRecord::Base
|
||||
class Gestionnaire < ApplicationRecord
|
||||
has_many :assign_to, dependent: :destroy
|
||||
has_many :procedures, through: :assign_to
|
||||
|
||||
|
@ -145,7 +145,7 @@ class ResetAllPreferenceListDossier < ActiveRecord::Migration
|
|||
end
|
||||
end
|
||||
|
||||
class Procedure < ActiveRecord::Base
|
||||
class Procedure < ApplicationRecord
|
||||
has_many :assign_to, dependent: :destroy
|
||||
has_many :gestionnaires, through: :assign_to
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class CreatePreferenceSmartListingPage < ActiveRecord::Migration
|
||||
class Gestionnaire < ActiveRecord::Base
|
||||
class Gestionnaire < ApplicationRecord
|
||||
has_one :preference_smart_listing_page, dependent: :destroy
|
||||
|
||||
def build_default_preferences_smart_listing_page
|
||||
|
@ -7,7 +7,7 @@ class CreatePreferenceSmartListingPage < ActiveRecord::Migration
|
|||
end
|
||||
end
|
||||
|
||||
class PreferenceSmartListingPage < ActiveRecord::Base
|
||||
class PreferenceSmartListingPage < ApplicationRecord
|
||||
belongs_to :gestionnaire
|
||||
belongs_to :procedure
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace :'2017_07_26_clean_birthdate_on_individual' do
|
|||
puts "cleaning #{i.birthdate}"
|
||||
new_date = Date.strptime(i.birthdate, "%d/%m/%y")
|
||||
if new_date.year > 2017
|
||||
new_date = new_date - 100.year
|
||||
new_date = new_date - 100.years
|
||||
end
|
||||
i.update(birthdate: new_date.iso8601)
|
||||
end
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace :'2017_10_30_copy_commentaire_piece_justificative_to_file' do
|
|||
end
|
||||
|
||||
commentaire.save
|
||||
if !commentaire.file.present?
|
||||
if commentaire.file.blank?
|
||||
puts "Failed to save file for commentaire #{commentaire.id}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace :cloudstorage do
|
|||
|
||||
@cont.objects_detail.each { |object, details|
|
||||
last_modified = DateTime.parse(details[:last_modified])
|
||||
@cont.delete_object(object) if last_modified.utc <= (Time.now - 2.year).utc
|
||||
@cont.delete_object(object) if last_modified.utc <= (Time.now - 2.years).utc
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -112,7 +112,7 @@ describe Admin::GestionnairesController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when an other admin will add the same email' do
|
||||
let(:gestionnaire) { Gestionnaire.find_by_email(email) }
|
||||
let(:gestionnaire) { Gestionnaire.find_by(email: email) }
|
||||
|
||||
before do
|
||||
create :gestionnaire, email: email, administrateurs: [admin]
|
||||
|
@ -133,7 +133,7 @@ describe Admin::GestionnairesController, type: :controller do
|
|||
|
||||
context 'when an other admin will add the same email with some uppercase in it' do
|
||||
let(:email) { 'Test@Plop.com' }
|
||||
let(:gestionnaire) { Gestionnaire.find_by_email(email.downcase) }
|
||||
let(:gestionnaire) { Gestionnaire.find_by(email: email.downcase) }
|
||||
|
||||
before do
|
||||
create :gestionnaire, email: email, administrateurs: [admin]
|
||||
|
|
|
@ -254,9 +254,9 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
|
||||
describe 'statut' do
|
||||
let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago){ create(:dossier, procedure: procedure, state: 'en_instruction') } }
|
||||
let!(:new_followed_dossier) { Timecop.freeze(2.day.ago){ create(:dossier, procedure: procedure, state: 'en_instruction') } }
|
||||
let!(:termine_dossier) { Timecop.freeze(3.day.ago){ create(:dossier, procedure: procedure, state: 'accepte') } }
|
||||
let!(:archived_dossier) { Timecop.freeze(4.day.ago){ create(:dossier, procedure: procedure, state: 'en_instruction', archived: true) } }
|
||||
let!(:new_followed_dossier) { Timecop.freeze(2.days.ago){ create(:dossier, procedure: procedure, state: 'en_instruction') } }
|
||||
let!(:termine_dossier) { Timecop.freeze(3.days.ago){ create(:dossier, procedure: procedure, state: 'accepte') } }
|
||||
let!(:archived_dossier) { Timecop.freeze(4.days.ago){ create(:dossier, procedure: procedure, state: 'en_instruction', archived: true) } }
|
||||
|
||||
before do
|
||||
gestionnaire.followed_dossiers << new_followed_dossier
|
||||
|
|
|
@ -45,7 +45,7 @@ describe StatsController, type: :controller do
|
|||
it do
|
||||
expect(subject).to eq([
|
||||
[I18n.l(45.days.ago.beginning_of_month, format: "%B %Y"), 1],
|
||||
[I18n.l(1.days.ago.beginning_of_month, format: "%B %Y"), 2]
|
||||
[I18n.l(1.day.ago.beginning_of_month, format: "%B %Y"), 2]
|
||||
])
|
||||
end
|
||||
end
|
||||
|
@ -72,7 +72,7 @@ describe StatsController, type: :controller do
|
|||
|
||||
it do
|
||||
expect(subject).to eq({
|
||||
2.month.ago.beginning_of_month => 2,
|
||||
2.months.ago.beginning_of_month => 2,
|
||||
1.month.ago.beginning_of_month => 4,
|
||||
1.hour.ago.beginning_of_month => 5
|
||||
})
|
||||
|
@ -86,7 +86,7 @@ describe StatsController, type: :controller do
|
|||
|
||||
it do
|
||||
expect(subject).to eq({
|
||||
2.month.ago.beginning_of_month => 2,
|
||||
2.months.ago.beginning_of_month => 2,
|
||||
1.month.ago.beginning_of_month => 4
|
||||
})
|
||||
end
|
||||
|
@ -151,22 +151,22 @@ describe StatsController, type: :controller do
|
|||
dossier_p1_b = FactoryBot.create(:dossier,
|
||||
:procedure => procedure_1,
|
||||
:en_construction_at => 2.months.ago.beginning_of_month,
|
||||
:processed_at => 2.months.ago.beginning_of_month + 1.days)
|
||||
:processed_at => 2.months.ago.beginning_of_month + 1.day)
|
||||
dossier_p1_c = FactoryBot.create(:dossier,
|
||||
:procedure => procedure_1,
|
||||
:en_construction_at => 1.months.ago.beginning_of_month,
|
||||
:processed_at => 1.months.ago.beginning_of_month + 5.days)
|
||||
:en_construction_at => 1.month.ago.beginning_of_month,
|
||||
:processed_at => 1.month.ago.beginning_of_month + 5.days)
|
||||
dossier_p2_a = FactoryBot.create(:dossier,
|
||||
:procedure => procedure_2,
|
||||
:en_construction_at => 2.month.ago.beginning_of_month,
|
||||
:processed_at => 2.month.ago.beginning_of_month + 4.days)
|
||||
:en_construction_at => 2.months.ago.beginning_of_month,
|
||||
:processed_at => 2.months.ago.beginning_of_month + 4.days)
|
||||
|
||||
# Write directly in the DB to avoid the before_validation hook
|
||||
Dossier.update_all(state: "accepte")
|
||||
|
||||
@expected_hash = {
|
||||
"#{2.months.ago.beginning_of_month}" => 3.0,
|
||||
"#{1.months.ago.beginning_of_month}" => 5.0
|
||||
"#{1.month.ago.beginning_of_month}" => 5.0
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -204,21 +204,21 @@ describe StatsController, type: :controller do
|
|||
:processed_at => 2.months.ago.beginning_of_month + 1.day)
|
||||
dossier_p1_c = FactoryBot.create(:dossier,
|
||||
:procedure => procedure_1,
|
||||
:created_at => 1.months.ago.beginning_of_month,
|
||||
:en_construction_at => 1.months.ago.beginning_of_month + 50.minutes,
|
||||
:processed_at => 1.months.ago.beginning_of_month + 1.day)
|
||||
:created_at => 1.month.ago.beginning_of_month,
|
||||
:en_construction_at => 1.month.ago.beginning_of_month + 50.minutes,
|
||||
:processed_at => 1.month.ago.beginning_of_month + 1.day)
|
||||
dossier_p2_a = FactoryBot.create(:dossier,
|
||||
:procedure => procedure_2,
|
||||
:created_at => 2.month.ago.beginning_of_month,
|
||||
:en_construction_at => 2.month.ago.beginning_of_month + 80.minutes,
|
||||
:processed_at => 2.month.ago.beginning_of_month + 1.day)
|
||||
:created_at => 2.months.ago.beginning_of_month,
|
||||
:en_construction_at => 2.months.ago.beginning_of_month + 80.minutes,
|
||||
:processed_at => 2.months.ago.beginning_of_month + 1.day)
|
||||
|
||||
# Write directly in the DB to avoid the before_validation hook
|
||||
Dossier.update_all(state: "accepte")
|
||||
|
||||
@expected_hash = {
|
||||
"#{2.months.ago.beginning_of_month}" => 30.0,
|
||||
"#{1.months.ago.beginning_of_month}" => 50.0
|
||||
"#{1.month.ago.beginning_of_month}" => 50.0
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -239,7 +239,7 @@ describe StatsController, type: :controller do
|
|||
|
||||
subject { StatsController.new.send(:avis_usage) }
|
||||
|
||||
it { expect(subject).to match([[3.week.ago.to_i, 0], [2.week.ago.to_i, 0], [1.week.ago.to_i, 33.33]]) }
|
||||
it { expect(subject).to match([[3.weeks.ago.to_i, 0], [2.weeks.ago.to_i, 0], [1.week.ago.to_i, 33.33]]) }
|
||||
end
|
||||
|
||||
describe "#avis_average_answer_time" do
|
||||
|
@ -251,10 +251,10 @@ describe StatsController, type: :controller do
|
|||
create(:avis, created_at: 1.week.ago + 2.days)
|
||||
|
||||
# 2 weeks ago
|
||||
create(:avis, answer: "voila ma réponse", created_at: 2.week.ago + 1.day, updated_at: 2.week.ago + 2.days) # 1 day
|
||||
create(:avis, answer: "voila ma réponse2", created_at: 2.week.ago + 3.days, updated_at: 1.week.ago + 6.days) # 10 days
|
||||
create(:avis, answer: "voila ma réponse2", created_at: 2.week.ago + 2.days, updated_at: 1.week.ago + 6.days) # 11 days
|
||||
create(:avis, created_at: 2.week.ago + 1.day, updated_at: 2.week.ago + 2.days)
|
||||
create(:avis, answer: "voila ma réponse", created_at: 2.weeks.ago + 1.day, updated_at: 2.weeks.ago + 2.days) # 1 day
|
||||
create(:avis, answer: "voila ma réponse2", created_at: 2.weeks.ago + 3.days, updated_at: 1.week.ago + 6.days) # 10 days
|
||||
create(:avis, answer: "voila ma réponse2", created_at: 2.weeks.ago + 2.days, updated_at: 1.week.ago + 6.days) # 11 days
|
||||
create(:avis, created_at: 2.weeks.ago + 1.day, updated_at: 2.weeks.ago + 2.days)
|
||||
|
||||
# 3 weeks ago
|
||||
create(:avis, answer: "voila ma réponse2", created_at: 3.weeks.ago + 1.day, updated_at: 3.weeks.ago + 2.days) # 1 day
|
||||
|
@ -267,8 +267,8 @@ describe StatsController, type: :controller do
|
|||
|
||||
it { expect(subject.count).to eq(3) }
|
||||
it { is_expected.to include [1.week.ago.to_i, 1.0] }
|
||||
it { is_expected.to include [2.week.ago.to_i, 7.33] }
|
||||
it { is_expected.to include [3.week.ago.to_i, 9.5] }
|
||||
it { is_expected.to include [2.weeks.ago.to_i, 7.33] }
|
||||
it { is_expected.to include [3.weeks.ago.to_i, 9.5] }
|
||||
end
|
||||
|
||||
describe '#avis_answer_percentages' do
|
||||
|
@ -281,7 +281,7 @@ describe StatsController, type: :controller do
|
|||
before { Timecop.freeze(Time.now) }
|
||||
after { Timecop.return }
|
||||
|
||||
it { is_expected.to match [[3.week.ago.to_i, 0], [2.week.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]] }
|
||||
end
|
||||
|
||||
describe '#motivation_usage_dossier' do
|
||||
|
@ -294,7 +294,7 @@ describe StatsController, type: :controller do
|
|||
|
||||
subject { StatsController.new.send(:motivation_usage_dossier) }
|
||||
|
||||
it { expect(subject).to match([[I18n.l(3.week.ago.end_of_week, format: '%d/%m/%Y'), 0], [I18n.l(2.week.ago.end_of_week, format: '%d/%m/%Y'), 0], [I18n.l(1.week.ago.end_of_week, format: '%d/%m/%Y'), 33.33]]) }
|
||||
it { expect(subject).to match([[I18n.l(3.weeks.ago.end_of_week, format: '%d/%m/%Y'), 0], [I18n.l(2.weeks.ago.end_of_week, format: '%d/%m/%Y'), 0], [I18n.l(1.week.ago.end_of_week, format: '%d/%m/%Y'), 33.33]]) }
|
||||
end
|
||||
|
||||
describe '#motivation_usage_procedure' do
|
||||
|
@ -308,6 +308,6 @@ describe StatsController, type: :controller do
|
|||
|
||||
subject { StatsController.new.send(:motivation_usage_procedure) }
|
||||
|
||||
it { expect(subject).to match([[I18n.l(3.week.ago.end_of_week, format: '%d/%m/%Y'), 0], [I18n.l(2.week.ago.end_of_week, format: '%d/%m/%Y'), 0], [I18n.l(1.week.ago.end_of_week, format: '%d/%m/%Y'), 33.33]]) }
|
||||
it { expect(subject).to match([[I18n.l(3.weeks.ago.end_of_week, format: '%d/%m/%Y'), 0], [I18n.l(2.weeks.ago.end_of_week, format: '%d/%m/%Y'), 0], [I18n.l(1.week.ago.end_of_week, format: '%d/%m/%Y'), 33.33]]) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -376,7 +376,7 @@ shared_examples 'description_controller_spec' do
|
|||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 2 }
|
||||
it { expect(flash[:notice]).to be_present }
|
||||
it { is_expected.to redirect_to users_dossiers_invite_path(id: guest.invites.find_by_dossier_id(dossier.id).id) }
|
||||
it { is_expected.to redirect_to users_dossiers_invite_path(id: guest.invites.find_by(dossier_id: dossier.id).id) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -396,7 +396,7 @@ shared_examples 'description_controller_spec' do
|
|||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 4 }
|
||||
it { expect(flash[:notice]).to be_present }
|
||||
it { is_expected.to redirect_to users_dossiers_invite_path(id: guest.invites.find_by_dossier_id(dossier.id).id) }
|
||||
it { is_expected.to redirect_to users_dossiers_invite_path(id: guest.invites.find_by(dossier_id: dossier.id).id) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -413,7 +413,7 @@ shared_examples 'description_controller_spec' do
|
|||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 1 }
|
||||
it { expect(flash[:alert]).to be_present }
|
||||
it { is_expected.to redirect_to users_dossiers_invite_path(id: guest.invites.find_by_dossier_id(dossier.id).id) }
|
||||
it { is_expected.to redirect_to users_dossiers_invite_path(id: guest.invites.find_by(dossier_id: dossier.id).id) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -85,7 +85,7 @@ FactoryBot.define do
|
|||
after(:create) do |dossier, _evaluator|
|
||||
dossier.state = 'en_instruction'
|
||||
dossier.en_construction_at = dossier.created_at + 1.minute
|
||||
dossier.created_at = dossier.created_at + 2.minute
|
||||
dossier.created_at = dossier.created_at + 2.minutes
|
||||
dossier.save!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -245,9 +245,9 @@ describe Procedure do
|
|||
|
||||
it { expect(procedure.archived_at).to eq(nil) }
|
||||
it { expect(procedure.published_at).to eq(now) }
|
||||
it { expect(ProcedurePath.find_by_path("example-path")).to be }
|
||||
it { expect(ProcedurePath.find_by_path("example-path").procedure).to eq(procedure) }
|
||||
it { expect(ProcedurePath.find_by_path("example-path").administrateur).to eq(procedure.administrateur) }
|
||||
it { expect(ProcedurePath.find_by(path: "example-path")).to be }
|
||||
it { expect(ProcedurePath.find_by(path: "example-path").procedure).to eq(procedure) }
|
||||
it { expect(ProcedurePath.find_by(path: "example-path").administrateur).to eq(procedure.administrateur) }
|
||||
end
|
||||
|
||||
describe "#brouillon?" do
|
||||
|
|
|
@ -52,8 +52,8 @@ Capybara.default_max_wait_time = 1
|
|||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
||||
Dir[Rails.root.join('spec/factories/**/*.rb')].each { |f| require f }
|
||||
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
|
||||
Dir[Rails.root.join('spec', 'factories', '**', '*.rb')].each { |f| require f }
|
||||
|
||||
# Checks for pending migrations before tests are run.
|
||||
# If you are not using ActiveRecord, you can remove this line.
|
||||
|
|
Loading…
Reference in a new issue