Before save copy body in rich_body

This commit is contained in:
Mathieu Magnin 2019-04-10 15:21:08 +02:00 committed by Paul Chavard
parent d13b7f953f
commit 10d3ba10f2
2 changed files with 11 additions and 0 deletions

View file

@ -11,8 +11,13 @@ module MailTemplateConcern
replace_tags(body, dossier)
end
def update_rich_body
self.rich_body = self.body
end
included do
has_rich_text :rich_body
before_save :update_rich_body
end
module ClassMethods

View file

@ -113,4 +113,10 @@ describe MailTemplateConcern do
expect(initiated_mail.body_for_dossier(dossier2)).to eq("n #{dossier2.id}")
end
end
describe '#update_rich_body' do
before { initiated_mail.update(body: "Voici le corps du mail") }
it { expect(initiated_mail.rich_body.to_plain_text).to eq(initiated_mail.body) }
end
end