diff --git a/.rubocop.yml b/.rubocop.yml index 445c3400a..58f2402ee 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -866,7 +866,14 @@ Style/ClassVars: Enabled: false Style/CollectionMethods: - Enabled: false + PreferredMethods: + collect: map + collect!: map! + inject: reduce + detect: find + select: filter + find_all: filter + Enabled: true Style/ColonMethodCall: Enabled: true diff --git a/app/controllers/concerns/create_avis_concern.rb b/app/controllers/concerns/create_avis_concern.rb index 6f583c552..e7c34495c 100644 --- a/app/controllers/concerns/create_avis_concern.rb +++ b/app/controllers/concerns/create_avis_concern.rb @@ -36,7 +36,7 @@ module CreateAvisConcern if failed.any? flash.now.alert = failed - .select { |avis| avis.errors.present? } + .filter { |avis| avis.errors.present? } .map { |avis| "#{avis.email} : #{avis.errors.full_messages.join(', ')}" } # When an error occurs, return the avis back to the controller diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index 3a826e5af..6b04eb4ed 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -76,7 +76,7 @@ module Instructeurs if @current_filters.count > 0 filtered_ids = procedure_presentation.filtered_ids(@dossiers, statut) - filtered_sorted_ids = sorted_ids.select { |id| filtered_ids.include?(id) } + filtered_sorted_ids = sorted_ids.filter { |id| filtered_ids.include?(id) } else filtered_sorted_ids = sorted_ids end diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 78661a349..253e439e1 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -24,11 +24,11 @@ class RootController < ApplicationController .map.with_index { |type_de_champ, i| type_de_champ.champ.build(id: i) } all_champs - .select { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:header_section) } + .filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:header_section) } .each { |champ| champ.type_de_champ.libelle = 'un super titre de section' } all_champs - .select { |champ| [TypeDeChamp.type_champs.fetch(:drop_down_list), TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)].include?(champ.type_champ) } + .filter { |champ| [TypeDeChamp.type_champs.fetch(:drop_down_list), TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)].include?(champ.type_champ) } .each do |champ| champ.type_de_champ.drop_down_list = DropDownList.new(type_de_champ: champ.type_de_champ) champ.drop_down_list.value = @@ -47,7 +47,7 @@ class RootController < ApplicationController type_champ_values.each do |(type_champ, value)| all_champs - .select { |champ| champ.type_champ == type_champ } + .filter { |champ| champ.type_champ == type_champ } .each { |champ| champ.value = value } end diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index f5563e8a5..89f3e211f 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -356,7 +356,7 @@ class StatsController < ApplicationController if weekly_dossiers_count == 0 result = 0 else - weekly_dossier_with_avis_count = weekly_dossiers.select { |dossier| dossier.avis.present? }.count + weekly_dossier_with_avis_count = weekly_dossiers.filter { |dossier| dossier.avis.present? }.count result = percentage(weekly_dossier_with_avis_count, weekly_dossiers_count) end diff --git a/app/controllers/users/demarches_controller.rb b/app/controllers/users/demarches_controller.rb index 45f0fd7f4..02df95a8a 100644 --- a/app/controllers/users/demarches_controller.rb +++ b/app/controllers/users/demarches_controller.rb @@ -6,7 +6,7 @@ module Users .includes(:procedure) .map(&:procedure) .uniq - .select(&:publiee?) + .filter(&:publiee?) @popular_demarches = Procedure .includes(:service) diff --git a/app/models/champs/carte_champ.rb b/app/models/champs/carte_champ.rb index cb11520e6..a12792cc6 100644 --- a/app/models/champs/carte_champ.rb +++ b/app/models/champs/carte_champ.rb @@ -2,19 +2,19 @@ class Champs::CarteChamp < Champ # We are not using scopes here as we want to access # the following collections on unsaved records. def cadastres - geo_areas.select do |area| + geo_areas.filter do |area| area.source == GeoArea.sources.fetch(:cadastre) end end def quartiers_prioritaires - geo_areas.select do |area| + geo_areas.filter do |area| area.source == GeoArea.sources.fetch(:quartier_prioritaire) end end def parcelles_agricoles - geo_areas.select do |area| + geo_areas.filter do |area| area.source == GeoArea.sources.fetch(:parcelle_agricole) end end diff --git a/app/models/champs/linked_drop_down_list_champ.rb b/app/models/champs/linked_drop_down_list_champ.rb index d28b3004f..52e5386cf 100644 --- a/app/models/champs/linked_drop_down_list_champ.rb +++ b/app/models/champs/linked_drop_down_list_champ.rb @@ -30,7 +30,7 @@ class Champs::LinkedDropDownListChamp < Champ end def to_s - value.present? ? [primary_value, secondary_value].select(&:present?).join(' / ') : "" + value.present? ? [primary_value, secondary_value].filter(&:present?).join(' / ') : "" end def for_export diff --git a/app/models/champs/pays_champ.rb b/app/models/champs/pays_champ.rb index 78de3277f..6f916dbce 100644 --- a/app/models/champs/pays_champ.rb +++ b/app/models/champs/pays_champ.rb @@ -4,6 +4,6 @@ class Champs::PaysChamp < Champs::TextChamp end def self.disabled_options - pays.select { |v| (v =~ /^--.*--$/).present? } + pays.filter { |v| (v =~ /^--.*--$/).present? } end end diff --git a/app/models/concerns/tags_substitution_concern.rb b/app/models/concerns/tags_substitution_concern.rb index 537cd46ba..1410f4479 100644 --- a/app/models/concerns/tags_substitution_concern.rb +++ b/app/models/concerns/tags_substitution_concern.rb @@ -179,7 +179,7 @@ module TagsSubstitutionConcern raise NameError.new("The class #{self.class.name} includes TagsSubstitutionConcern, it should define the DOSSIER_STATE constant but it does not", :DOSSIER_STATE) end - tags.select { |tag| tag[:available_for_states].include?(self.class::DOSSIER_STATE) } + tags.filter { |tag| tag[:available_for_states].include?(self.class::DOSSIER_STATE) } end def champ_public_tags @@ -213,12 +213,12 @@ module TagsSubstitutionConcern tags_and_datas .map { |(tags, data)| [filter_tags(tags), data] } - .inject(text) { |acc, (tags, data)| replace_tags_with_values_from_data(acc, tags, data) } + .reduce(text) { |acc, (tags, data)| replace_tags_with_values_from_data(acc, tags, data) } end def replace_tags_with_values_from_data(text, tags, data) if data.present? - tags.inject(text) do |acc, tag| + tags.reduce(text) do |acc, tag| replace_tag(acc, tag, data) end else diff --git a/app/models/dossier.rb b/app/models/dossier.rb index c4768edf1..c1e11a3a3 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -426,15 +426,15 @@ class Dossier < ApplicationRecord end def check_mandatory_champs - (champs + champs.select(&:repetition?).flat_map(&:champs)) - .select(&:mandatory_and_blank?) + (champs + champs.filter(&:repetition?).flat_map(&:champs)) + .filter(&:mandatory_and_blank?) .map do |champ| "Le champ #{champ.libelle.truncate(200)} doit être rempli." end end def modifier_annotations!(instructeur) - champs_private.select(&:value_previously_changed?).each do |champ| + champs_private.filter(&:value_previously_changed?).each do |champ| log_dossier_operation(instructeur, :modifier_annotation, champ) end end diff --git a/app/models/drop_down_list.rb b/app/models/drop_down_list.rb index fc9451ecf..993bf0e04 100644 --- a/app/models/drop_down_list.rb +++ b/app/models/drop_down_list.rb @@ -9,7 +9,7 @@ class DropDownList < ApplicationRecord end def disabled_options - options.select { |v| (v =~ /^--.*--$/).present? } + options.filter { |v| (v =~ /^--.*--$/).present? } end def multiple diff --git a/app/models/instructeur.rb b/app/models/instructeur.rb index d9fd18dc9..baa45513d 100644 --- a/app/models/instructeur.rb +++ b/app/models/instructeur.rb @@ -74,7 +74,7 @@ class Instructeur < ApplicationRecord active_procedure_overviews = procedures .publiees .map { |procedure| procedure.procedure_overview(start_date) } - .select(&:had_some_activities?) + .filter(&:had_some_activities?) if active_procedure_overviews.count == 0 nil 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 3b6e32ad8..71f0784b1 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 @@ -30,7 +30,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas description: "#{description} (menu primaire)", lambda: -> (champs) { champs - .detect { |champ| champ.type_de_champ == tdc } + .find { |champ| champ.type_de_champ == tdc } &.primary_value } } @@ -41,7 +41,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas description: "#{description} (menu secondaire)", lambda: -> (champs) { champs - .detect { |champ| champ.type_de_champ == tdc } + .find { |champ| champ.type_de_champ == tdc } &.secondary_value } } diff --git a/app/models/types_de_champ/type_de_champ_base.rb b/app/models/types_de_champ/type_de_champ_base.rb index 8d808df2a..650f600d5 100644 --- a/app/models/types_de_champ/type_de_champ_base.rb +++ b/app/models/types_de_champ/type_de_champ_base.rb @@ -14,7 +14,7 @@ class TypesDeChamp::TypeDeChampBase libelle: libelle, description: description, lambda: -> (champs) { - champs.detect { |champ| champ.type_de_champ == tdc } + champs.find { |champ| champ.type_de_champ == tdc } } } ] diff --git a/app/services/administrateur_usage_statistics_service.rb b/app/services/administrateur_usage_statistics_service.rb index d7351e859..47a76c249 100644 --- a/app/services/administrateur_usage_statistics_service.rb +++ b/app/services/administrateur_usage_statistics_service.rb @@ -39,7 +39,7 @@ class AdministrateurUsageStatisticsService ds_nb_demarches_brouillons: nb_demarches_by_administrateur_id_and_state[[administrateur.id, "brouillon"]], nb_demarches_test: nb_dossiers_by_procedure_id - .select { |procedure_id, count| count > 0 && is_brouillon(procedure_id) } + .filter { |procedure_id, count| count > 0 && is_brouillon(procedure_id) } .count, nb_demarches_prod: nb_dossiers_by_procedure_id .reject { |procedure_id, count| count == 0 || is_brouillon(procedure_id) } diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index ea7475d17..cf834fe92 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -1,7 +1,7 @@ class PiecesJustificativesService def self.liste_pieces_justificatives(dossier) champs_blocs_repetables = dossier.champs - .select { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:repetition) } + .filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:repetition) } .flat_map(&:champs) champs_pieces_justificatives_with_attachments( @@ -15,7 +15,7 @@ class PiecesJustificativesService end def self.serialize_types_de_champ_as_type_pj(procedure) - tdcs = procedure.types_de_champ.select { |type_champ| type_champ.old_pj.present? } + tdcs = procedure.types_de_champ.filter { |type_champ| type_champ.old_pj.present? } tdcs.map.with_index do |type_champ, order_place| description = type_champ.description if /^(?.*?)(?:[\r\n]+)Récupérer le formulaire vierge pour mon dossier : (?http.*)$/m =~ description @@ -32,7 +32,7 @@ class PiecesJustificativesService end def self.serialize_champs_as_pjs(dossier) - dossier.champs.select { |champ| champ.type_de_champ.old_pj }.map do |champ| + dossier.champs.filter { |champ| champ.type_de_champ.old_pj }.map do |champ| { created_at: champ.created_at&.in_time_zone('UTC'), type_de_piece_justificative_id: champ.type_de_champ.old_pj[:stable_id], @@ -46,7 +46,7 @@ class PiecesJustificativesService def self.champs_pieces_justificatives_with_attachments(champs) champs - .select { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) } + .filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) } .filter { |pj| pj.piece_justificative_file.attached? } end end diff --git a/app/services/procedure_export_service.rb b/app/services/procedure_export_service.rb index e308a5f69..e4bf53727 100644 --- a/app/services/procedure_export_service.rb +++ b/app/services/procedure_export_service.rb @@ -122,7 +122,7 @@ class ProcedureExportService @etablissements = @dossiers.flat_map do |dossier| [dossier.champs, dossier.champs_private] .flatten - .select { |champ| champ.is_a?(Champs::SiretChamp) } + .filter { |champ| champ.is_a?(Champs::SiretChamp) } end.map(&:etablissement).compact if @etablissements.any? diff --git a/app/services/procedure_export_v2_service.rb b/app/services/procedure_export_v2_service.rb index f29a5b1d2..0d7d3b74c 100644 --- a/app/services/procedure_export_v2_service.rb +++ b/app/services/procedure_export_v2_service.rb @@ -40,7 +40,7 @@ class ProcedureExportV2Service @etablissements ||= dossiers.flat_map do |dossier| [dossier.champs, dossier.champs_private] .flatten - .select { |champ| champ.is_a?(Champs::SiretChamp) } + .filter { |champ| champ.is_a?(Champs::SiretChamp) } end.map(&:etablissement).compact + dossiers.map(&:etablissement).compact end @@ -52,7 +52,7 @@ class ProcedureExportV2Service @champs_repetables ||= dossiers.flat_map do |dossier| [dossier.champs, dossier.champs_private] .flatten - .select { |champ| champ.is_a?(Champs::RepetitionChamp) } + .filter { |champ| champ.is_a?(Champs::RepetitionChamp) } end.group_by(&:libelle) end diff --git a/app/services/zxcvbn_service.rb b/app/services/zxcvbn_service.rb index 5b0caa762..0b11d4135 100644 --- a/app/services/zxcvbn_service.rb +++ b/app/services/zxcvbn_service.rb @@ -7,7 +7,7 @@ class ZxcvbnService wxcvbn = compute_zxcvbn score = wxcvbn.score length = @password.blank? ? 0 : @password.length - vulnerabilities = wxcvbn.match_sequence.map { |m| m.matched_word.nil? ? m.token : m.matched_word }.select { |s| s.length > 2 }.join(', ') + vulnerabilities = wxcvbn.match_sequence.map { |m| m.matched_word.nil? ? m.token : m.matched_word }.filter { |s| s.length > 2 }.join(', ') [score, vulnerabilities, length] end diff --git a/lib/tasks/2017_07_18_clean_followed_dossiers.rake b/lib/tasks/2017_07_18_clean_followed_dossiers.rake index 2c9a5f4ce..abd204e15 100644 --- a/lib/tasks/2017_07_18_clean_followed_dossiers.rake +++ b/lib/tasks/2017_07_18_clean_followed_dossiers.rake @@ -3,7 +3,7 @@ namespace :'2017_07_18_clean_followed_dossiers' do Follow.where(gestionnaire_id: nil).destroy_all Follow.where(dossier_id: nil).destroy_all - duplicate_follows = Follow.group('gestionnaire_id', 'dossier_id').count.select { |_gestionnaire_id_dossier_id, count| count > 1 }.keys + duplicate_follows = Follow.group('gestionnaire_id', 'dossier_id').count.filter { |_gestionnaire_id_dossier_id, count| count > 1 }.keys duplicate_ids = duplicate_follows.map { |gestionnaire_id, dossier_id| Follow.where(gestionnaire_id: gestionnaire_id, dossier_id: dossier_id).pluck(:id) } diff --git a/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake b/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake index caa4c674f..629146e06 100644 --- a/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake +++ b/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake @@ -3,7 +3,7 @@ require Rails.root.join("lib", "tasks", "task_helper") namespace :'2017_07_26_clean_birthdate_on_individual' do task clean: :environment do # remove duplicates - duplicate_individuals = Individual.group("dossier_id").count.select { |_dossier_id, count| count > 1 }.keys + duplicate_individuals = Individual.group("dossier_id").count.filter { |_dossier_id, count| count > 1 }.keys duplicate_individuals.each { |dossier_id| Individual.where(dossier_id: dossier_id, nom: nil).delete_all } # Match "" => nil @@ -11,13 +11,13 @@ namespace :'2017_07_26_clean_birthdate_on_individual' do individuals_with_date = Individual.where.not(birthdate: nil) # Match 31/12/2017 => 2017-12-31 - individuals_with_date.select { |i| /^\d{2}\/\d{2}\/\d{4}$/.match(i.birthdate) }.each do |i| + individuals_with_date.filter { |i| /^\d{2}\/\d{2}\/\d{4}$/.match(i.birthdate) }.each do |i| rake_puts "cleaning #{i.birthdate}" i.update(birthdate: Date.parse(i.birthdate).iso8601) rescue nil end # Match 31/12/17 => 2017-12-31 - individuals_with_date.select { |i| /^\d{2}\/\d{2}\/\d{2}$/.match(i.birthdate) }.each do |i| + individuals_with_date.filter { |i| /^\d{2}\/\d{2}\/\d{2}$/.match(i.birthdate) }.each do |i| rake_puts "cleaning #{i.birthdate}" new_date = Date.strptime(i.birthdate, "%d/%m/%y") if new_date.year > 2017 diff --git a/lib/tasks/2017_08_01_clean_assign_to.rake b/lib/tasks/2017_08_01_clean_assign_to.rake index bbc2d86dd..25e192eec 100644 --- a/lib/tasks/2017_08_01_clean_assign_to.rake +++ b/lib/tasks/2017_08_01_clean_assign_to.rake @@ -1,6 +1,6 @@ namespace :'2017_08_01_clean_assign_to' do task clean: :environment do - duplicates = AssignTo.group(:gestionnaire_id, :procedure_id).count.select { |_gestionnaire_id_procedure_id, count| count > 1 }.keys + duplicates = AssignTo.group(:gestionnaire_id, :procedure_id).count.filter { |_gestionnaire_id_procedure_id, count| count > 1 }.keys duplicate_ids = duplicates.map { |gestionnaire_id, procedure_id| AssignTo.where(gestionnaire_id: gestionnaire_id, procedure_id: procedure_id).pluck(:id) } diff --git a/lib/tasks/2018_01_18_clean_datetime_in_champs.rake b/lib/tasks/2018_01_18_clean_datetime_in_champs.rake index a5f5bb627..3f3128444 100644 --- a/lib/tasks/2018_01_18_clean_datetime_in_champs.rake +++ b/lib/tasks/2018_01_18_clean_datetime_in_champs.rake @@ -5,20 +5,20 @@ namespace :'2018_01_18_clean_datetime_in_champs' do datetime_champs = TypeDeChamp.where(type_champ: "datetime").flat_map(&:champ) # Match " HH:MM" => nil a datetime is not valid if not composed by date AND time - datetime_champs.select { |c| /^\s\d{2}:\d{2}$/.match(c.value) }.each do |c| + datetime_champs.filter { |c| /^\s\d{2}:\d{2}$/.match(c.value) }.each do |c| rake_puts "cleaning #{c.value} => nil" c.update_columns(value: nil) end # 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.filter { |c| /^\d{2}\/\d{2}\/\d{4}\s\d{2}:\d{2}$/ =~ c.value }.each do |c| formated_date = Time.zone.strptime(c.value, "%d/%m/%Y %H:%M").strftime("%Y-%m-%d %H:%M") rake_puts "cleaning #{c.value} => #{formated_date}" c.update_columns(value: formated_date) end # Match "ddmmYYYY HH:MM" => "YYYY-mm-dd HH:MM" - datetime_champs.select { |c| /^\d{8}\s\d{2}:\d{2}$/ =~ c.value }.each do |c| + datetime_champs.filter { |c| /^\d{8}\s\d{2}:\d{2}$/ =~ c.value }.each do |c| day = c.value[0, 2] month = c.value[2, 2] year = c.value[4, 4] diff --git a/lib/tasks/2018_02_28_clean_gestionnaire_emails.rake b/lib/tasks/2018_02_28_clean_gestionnaire_emails.rake index 6106ae5ab..19c51d2f9 100644 --- a/lib/tasks/2018_02_28_clean_gestionnaire_emails.rake +++ b/lib/tasks/2018_02_28_clean_gestionnaire_emails.rake @@ -1,10 +1,10 @@ namespace :'2018_02_28_clean_invalid_emails_accounts' do task clean: :environment do - Gestionnaire.pluck(:email, :id).select { |e, _id| e.include?(" ") }.each do |_email, id| + Gestionnaire.pluck(:email, :id).filter { |e, _id| e.include?(" ") }.each do |_email, id| Gestionnaire.find_by(id: id, current_sign_in_at: nil)&.destroy # ensure account was never used end - User.pluck(:email, :id).select { |e, _id| e.include?(" ") }.each do |_email, id| + User.pluck(:email, :id).filter { |e, _id| e.include?(" ") }.each do |_email, id| User.find_by(id: id, current_sign_in_at: nil)&.destroy # ensure account was never used end end diff --git a/lib/tasks/2018_04_03_attestation_closed_mail_discrepancy.rake b/lib/tasks/2018_04_03_attestation_closed_mail_discrepancy.rake index 72db6d867..2c7a20cf9 100644 --- a/lib/tasks/2018_04_03_attestation_closed_mail_discrepancy.rake +++ b/lib/tasks/2018_04_03_attestation_closed_mail_discrepancy.rake @@ -1,7 +1,7 @@ namespace :'2018_04_03_attestation_closed_mail_discrepancy' do task mail_adminstrators: :environment do Administrateur.includes(:procedures).find_each(batch_size: 10) do |admin| - procedures = admin.procedures.where(archived_at: nil).select { |p| p.closed_mail_template_attestation_inconsistency_state == :missing_tag } + procedures = admin.procedures.where(archived_at: nil).filter { |p| p.closed_mail_template_attestation_inconsistency_state == :missing_tag } if procedures.any? # Use `deliver_now` because the delayed job cannot find the `Mailers::AttestationClosedMailDiscrepancyMaile` class in production Mailers::AttestationClosedMailDiscrepancyMailer.missing_attestation_tag_email(admin, procedures).deliver_now! diff --git a/lib/tasks/2018_06_05_resend_attestations.rake b/lib/tasks/2018_06_05_resend_attestations.rake index de3e49b49..a2ad1aaf4 100644 --- a/lib/tasks/2018_06_05_resend_attestations.rake +++ b/lib/tasks/2018_06_05_resend_attestations.rake @@ -3,7 +3,7 @@ require Rails.root.join("lib", "tasks", "task_helper") namespace :'2018_06_05_resend_attestations' do task set: :environment do procedure = Procedure.find(4247) - dossiers = procedure.dossiers.includes(:attestation).where(state: 'accepte').select do |d| + dossiers = procedure.dossiers.includes(:attestation).where(state: 'accepte').filter do |d| d.processed_at < procedure.attestation_template.updated_at end diff --git a/lib/tasks/2018_06_06_users_for_admins_and_gestionnaires.rake b/lib/tasks/2018_06_06_users_for_admins_and_gestionnaires.rake index 91c56b6af..5f94192ca 100644 --- a/lib/tasks/2018_06_06_users_for_admins_and_gestionnaires.rake +++ b/lib/tasks/2018_06_06_users_for_admins_and_gestionnaires.rake @@ -14,7 +14,7 @@ namespace :'2018_06_06_users_for_admins_and_gestionnaires' do .joins("INNER JOIN users ON #{table_name}.email = users.email") .where(users: { confirmed_at: nil }) .to_a - .select(&block) + .filter(&block) rake_puts "Sending emails to #{already_activated.count} #{table_name} that were already confirmed" diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 4eac9c120..52105bbab 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -5,7 +5,7 @@ describe ApplicationController, type: :controller do it 'is present' do before_actions = ApplicationController ._process_action_callbacks - .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } + .filter { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:set_raven_context) diff --git a/spec/controllers/instructeurs/instructeur_controller_spec.rb b/spec/controllers/instructeurs/instructeur_controller_spec.rb index 67ea8ca89..3c8ae4dff 100644 --- a/spec/controllers/instructeurs/instructeur_controller_spec.rb +++ b/spec/controllers/instructeurs/instructeur_controller_spec.rb @@ -5,7 +5,7 @@ describe Instructeurs::InstructeurController, type: :controller do it 'is present' do before_actions = Instructeurs::InstructeurController ._process_action_callbacks - .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } + .filter { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:authenticate_instructeur!) diff --git a/spec/controllers/instructeurs/procedures_controller_spec.rb b/spec/controllers/instructeurs/procedures_controller_spec.rb index ef66acd25..a6a0b8246 100644 --- a/spec/controllers/instructeurs/procedures_controller_spec.rb +++ b/spec/controllers/instructeurs/procedures_controller_spec.rb @@ -5,7 +5,7 @@ describe Instructeurs::ProceduresController, type: :controller do it "is present" do before_actions = Instructeurs::ProceduresController ._process_action_callbacks - .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } + .filter { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:ensure_ownership!) @@ -46,7 +46,7 @@ describe Instructeurs::ProceduresController, type: :controller do it "is present" do before_actions = Instructeurs::ProceduresController ._process_action_callbacks - .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } + .filter { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:redirect_to_avis_if_needed) diff --git a/spec/controllers/new_administrateur/administrateur_controller_spec.rb b/spec/controllers/new_administrateur/administrateur_controller_spec.rb index 6dbd65ffd..d55ce9b99 100644 --- a/spec/controllers/new_administrateur/administrateur_controller_spec.rb +++ b/spec/controllers/new_administrateur/administrateur_controller_spec.rb @@ -3,7 +3,7 @@ describe NewAdministrateur::AdministrateurController, type: :controller do it 'is present' do before_actions = NewAdministrateur::AdministrateurController ._process_action_callbacks - .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } + .filter { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:authenticate_administrateur!) diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index 478ede36c..4c60081bc 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -7,7 +7,7 @@ describe Users::DossiersController, type: :controller do it 'are present' do before_actions = Users::DossiersController ._process_action_callbacks - .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } + .filter { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:ensure_ownership!, :ensure_ownership_or_invitation!, :forbid_invite_submission!) diff --git a/spec/controllers/users/user_controller_spec.rb b/spec/controllers/users/user_controller_spec.rb index 7f6c2b1f1..f5601760e 100644 --- a/spec/controllers/users/user_controller_spec.rb +++ b/spec/controllers/users/user_controller_spec.rb @@ -5,7 +5,7 @@ describe Users::UserController, type: :controller do it 'is present' do before_actions = Users::UserController ._process_action_callbacks - .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } + .filter { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:authenticate_user!) diff --git a/spec/models/attestation_template_spec.rb b/spec/models/attestation_template_spec.rb index 129c3c358..471b591d8 100644 --- a/spec/models/attestation_template_spec.rb +++ b/spec/models/attestation_template_spec.rb @@ -149,12 +149,12 @@ describe AttestationTemplate, type: :model do context 'and their value in the dossier are not nil' do before do dossier.champs - .select { |champ| champ.libelle == 'libelleA' } + .filter { |champ| champ.libelle == 'libelleA' } .first .update(value: 'libelle1') dossier.champs - .select { |champ| champ.libelle == 'libelleB' } + .filter { |champ| champ.libelle == 'libelleB' } .first .update(value: 'libelle2') end diff --git a/spec/models/concern/tags_substitution_concern_spec.rb b/spec/models/concern/tags_substitution_concern_spec.rb index c6be332c5..a2d3b1443 100644 --- a/spec/models/concern/tags_substitution_concern_spec.rb +++ b/spec/models/concern/tags_substitution_concern_spec.rb @@ -99,12 +99,12 @@ describe TagsSubstitutionConcern, type: :model do context 'and their value in the dossier are not nil' do before do dossier.champs - .select { |champ| champ.libelle == 'libelleA' } + .filter { |champ| champ.libelle == 'libelleA' } .first .update(value: 'libelle1') dossier.champs - .select { |champ| champ.libelle == 'libelleB' } + .filter { |champ| champ.libelle == 'libelleB' } .first .update(value: 'libelle2') end @@ -228,12 +228,12 @@ describe TagsSubstitutionConcern, type: :model do context 'and its value in the dossier are not nil' do before do dossier.champs - .select { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:date) } + .filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:date) } .first .update(value: '2017-04-15') dossier.champs - .select { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:datetime) } + .filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:datetime) } .first .update(value: '2017-09-13 09:00') end diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 1222e3c22..08d65d4fe 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -460,7 +460,7 @@ describe Dossier do before do (dossier.champs + dossier.champs_private) - .select { |c| c.libelle.match?(/^specified/) } + .filter { |c| c.libelle.match?(/^specified/) } .each { |c| c.update_attribute(:value, "specified") } end