Add a mail_template decorator
This commit is contained in:
parent
0e5c90cb0c
commit
482ca2a317
2 changed files with 31 additions and 0 deletions
12
app/decorators/mail_template_decorator.rb
Normal file
12
app/decorators/mail_template_decorator.rb
Normal 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
|
19
spec/decorators/mail_template_decorator_spec.rb
Normal file
19
spec/decorators/mail_template_decorator_spec.rb
Normal 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
|
Loading…
Reference in a new issue