Skip to content

Commit

Permalink
Ne fait pas de relance pour les comptes sans structure
Browse files Browse the repository at this point in the history
pour éviter l'erreur rollbar
https://app.rollbar.com/a/eva-betagouv/fix/item/eva/828?utm_campaign=new_item_message&utm_medium=slack&utm_source=rollbar-notification
undefined method `cible_evaluation' for nil:NilClass
at
relance(/app/app/mailers/compte_mailer.rb:20)
  • Loading branch information
etienneCharignon committed Sep 27, 2023
1 parent 2e9ef7e commit bf1b3db
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/jobs/relance_utilisateur_pour_non_activation_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class RelanceUtilisateurPourNonActivationJob < ApplicationJob

def perform(compte_id)
compte = Compte.find_by id: compte_id
return if compte.blank?
return if compte.blank? || compte.structure.blank?

campagnes = Campagne.avec_nombre_evaluations_et_derniere_evaluation.where(compte: compte)
return unless campagnes.map(&:nombre_evaluations).reduce(:+).to_i.zero?
Expand Down
21 changes: 20 additions & 1 deletion spec/jobs/relance_utilisateur_pour_non_activation_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,26 @@
end
end

context 'quand le compte a une campagne sans passations et pas de structure' do
let(:campagne) { create :campagne, compte: compte }

before do
compte.update(structure_id: nil)
end

it 'ne fais rien' do
expect do
RelanceUtilisateurPourNonActivationJob.perform_now(compte.id)
end.to change { ActionMailer::Base.deliveries.count }.by(0)
end
end

context 'quand le compte a été supprimé' do
it { RelanceUtilisateurPourNonActivationJob.perform_now(1) }
it do
id_compte_supprime = 1
expect do
RelanceUtilisateurPourNonActivationJob.perform_now(id_compte_supprime)
end.to change { ActionMailer::Base.deliveries.count }.by(0)
end
end
end

0 comments on commit bf1b3db

Please sign in to comment.