#4807 better method/variable naming

This commit is contained in:
maatinito 2020-03-18 16:46:12 -10:00
parent e61c53f267
commit f5c2dc03c5
5 changed files with 11 additions and 11 deletions

View file

@ -105,7 +105,7 @@ class DossierMailer < ApplicationMailer
mail(from: NO_REPLY_EMAIL, to: instructeur.email, subject: @subject)
end
def notify_dossier_not_submitted(dossier)
def notify_brouillon_not_submitted(dossier)
@subject = "Attention : votre dossier n'est pas déposé."
@dossier = dossier

View file

@ -710,7 +710,7 @@ class Dossier < ApplicationRecord
brouillon_close_to_procedure_closing_date
.includes(:procedure, :user)
.find_each do |dossier|
DossierMailer.notify_dossier_not_submitted(dossier).deliver_later
DossierMailer.notify_brouillon_not_submitted(dossier).deliver_later
end
end
end

View file

@ -52,9 +52,9 @@ class DossierMailerPreview < ActionMailer::Preview
def notify_automatic_deletion_to_administration
DossierMailer.notify_automatic_deletion_to_administration([deleted_dossier, deleted_dossier], administration_email)
end
def notify_dossier_not_submitted
DossierMailer.notify_dossier_not_submitted(draft)
def notify_brouillon_not_submitted
DossierMailer.notify_brouillon_not_submitted(draft)
end
private

View file

@ -1160,22 +1160,22 @@ describe Dossier do
let!(:procedure_closed_before) { create(:procedure, auto_archive_on: Time.zone.today + Dossier::REMAINING_TIME_BEFORE_CLOSING - 1.day) }
# user 1 has three draft dossiers where one is for procedure that closes in two days ==> should trigger one mail
let!(:draft_in_time) { create(:dossier, user: user1, procedure: procedure_closed_in_time) }
let!(:draft_near_closing) { create(:dossier, user: user1, procedure: procedure_closed_in_time) }
let!(:draft_before) { create(:dossier, user: user1, procedure: procedure_closed_before) }
let!(:draft_later) { create(:dossier, user: user1, procedure: procedure_closed_later) }
# user 2 submitted a draft and en_construction dossier for the same procedure ==> should not trigger the mail
let!(:draft_in_time2) { create(:dossier, :en_construction, user: user2, procedure: procedure_closed_in_time) }
let!(:submitted_in_time2) { create(:dossier, user: user2, procedure: procedure_closed_in_time) }
let!(:draft_near_closing_2) { create(:dossier, :en_construction, user: user2, procedure: procedure_closed_in_time) }
let!(:submitted_in_time_2) { create(:dossier, user: user2, procedure: procedure_closed_in_time) }
before do
allow(DossierMailer).to receive(:notify_dossier_not_submitted).and_return(double(deliver_later: nil))
allow(DossierMailer).to receive(:notify_brouillon_not_submitted).and_return(double(deliver_later: nil))
Dossier.notify_draft_not_submitted
end
it 'notifies draft is not submitted' do
expect(DossierMailer).to have_received(:notify_dossier_not_submitted).once
expect(DossierMailer).to have_received(:notify_dossier_not_submitted).with(draft_in_time)
expect(DossierMailer).to have_received(:notify_brouillon_not_submitted).once
expect(DossierMailer).to have_received(:notify_brouillon_not_submitted).with(draft_near_closing)
end
end