Procedure: add the new mails
This commit is contained in:
parent
695dc16b85
commit
206d56f106
2 changed files with 14 additions and 4 deletions
|
@ -5,7 +5,6 @@ class Procedure < ActiveRecord::Base
|
|||
has_many :dossiers
|
||||
has_many :mail_templates
|
||||
|
||||
has_one :initiated_mail
|
||||
|
||||
has_one :procedure_path, dependent: :destroy
|
||||
|
||||
|
@ -30,10 +29,13 @@ class Procedure < ActiveRecord::Base
|
|||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :description, presence: true, allow_blank: false, allow_nil: false
|
||||
|
||||
def initiated_mail_with_override
|
||||
initiated_mail_without_override || InitiatedMail.default
|
||||
%w(InitiatedMail ReceivedMail ClosedMail RefusedMail WithoutContinuationMail).each do |name|
|
||||
has_one "#{name.underscore}".to_sym
|
||||
define_method("#{name.underscore}_with_override") do
|
||||
self.send("#{name.underscore}_without_override") || Object.const_get(name).default
|
||||
end
|
||||
alias_method_chain "#{name.underscore.to_sym}".to_s, :override
|
||||
end
|
||||
alias_method_chain :initiated_mail, :override
|
||||
|
||||
def path
|
||||
procedure_path.path unless procedure_path.nil?
|
||||
|
|
|
@ -23,6 +23,14 @@ describe Procedure do
|
|||
it { is_expected.to have_db_column(:published) }
|
||||
end
|
||||
|
||||
describe 'mails' do
|
||||
it { expect(subject.initiated_mail).to be_a(InitiatedMail) }
|
||||
it { expect(subject.received_mail).to be_a(ReceivedMail) }
|
||||
it { expect(subject.closed_mail).to be_a(ClosedMail) }
|
||||
it { expect(subject.refused_mail).to be_a(RefusedMail) }
|
||||
it { expect(subject.without_continuation_mail).to be_a(WithoutContinuationMail) }
|
||||
end
|
||||
|
||||
describe 'initiated_mail' do
|
||||
subject { create(:procedure) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue