Add a mail_template decorator

This commit is contained in:
Mathieu Magnin 2017-01-24 11:58:09 +01:00
parent 0e5c90cb0c
commit 482ca2a317
2 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,12 @@
class MailTemplateDecorator < Draper::Decorator
delegate_all
def name
case object.type
when "MailReceived"
"Email d'accusé de réception"
else
object.type
end
end
end

View file

@ -0,0 +1,19 @@
require 'spec_helper'
describe MailTemplateDecorator do
let(:mail_template) {create :mail_template}
let(:decorator) { mail_template.decorate }
context '#name' do
subject { decorator.name }
it { is_expected.to eq decorator.type}
context 'when mail_template is a MailReceived' do
let(:mail_template) {create :mail_template, :dossier_received}
it { is_expected.to eq "Email d'accusé de réception" }
end
end
end