Procedure: add inititad_mail with default provider
This commit is contained in:
parent
2f5dde381a
commit
c22c84f1f9
2 changed files with 33 additions and 0 deletions
|
@ -37,6 +37,11 @@ class Procedure < ActiveRecord::Base
|
|||
MailReceived.create(procedure: self) unless mail_received
|
||||
end
|
||||
|
||||
def initiated_mail_with_override
|
||||
initiated_mail_without_override || InitiatedMail.default
|
||||
end
|
||||
alias_method_chain :initiated_mail, :override
|
||||
|
||||
def path
|
||||
procedure_path.path unless procedure_path.nil?
|
||||
end
|
||||
|
|
|
@ -55,6 +55,34 @@ describe Procedure do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'initiated_mail' do
|
||||
subject { create(:procedure) }
|
||||
|
||||
context 'when initiated_mail is not customize' do
|
||||
it { expect(subject.initiated_mail.body).to eq(InitiatedMail.default.body) }
|
||||
end
|
||||
|
||||
context 'when initiated_mail is customize' do
|
||||
before :each do
|
||||
subject.initiated_mail = InitiatedMail.new(body: 'sisi')
|
||||
subject.save
|
||||
subject.reload
|
||||
end
|
||||
it { expect(subject.initiated_mail.body).to eq('sisi') }
|
||||
end
|
||||
|
||||
context 'when initiated_mail is customize ... again' do
|
||||
before :each do
|
||||
subject.initiated_mail = InitiatedMail.new(body: 'toto')
|
||||
subject.save
|
||||
subject.reload
|
||||
end
|
||||
it { expect(subject.initiated_mail.body).to eq('toto') }
|
||||
|
||||
it { expect(InitiatedMail.count).to eq(1) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validation' do
|
||||
context 'libelle' do
|
||||
it { is_expected.not_to allow_value(nil).for(:libelle) }
|
||||
|
|
Loading…
Add table
Reference in a new issue