From f5c2dc03c57a3ae08e07b78550963fe68be38d95 Mon Sep 17 00:00:00 2001 From: maatinito <15379878+maatinito@users.noreply.github.com> Date: Wed, 18 Mar 2020 16:46:12 -1000 Subject: [PATCH] #4807 better method/variable naming --- app/mailers/dossier_mailer.rb | 2 +- app/models/dossier.rb | 2 +- ...haml => notify_brouillon_not_submitted.html.haml} | 0 spec/mailers/previews/dossier_mailer_preview.rb | 6 +++--- spec/models/dossier_spec.rb | 12 ++++++------ 5 files changed, 11 insertions(+), 11 deletions(-) rename app/views/dossier_mailer/{notify_dossier_not_submitted.html.haml => notify_brouillon_not_submitted.html.haml} (100%) diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb index 0859ba0e7..6bc61df26 100644 --- a/app/mailers/dossier_mailer.rb +++ b/app/mailers/dossier_mailer.rb @@ -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 diff --git a/app/models/dossier.rb b/app/models/dossier.rb index f236ca36e..528c67a22 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -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 diff --git a/app/views/dossier_mailer/notify_dossier_not_submitted.html.haml b/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml similarity index 100% rename from app/views/dossier_mailer/notify_dossier_not_submitted.html.haml rename to app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml diff --git a/spec/mailers/previews/dossier_mailer_preview.rb b/spec/mailers/previews/dossier_mailer_preview.rb index b69ed2a69..19354e2da 100644 --- a/spec/mailers/previews/dossier_mailer_preview.rb +++ b/spec/mailers/previews/dossier_mailer_preview.rb @@ -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 diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index fc3b0c7f9..b484d0964 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -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