diff --git a/app/controllers/administrateurs/groupe_instructeurs_controller.rb b/app/controllers/administrateurs/groupe_instructeurs_controller.rb index a0f6bf90155..ed7a872625d 100644 --- a/app/controllers/administrateurs/groupe_instructeurs_controller.rb +++ b/app/controllers/administrateurs/groupe_instructeurs_controller.rb @@ -8,7 +8,7 @@ class GroupeInstructeursController < AdministrateurController before_action :ensure_not_super_admin!, only: [:add_instructeur] ITEMS_PER_PAGE = 25 - CSV_MAX_SIZE = 1.megabytes + CSV_MAX_SIZE = 1.megabyte CSV_ACCEPTED_CONTENT_TYPES = [ "text/csv", "application/vnd.ms-excel" diff --git a/app/controllers/administrateurs/procedures_controller.rb b/app/controllers/administrateurs/procedures_controller.rb index 7e9c4aa57fe..c1803a824a9 100644 --- a/app/controllers/administrateurs/procedures_controller.rb +++ b/app/controllers/administrateurs/procedures_controller.rb @@ -480,7 +480,7 @@ def filter_procedures(filter) procedures_result = procedures_result.where(aasm_state: filter.statuses) if filter.statuses.present? procedures_result = procedures_result.where("tags @> ARRAY[?]::text[]", filter.tags) if filter.tags.present? procedures_result = procedures_result.where(template: true) if filter.template? - procedures_result = procedures_result.where('published_at >= ?', filter.from_publication_date) if filter.from_publication_date.present? + procedures_result = procedures_result.where(published_at: filter.from_publication_date..) if filter.from_publication_date.present? procedures_result = procedures_result.where(service: service) if filter.service_siret.present? procedures_result = procedures_result.where(service: services) if services procedures_result = procedures_result.where(for_individual: filter.for_individual) if filter.for_individual.present? diff --git a/app/controllers/administrateurs/types_de_champ_controller.rb b/app/controllers/administrateurs/types_de_champ_controller.rb index ab914c7f56b..2b64df509d3 100644 --- a/app/controllers/administrateurs/types_de_champ_controller.rb +++ b/app/controllers/administrateurs/types_de_champ_controller.rb @@ -73,9 +73,9 @@ def move_and_morph @created = champ_component_from(@coordinate) @morphed = @coordinate.siblings if from > to # case of moved up, update components from target (> plus one) to origin - @morphed = @morphed.where("position > ?", to).where("position <= ?", from) + @morphed = @morphed.where("position > ?", to).where(position: ..from) else # case of moved down, update components from origin up to target (< minus one) - @morphed = @morphed.where("position >= ?", from).where("position < ?", to) + @morphed = @morphed.where(position: from..).where(position: ...to) end @morphed = @morphed.map { |c| champ_component_from(c) } diff --git a/app/controllers/manager/procedures_controller.rb b/app/controllers/manager/procedures_controller.rb index 6fb14e6d2ff..9240ea0ee90 100644 --- a/app/controllers/manager/procedures_controller.rb +++ b/app/controllers/manager/procedures_controller.rb @@ -1,6 +1,6 @@ module Manager class ProceduresController < Manager::ApplicationController - CSV_MAX_SIZE = 1.megabytes + CSV_MAX_SIZE = 1.megabyte CSV_ACCEPTED_CONTENT_TYPES = [ "text/csv", "application/vnd.ms-excel" diff --git a/app/graphql/types/demarche_type.rb b/app/graphql/types/demarche_type.rb index 963837129fc..adef2b6f41a 100644 --- a/app/graphql/types/demarche_type.rb +++ b/app/graphql/types/demarche_type.rb @@ -103,11 +103,11 @@ def dossiers(updated_since: nil, created_since: nil, state: nil, archived: nil, dossiers = dossiers.where(revision: find_revision(revision)) else if !min_revision.nil? - dossiers = dossiers.joins(:revision).where('procedure_revisions.created_at >= ?', find_revision(min_revision).created_at) + dossiers = dossiers.joins(:revision).where(procedure_revisions: { created_at: find_revision(min_revision).created_at.. }) end if !max_revision.nil? - dossiers = dossiers.joins(:revision).where('procedure_revisions.created_at <= ?', find_revision(max_revision).created_at) + dossiers = dossiers.joins(:revision).where(procedure_revisions: { created_at: ..find_revision(max_revision).created_at }) end end diff --git a/app/graphql/types/groupe_instructeur_with_dossiers_type.rb b/app/graphql/types/groupe_instructeur_with_dossiers_type.rb index 32999241a80..b461974b7dc 100644 --- a/app/graphql/types/groupe_instructeur_with_dossiers_type.rb +++ b/app/graphql/types/groupe_instructeur_with_dossiers_type.rb @@ -41,11 +41,11 @@ def dossiers(updated_since: nil, created_since: nil, state: nil, archived: nil, dossiers = dossiers.where(revision: find_revision(revision)) else if !min_revision.nil? - dossiers = dossiers.joins(:revision).where('procedure_revisions.created_at >= ?', find_revision(min_revision).created_at) + dossiers = dossiers.joins(:revision).where(procedure_revisions: { created_at: find_revision(min_revision).created_at.. }) end if !max_revision.nil? - dossiers = dossiers.joins(:revision).where('procedure_revisions.created_at <= ?', find_revision(max_revision).created_at) + dossiers = dossiers.joins(:revision).where(procedure_revisions: { created_at: ..find_revision(max_revision).created_at }) end end diff --git a/app/jobs/cron/auto_archive_procedure_job.rb b/app/jobs/cron/auto_archive_procedure_job.rb index 9a998cf436c..70832f8bfd2 100644 --- a/app/jobs/cron/auto_archive_procedure_job.rb +++ b/app/jobs/cron/auto_archive_procedure_job.rb @@ -21,6 +21,6 @@ def perform(*args) def procedures_to_close Procedure .publiees - .where("auto_archive_on <= ?", Time.zone.today) + .where(auto_archive_on: ..Time.zone.today) end end diff --git a/app/models/administrateur.rb b/app/models/administrateur.rb index 48b38840ceb..1c4725d15ee 100644 --- a/app/models/administrateur.rb +++ b/app/models/administrateur.rb @@ -114,7 +114,7 @@ def merge(old_admin) i.administrateurs.delete(old_admin) end - old_admin.api_tokens.where('version >= ?', 3).find_each do |token| + old_admin.api_tokens.where(version: 3..).find_each do |token| self.api_tokens << token end end diff --git a/app/models/archive.rb b/app/models/archive.rb index e64c96a0bb8..761cb54011b 100644 --- a/app/models/archive.rb +++ b/app/models/archive.rb @@ -18,7 +18,7 @@ class Archive < ApplicationRecord ) } - enum time_span_type: { + enum :time_span_type, { everything: 'everything', monthly: 'monthly' } diff --git a/app/models/attestation_template.rb b/app/models/attestation_template.rb index cfbd7fc5649..8b7e241cc86 100644 --- a/app/models/attestation_template.rb +++ b/app/models/attestation_template.rb @@ -12,7 +12,7 @@ class AttestationTemplate < ApplicationRecord validates :json_body, tags: true, if: -> { procedure.present? && version == 2 } validates :footer, length: { maximum: 190 } - FILE_MAX_SIZE = 1.megabytes + FILE_MAX_SIZE = 1.megabyte validates :logo, content_type: ['image/png', 'image/jpg', 'image/jpeg'], size: { less_than: FILE_MAX_SIZE } validates :signature, content_type: ['image/png', 'image/jpg', 'image/jpeg'], size: { less_than: FILE_MAX_SIZE } diff --git a/app/models/batch_operation.rb b/app/models/batch_operation.rb index f6abad9b169..c309066a633 100644 --- a/app/models/batch_operation.rb +++ b/app/models/batch_operation.rb @@ -1,5 +1,5 @@ class BatchOperation < ApplicationRecord - enum operation: { + enum :operation, { accepter: 'accepter', refuser: 'refuser', classer_sans_suite: 'classer_sans_suite', @@ -30,12 +30,12 @@ class BatchOperation < ApplicationRecord scope :stale, lambda { where.not(finished_at: nil) - .where('updated_at < ?', (Time.zone.now - RETENTION_DURATION)) + .where(updated_at: ...(Time.zone.now - RETENTION_DURATION)) } scope :stuck, lambda { where(finished_at: nil) - .where('updated_at < ?', (Time.zone.now - MAX_DUREE_GENERATION)) + .where(updated_at: ...(Time.zone.now - MAX_DUREE_GENERATION)) } def dossiers_safe_scope(dossier_ids = self.dossier_ids) diff --git a/app/models/concerns/domain_migratable_concern.rb b/app/models/concerns/domain_migratable_concern.rb index 65be5f723b7..820e160855a 100644 --- a/app/models/concerns/domain_migratable_concern.rb +++ b/app/models/concerns/domain_migratable_concern.rb @@ -2,7 +2,7 @@ module DomainMigratableConcern extend ActiveSupport::Concern included do - enum preferred_domain: { demarches_gouv_fr: 0, demarches_simplifiees_fr: 1 }, _prefix: true + enum :preferred_domain, { demarches_gouv_fr: 0, demarches_simplifiees_fr: 1 }, prefix: true validates :preferred_domain, inclusion: { in: User.preferred_domains.keys, allow_nil: true } diff --git a/app/models/concerns/transient_models_with_purgeable_job_concern.rb b/app/models/concerns/transient_models_with_purgeable_job_concern.rb index 72e5d1c640b..5543da66f9b 100644 --- a/app/models/concerns/transient_models_with_purgeable_job_concern.rb +++ b/app/models/concerns/transient_models_with_purgeable_job_concern.rb @@ -8,7 +8,7 @@ module TransientModelsWithPurgeableJobConcern included do include AASM - enum job_status: { + enum :job_status, { pending: 'pending', generated: 'generated', failed: 'failed' @@ -32,12 +32,12 @@ module TransientModelsWithPurgeableJobConcern scope :stale, lambda { |duration| where(job_status: [job_statuses.fetch(:generated), job_statuses.fetch(:failed)]) - .where('updated_at < ?', (Time.zone.now - duration)) + .where(updated_at: ...(Time.zone.now - duration)) } scope :stuck, lambda { |duration| where(job_status: [job_statuses.fetch(:pending)]) - .where('updated_at < ?', (Time.zone.now - duration)) + .where(updated_at: ...(Time.zone.now - duration)) } def available? diff --git a/app/models/deleted_dossier.rb b/app/models/deleted_dossier.rb index b8caead0e5b..7d9ab5ef03c 100644 --- a/app/models/deleted_dossier.rb +++ b/app/models/deleted_dossier.rb @@ -3,10 +3,10 @@ class DeletedDossier < ApplicationRecord belongs_to :groupe_instructeur, inverse_of: :deleted_dossiers, optional: true scope :order_by_updated_at, -> (order = :desc) { order(created_at: order) } - scope :deleted_since, -> (since) { where('deleted_dossiers.deleted_at >= ?', since) } + scope :deleted_since, -> (since) { where(deleted_dossiers: { deleted_at: since.. }) } scope :state_termine, -> { where(state: [states.fetch(:accepte), states.fetch(:refuse), states.fetch(:sans_suite)]) } - enum reason: { + enum :reason, { user_request: 'user_request', manager_request: 'manager_request', user_removed: 'user_removed', @@ -16,7 +16,7 @@ class DeletedDossier < ApplicationRecord user_expired: 'user_expired' } - enum state: { + enum :state, { en_construction: 'en_construction', en_instruction: 'en_instruction', accepte: 'accepte', diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 7f7f53cdc78..af170870c8a 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -12,7 +12,7 @@ class Dossier < ApplicationRecord include DossierStateConcern include DossierChampsConcern - enum state: { + enum :state, { brouillon: 'brouillon', en_construction: 'en_construction', en_instruction: 'en_instruction', @@ -237,8 +237,8 @@ def classer_sans_suite(motivation: nil, instructeur: nil, processed_at: Time.zon scope :for_groupe_instructeur, -> (groupe_instructeurs) { where(groupe_instructeur: groupe_instructeurs) } scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order, id: order) } scope :order_by_created_at, -> (order = :asc) { order(depose_at: order, id: order) } - scope :updated_since, -> (since) { where('dossiers.updated_at >= ?', since) } - scope :created_since, -> (since) { where('dossiers.depose_at >= ?', since) } + scope :updated_since, -> (since) { where(dossiers: { updated_at: since.. }) } + scope :created_since, -> (since) { where(dossiers: { depose_at: since.. }) } scope :hidden_by_user_since, -> (since) { where('dossiers.hidden_by_user_at IS NOT NULL AND dossiers.hidden_by_user_at >= ?', since) } scope :hidden_by_administration_since, -> (since) { where('dossiers.hidden_by_administration_at IS NOT NULL AND dossiers.hidden_by_administration_at >= ?', since) } scope :hidden_since, -> (since) { hidden_by_user_since(since).or(hidden_by_administration_since(since)) } @@ -370,8 +370,8 @@ def classer_sans_suite(motivation: nil, instructeur: nil, processed_at: Time.zon scope :without_en_construction_expiration_notice_sent, -> { where(en_construction_close_to_expiration_notice_sent_at: nil) } scope :without_termine_expiration_notice_sent, -> { where(termine_close_to_expiration_notice_sent_at: nil) } - scope :deleted_by_user_expired, -> { where('dossiers.hidden_by_user_at < ?', 1.week.ago) } - scope :deleted_by_administration_expired, -> { where('dossiers.hidden_by_administration_at < ?', 1.week.ago) } + scope :deleted_by_user_expired, -> { where(dossiers: { hidden_by_user_at: ...1.week.ago }) } + scope :deleted_by_administration_expired, -> { where(dossiers: { hidden_by_administration_at: ...1.week.ago }) } scope :en_brouillon_expired_to_delete, -> { state_brouillon.deleted_by_user_expired } scope :en_construction_expired_to_delete, -> { state_en_construction.deleted_by_user_expired } scope :termine_expired_to_delete, -> { state_termine.deleted_by_user_expired.deleted_by_administration_expired } diff --git a/app/models/dossier_assignment.rb b/app/models/dossier_assignment.rb index 239a218d4d5..039ce8cc586 100644 --- a/app/models/dossier_assignment.rb +++ b/app/models/dossier_assignment.rb @@ -4,7 +4,7 @@ class DossierAssignment < ApplicationRecord belongs_to :groupe_instructeur, optional: true, inverse_of: :assignments belongs_to :previous_groupe_instructeur, class_name: 'GroupeInstructeur', optional: true, inverse_of: :previous_assignments - enum mode: { + enum :mode, { auto: 'auto', manual: 'manual', tech: 'tech' diff --git a/app/models/dossier_batch_operation.rb b/app/models/dossier_batch_operation.rb index ca5582d22e7..cef634814c6 100644 --- a/app/models/dossier_batch_operation.rb +++ b/app/models/dossier_batch_operation.rb @@ -3,7 +3,7 @@ class DossierBatchOperation < ApplicationRecord belongs_to :batch_operation has_many :groupe_instructeurs, through: :dossier - enum state: { + enum :state, { pending: 'pending', success: 'success', error: 'error' diff --git a/app/models/dossier_correction.rb b/app/models/dossier_correction.rb index 2f442a38525..2f8099cf85d 100644 --- a/app/models/dossier_correction.rb +++ b/app/models/dossier_correction.rb @@ -6,11 +6,11 @@ class DossierCorrection < ApplicationRecord scope :pending, -> { where(resolved_at: nil) } - enum reason: { + enum :reason, { incorrect: 'incorrect', incomplete: 'incomplete', outdated: 'outdated' - }, _prefix: :dossier + }, prefix: :dossier def resolved? resolved_at.present? diff --git a/app/models/dossier_operation_log.rb b/app/models/dossier_operation_log.rb index 902626a8552..52c1430e8e0 100644 --- a/app/models/dossier_operation_log.rb +++ b/app/models/dossier_operation_log.rb @@ -1,5 +1,5 @@ class DossierOperationLog < ApplicationRecord - enum operation: { + enum :operation, { changer_groupe_instructeur: 'changer_groupe_instructeur', passer_en_instruction: 'passer_en_instruction', repasser_en_construction: 'repasser_en_construction', diff --git a/app/models/dossier_transfer.rb b/app/models/dossier_transfer.rb index 83e165cf764..0eb8075b541 100644 --- a/app/models/dossier_transfer.rb +++ b/app/models/dossier_transfer.rb @@ -8,7 +8,7 @@ class DossierTransfer < ApplicationRecord before_validation -> { sanitize_email(:email) } scope :pending, -> { where('created_at > ?', (Time.zone.now - EXPIRATION_LIMIT)) } - scope :stale, -> { where('created_at < ?', (Time.zone.now - EXPIRATION_LIMIT)) } + scope :stale, -> { where(created_at: ...(Time.zone.now - EXPIRATION_LIMIT)) } scope :with_dossiers, -> { joins(:dossiers).merge(Dossier.visible_by_user) } scope :for_email, -> (email) { includes(dossiers: :user).with_dossiers.where(email: email) } diff --git a/app/models/dossiers_filter.rb b/app/models/dossiers_filter.rb index c542c3cacd9..ec1ef1d2b16 100644 --- a/app/models/dossiers_filter.rb +++ b/app/models/dossiers_filter.rb @@ -24,8 +24,8 @@ def filter_procedures(dossiers) dossiers_result = dossiers_result.where(state: state) if state.present? && state != Dossier::A_CORRIGER dossiers_result = dossiers_result.with_pending_corrections if state.present? && state == Dossier::A_CORRIGER dossiers_result = exclude_accuse_lecture(dossiers_result) if state.present? && Dossier::TERMINE.include?(state) - dossiers_result = dossiers_result.where('dossiers.created_at >= ?', from_created_at_date) if from_created_at_date.present? - dossiers_result = dossiers_result.where('dossiers.depose_at >= ?', from_depose_at_date) if from_depose_at_date.present? + dossiers_result = dossiers_result.where(dossiers: { created_at: from_created_at_date.. }) if from_created_at_date.present? + dossiers_result = dossiers_result.where(dossiers: { depose_at: from_depose_at_date.. }) if from_depose_at_date.present? dossiers_result end diff --git a/app/models/email_event.rb b/app/models/email_event.rb index 4831adbd6a4..81cb289ac78 100644 --- a/app/models/email_event.rb +++ b/app/models/email_event.rb @@ -1,7 +1,7 @@ class EmailEvent < ApplicationRecord RETENTION_DURATION = 1.month - enum status: { + enum :status, { pending: 'pending', dispatched: 'dispatched', dispatch_error: 'dispatch_error' @@ -11,7 +11,7 @@ class EmailEvent < ApplicationRecord scope :dolist_smtp, -> { where(method: 'dolist_smtp') } # legacy method: removable after 2023-06 scope :dolist_api, -> { where(method: 'dolist_api') } scope :sendinblue, -> { where(method: 'sendinblue') } - scope :outdated, -> { where("created_at < ?", RETENTION_DURATION.ago) } + scope :outdated, -> { where(created_at: ...RETENTION_DURATION.ago) } class << self def create_from_message!(message, status:) diff --git a/app/models/etablissement.rb b/app/models/etablissement.rb index 4ded9d883e5..d9526274f41 100644 --- a/app/models/etablissement.rb +++ b/app/models/etablissement.rb @@ -12,10 +12,10 @@ class Etablissement < ApplicationRecord validates :siret, presence: true validates :dossier_id, uniqueness: { allow_nil: true } - enum entreprise_etat_administratif: { + enum :entreprise_etat_administratif, { actif: "actif", fermé: "fermé" - }, _prefix: true + }, prefix: true after_commit -> { dossier&.index_search_terms_later } diff --git a/app/models/export.rb b/app/models/export.rb index d9b29d40985..2b7751a635c 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -4,20 +4,20 @@ class Export < ApplicationRecord MAX_DUREE_CONSERVATION_EXPORT = 32.hours MAX_DUREE_GENERATION = 16.hours - enum format: { + enum :format, { csv: 'csv', ods: 'ods', xlsx: 'xlsx', zip: 'zip', json: 'json' - }, _prefix: true + }, prefix: true - enum time_span_type: { + enum :time_span_type, { everything: 'everything', monthly: 'monthly' } - enum statut: { + enum :statut, { 'a-suivre': 'a-suivre', suivis: 'suivis', traites: 'traites', diff --git a/app/models/geo_area.rb b/app/models/geo_area.rb index e3466975981..545ea73c46b 100644 --- a/app/models/geo_area.rb +++ b/app/models/geo_area.rb @@ -30,7 +30,7 @@ def filename properties['filename'] end - enum source: { + enum :source, { cadastre: 'cadastre', selection_utilisateur: 'selection_utilisateur' } diff --git a/app/models/groupe_instructeur.rb b/app/models/groupe_instructeur.rb index f628b136efc..0ddf88b71c0 100644 --- a/app/models/groupe_instructeur.rb +++ b/app/models/groupe_instructeur.rb @@ -17,7 +17,7 @@ class GroupeInstructeur < ApplicationRecord has_one_attached :signature - SIGNATURE_MAX_SIZE = 1.megabytes + SIGNATURE_MAX_SIZE = 1.megabyte validates :signature, content_type: ['image/png', 'image/jpg', 'image/jpeg'], size: { less_than: SIGNATURE_MAX_SIZE } validates :label, presence: true, allow_nil: false diff --git a/app/models/individual.rb b/app/models/individual.rb index d75e3607cc3..6ca6a39edb6 100644 --- a/app/models/individual.rb +++ b/app/models/individual.rb @@ -1,7 +1,7 @@ class Individual < ApplicationRecord include SanitizeConcern - enum notification_method: { + enum :notification_method, { email: 'email', no_notification: 'no_notification' } diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 47ccf9a67c2..1e5fee8a73a 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -191,7 +191,7 @@ def revisions_with_pending_dossiers scope :publiques, -> do publiees_ou_closes .opendata - .where('estimated_dossiers_count >= ?', 4) + .where(estimated_dossiers_count: 4..) .where.not('lien_site_web LIKE ?', '%mail%') .where.not('lien_site_web LIKE ?', '%intra%') end @@ -204,7 +204,7 @@ def revisions_with_pending_dossiers scope :discarded_expired, -> do with_discarded .discarded - .where('hidden_at < ?', 1.month.ago) + .where(hidden_at: ...1.month.ago) end scope :for_api, -> { @@ -222,15 +222,15 @@ def revisions_with_pending_dossiers ) } - enum declarative_with_state: { + enum :declarative_with_state, { en_instruction: 'en_instruction', accepte: 'accepte' } - enum closing_reason: { + enum :closing_reason, { internal_procedure: 'internal_procedure', other: 'other' - }, _prefix: true + }, prefix: true scope :for_api_v2, -> { includes(:draft_revision, :published_revision, administrateurs: :user) diff --git a/app/models/procedure_overview.rb b/app/models/procedure_overview.rb index fd8a4e9ee23..930c83104e0 100644 --- a/app/models/procedure_overview.rb +++ b/app/models/procedure_overview.rb @@ -15,12 +15,12 @@ def initialize(procedure, start_date, groups) @dossiers_en_instruction_count = dossiers.state_en_instruction.count @old_dossiers_en_instruction = dossiers .state_en_instruction - .where('en_instruction_at < ?', 1.week.ago) + .where(en_instruction_at: ...1.week.ago) @dossiers_en_construction_count = dossiers.state_en_construction.count @old_dossiers_en_construction = dossiers .state_en_construction - .where('depose_at < ?', 1.week.ago) + .where(depose_at: ...1.week.ago) @created_dossiers_count = dossiers .where(created_at: start_date..Time.zone.now) diff --git a/app/models/procedure_revision.rb b/app/models/procedure_revision.rb index 65fdc503550..fa0711435b7 100644 --- a/app/models/procedure_revision.rb +++ b/app/models/procedure_revision.rb @@ -43,7 +43,7 @@ def add_type_de_champ(params) if tdc.save # moving all the impacted tdc down position = next_position_for(after_coordinate:, siblings:) - siblings.where("position >= ?", position).update_all("position = position + 1") + siblings.where(position: position..).update_all("position = position + 1") # insertion of the new tdc h = { type_de_champ: tdc, parent_id: parent_id, position: position } @@ -107,7 +107,7 @@ def remove_type_de_champ(stable_id) children.each(&:destroy_if_orphan) tdc.destroy_if_orphan - coordinate.siblings.where("position >= ?", coordinate.position).update_all("position = position - 1") + coordinate.siblings.where(position: coordinate.position..).update_all("position = position - 1") coordinate end diff --git a/app/models/safe_mailer.rb b/app/models/safe_mailer.rb index 9ccc83aefac..841280e6a68 100644 --- a/app/models/safe_mailer.rb +++ b/app/models/safe_mailer.rb @@ -3,7 +3,7 @@ class SafeMailer < ApplicationRecord raise if SafeMailer.count == 1 end - enum forced_delivery_method: (Rails.application.config.action_mailer&.balancer_settings&.keys || []).to_h { |k| [k.to_sym, k.to_s] } + enum :forced_delivery_method, (Rails.application.config.action_mailer&.balancer_settings&.keys || []).to_h { |k| [k.to_sym, k.to_s] } def self.forced_delivery_method first&.forced_delivery_method diff --git a/app/models/service.rb b/app/models/service.rb index 1301d9a3cf6..7a2814299e0 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -4,7 +4,7 @@ class Service < ApplicationRecord scope :ordered, -> { order(nom: :asc) } - enum type_organisme: { + enum :type_organisme, { administration_centrale: 'administration_centrale', association: 'association', collectivite_territoriale: 'collectivite_territoriale', diff --git a/app/models/targeted_user_link.rb b/app/models/targeted_user_link.rb index 2d3d536602b..3fb44b42a72 100644 --- a/app/models/targeted_user_link.rb +++ b/app/models/targeted_user_link.rb @@ -2,7 +2,7 @@ class TargetedUserLink < ApplicationRecord belongs_to :user, optional: true belongs_to :target_model, polymorphic: true, optional: false - enum target_context: { avis: 'avis', invite: 'invite' } + enum :target_context, { avis: 'avis', invite: 'invite' } def invalid_signed_in_user?(signed_in_user) signed_in_user && signed_in_user.email != target_email diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index be37f3821e4..eb808a18607 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -90,7 +90,7 @@ class TypeDeChamp < ApplicationRecord lexpol: REFERENTIEL_EXTERNE }.merge(INSTANCE_TYPE_DE_CHAMP_TO_CATEGORIE) - enum type_champs: { + enum :type_champs, { engagement_juridique: 'engagement_juridique', header_section: 'header_section', diff --git a/app/models/types_de_champ/linked_drop_down_list_type_de_champ.rb b/app/models/types_de_champ/linked_drop_down_list_type_de_champ.rb index 7fb51647ea1..d86ba73aa4a 100644 --- a/app/models/types_de_champ/linked_drop_down_list_type_de_champ.rb +++ b/app/models/types_de_champ/linked_drop_down_list_type_de_champ.rb @@ -32,7 +32,7 @@ def secondary_options class << self def champ_value(champ) - [champ.primary_value, champ.secondary_value].filter(&:present?).join(' / ') + [champ.primary_value, champ.secondary_value].compact_blank.join(' / ') end def champ_value_for_tag(champ, path = :value) diff --git a/app/models/user.rb b/app/models/user.rb index e32dd113a00..ffd12b2bf07 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,7 +3,7 @@ class User < ApplicationRecord include EmailSanitizableConcern include PasswordComplexityConcern - enum loged_in_with_france_connect: { + enum :loged_in_with_france_connect, { particulier: 'particulier', entreprise: 'entreprise', sipf: 'sipf', diff --git a/app/models/zone.rb b/app/models/zone.rb index 81a2a2e8b48..14f7c46f6de 100644 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -8,7 +8,7 @@ def current_label end def label_at(date) - label = labels.where('designated_on < ?', date)&.first || labels.last + label = labels.where(designated_on: ...date)&.first || labels.last label.name end diff --git a/app/validators/types_de_champ/header_section_consistency_validator.rb b/app/validators/types_de_champ/header_section_consistency_validator.rb index 062b27cf009..9b1d1b790d5 100644 --- a/app/validators/types_de_champ/header_section_consistency_validator.rb +++ b/app/validators/types_de_champ/header_section_consistency_validator.rb @@ -17,7 +17,7 @@ def errors_for_header_sections_order(procedure, attribute, types_de_champ) .map.with_index .filter_map { |tdc, i| tdc.header_section? ? [tdc, i] : nil } .map { |tdc, i| [tdc, tdc.check_coherent_header_level(types_de_champ.take(i))] } - .filter { |_tdc, errors| errors.present? } + .compact_blank .each do |tdc, message| procedure.errors.add( attribute, diff --git a/config/application.rb b/config/application.rb index f3d7a7b9dc8..0bede05dc60 100644 --- a/config/application.rb +++ b/config/application.rb @@ -31,8 +31,8 @@ class Application < Rails::Application # The default locale is :fr 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.default_locale = :fr - config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] - config.i18n.load_path += Dir[Rails.root.join('config', 'custom_locales', '**', '*.{rb,yml}')] + config.i18n.load_path += Rails.root.glob('config/locales/**/*.{rb,yml}') + config.i18n.load_path += Rails.root.glob('config/custom_locales/**/*.{rb,yml}') config.i18n.available_locales = [:fr, :en] config.i18n.fallbacks = [:fr] diff --git a/config/initializers/core_ext.rb b/config/initializers/core_ext.rb index 44ae562d2e5..8e39d683da0 100644 --- a/config/initializers/core_ext.rb +++ b/config/initializers/core_ext.rb @@ -1,3 +1,3 @@ -Dir[Rails.root.join("lib", "core_ext", "*.rb")].each do |core_ext_file| +Rails.root.glob('lib/core_ext/*.rb').each do |core_ext_file| require core_ext_file end diff --git a/lib/tasks/deployment/20230131154015_fix_bad_invitation_targeted_user_link.rake b/lib/tasks/deployment/20230131154015_fix_bad_invitation_targeted_user_link.rake index 213d2790fdb..42d4e57aa9e 100644 --- a/lib/tasks/deployment/20230131154015_fix_bad_invitation_targeted_user_link.rake +++ b/lib/tasks/deployment/20230131154015_fix_bad_invitation_targeted_user_link.rake @@ -8,7 +8,7 @@ namespace :after_party do invalid_invites_to_refresh = Invite.where('invites.created_at > ?', 1.month.ago) .joins(:targeted_user_link) .where(targeted_user_link: { target_model_type: 'Avis' }) - invalid_invites_to_silence = Invite.where('invites.created_at <= ?', 1.month.ago) + invalid_invites_to_silence = Invite.where(invites: { created_at: ..1.month.ago }) .joins(:targeted_user_link) .where(targeted_user_link: { target_model_type: 'Avis' }) diff --git a/spec/lib/tasks/deployment/20241215115134_feature_flag_lexpol_champs_spec.rake_spec.rb b/spec/lib/tasks/deployment/20241215115134_feature_flag_lexpol_champs_spec.rake_spec.rb index 2641d352052..1c2422007bf 100644 --- a/spec/lib/tasks/deployment/20241215115134_feature_flag_lexpol_champs_spec.rake_spec.rb +++ b/spec/lib/tasks/deployment/20241215115134_feature_flag_lexpol_champs_spec.rake_spec.rb @@ -36,4 +36,4 @@ expect(Flipper.enabled?(:lexpol, procedure_with_lexpol_without_admin_featured)).to eq(false) end end -end \ No newline at end of file +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 6ba94e8a812..c31ac26d258 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -29,8 +29,8 @@ # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # -Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } -Dir[Rails.root.join('spec/factories/**/*.rb')].each { |f| require f } +Rails.root.glob('spec/support/**/*.rb').each { |f| require f } +Rails.root.glob('spec/factories/**/*.rb').each { |f| require f } ActiveSupport::Deprecation.silenced = true