replace filter+first with find

This commit is contained in:
clemkeirua 2020-09-24 15:09:41 +02:00 committed by Keirua (Rebase PR Action)
parent dfd2c1ee79
commit f3e487bd9e
3 changed files with 8 additions and 16 deletions

View file

@ -213,8 +213,7 @@ feature 'The routing', js: true do
def register_instructeur_and_log_in(email) def register_instructeur_and_log_in(email)
confirmation_email = emails_sent_to(email) confirmation_email = emails_sent_to(email)
.filter { |m| m.subject == 'Activez votre compte instructeur' } .find { |m| m.subject == 'Activez votre compte instructeur' }
.first
token_params = confirmation_email.body.match(/token=[^"]+/) token_params = confirmation_email.body.match(/token=[^"]+/)
visit "users/activate?#{token_params}" visit "users/activate?#{token_params}"

View file

@ -151,13 +151,11 @@ describe AttestationTemplate, type: :model do
context 'and their value in the dossier are not nil' do context 'and their value in the dossier are not nil' do
before do before do
dossier.champs dossier.champs
.filter { |champ| champ.libelle == 'libelleA' } .find { |champ| champ.libelle == 'libelleA' }
.first
.update(value: 'libelle1') .update(value: 'libelle1')
dossier.champs dossier.champs
.filter { |champ| champ.libelle == 'libelleB' } .find { |champ| champ.libelle == 'libelleB' }
.first
.update(value: 'libelle2') .update(value: 'libelle2')
end end

View file

@ -123,13 +123,11 @@ describe TagsSubstitutionConcern, type: :model do
context 'and their value in the dossier are not nil' do context 'and their value in the dossier are not nil' do
before do before do
dossier.champs dossier.champs
.filter { |champ| champ.libelle == 'libelleA' } .find { |champ| champ.libelle == 'libelleA' }
.first
.update(value: 'libelle1') .update(value: 'libelle1')
dossier.champs dossier.champs
.filter { |champ| champ.libelle == 'libelleB' } .find { |champ| champ.libelle == 'libelleB' }
.first
.update(value: 'libelle2') .update(value: 'libelle2')
end end
@ -151,8 +149,7 @@ describe TagsSubstitutionConcern, type: :model do
context 'and their value in the dossier are not nil' do context 'and their value in the dossier are not nil' do
before do before do
dossier.champs dossier.champs
.filter { |champ| champ.libelle == "Intitulé de l'‘«\"évènement\"»’" } .find { |champ| champ.libelle == "Intitulé de l'‘«\"évènement\"»’" }
.first
.update(value: 'ceci est mon évènement') .update(value: 'ceci est mon évènement')
end end
@ -302,13 +299,11 @@ describe TagsSubstitutionConcern, type: :model do
context 'and its value in the dossier are not nil' do context 'and its value in the dossier are not nil' do
before do before do
dossier.champs dossier.champs
.filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:date) } .find { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:date) }
.first
.update(value: '2017-04-15') .update(value: '2017-04-15')
dossier.champs dossier.champs
.filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:datetime) } .find { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:datetime) }
.first
.update(value: '2017-09-13 09:00') .update(value: '2017-09-13 09:00')
end end