Avis: move notify_gestionnaire to private method
This commit is contained in:
parent
afae7478f5
commit
fe1b97b738
2 changed files with 18 additions and 4 deletions
|
@ -14,10 +14,6 @@ class Avis < ApplicationRecord
|
||||||
gestionnaire.try(:email) || email
|
gestionnaire.try(:email) || email
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_gestionnaire
|
|
||||||
AvisMailer.avis_invitation(self).deliver_now
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.link_avis_to_gestionnaire(gestionnaire)
|
def self.link_avis_to_gestionnaire(gestionnaire)
|
||||||
Avis.where(email: gestionnaire.email).update_all(email: nil, gestionnaire_id: gestionnaire.id)
|
Avis.where(email: gestionnaire.email).update_all(email: nil, gestionnaire_id: gestionnaire.id)
|
||||||
end
|
end
|
||||||
|
@ -26,4 +22,10 @@ class Avis < ApplicationRecord
|
||||||
avis = Avis.find_by(id: avis_id)
|
avis = Avis.find_by(id: avis_id)
|
||||||
avis.present? && avis.email == email
|
avis.present? && avis.email == email
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def notify_gestionnaire
|
||||||
|
AvisMailer.avis_invitation(self).deliver_now
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -86,4 +86,16 @@ RSpec.describe Avis, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#notify_gestionnaire' do
|
||||||
|
context 'when an avis is created' do
|
||||||
|
before do
|
||||||
|
avis_invitation_double = double('avis_invitation', deliver_now: true)
|
||||||
|
allow(AvisMailer).to receive(:avis_invitation).and_return(avis_invitation_double)
|
||||||
|
Avis.create(claimant: claimant, email: 'email@l.com')
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(AvisMailer).to have_received(:avis_invitation) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue